diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index a76fa1945c2..71e80f703af 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -480,8 +480,8 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'Bookkeeping';
$objectlabel = 'Bookkeeping';
- $permissiontoread = $user->rights->societe->lire;
- $permissiontodelete = $user->rights->societe->supprimer;
+ $permissiontoread = $user->hasRight('societe', 'lire');
+ $permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index ba94415782f..e417f21832c 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -395,8 +395,8 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'Bookkeeping';
$objectlabel = 'Bookkeeping';
- $permissiontoread = $user->rights->societe->lire;
- $permissiontodelete = $user->rights->societe->supprimer;
+ $permissiontoread = $user->hasRight('societe', 'lire');
+ $permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index b02d05ca478..303e6f3cfec 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -186,7 +186,7 @@ if (isModEnabled('adherent') && !empty($user->rights->adherent->lire)) {
if (isModEnabled('recruitment') && !empty($user->rights->recruitment->recruitmentjobposition->read)) {
$elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
}
-if (isModEnabled("societe") && !empty($user->rights->societe->lire)) {
+if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
$elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
}
if (isModEnabled('project')) {
diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php
index d4d652f3e74..2c7653c3bb3 100644
--- a/htdocs/api/class/api_documents.class.php
+++ b/htdocs/api/class/api_documents.class.php
@@ -272,7 +272,7 @@ class Documents extends DolibarrApi
if ($modulepart == 'societe' || $modulepart == 'thirdparty') {
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index 96caac1dbb4..373effecbe8 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -397,7 +397,7 @@ if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)
print '';
}
-if (!empty($user->rights->societe->lire)) {
+if ($user->hasRight('societe', 'lire')) {
print '';
print '
';
print '
';
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index 76381c0d53d..e59ff070aec 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -315,7 +315,7 @@ class Categories extends DolibarrApi
throw new RestException(401);
} elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) {
throw new RestException(401);
- } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) {
+ } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) {
throw new RestException(401);
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 67df6af0298..1eca4555e91 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -131,7 +131,7 @@ if ($id > 0 && empty($object->id)) {
}
}
if ($object->id > 0) {
- if (!($object->client > 0) || empty($user->rights->societe->lire)) {
+ if (!($object->client > 0) || !$user->hasRight('societe', 'lire')) {
accessforbidden();
}
}
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index ed6184e0cd4..01f3bba9eff 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -594,7 +594,7 @@ print '
';
/*
* Last modified customers or prospects
*/
-if (isModEnabled("societe") && $user->rights->societe->lire) {
+if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -700,7 +700,7 @@ if (isModEnabled("societe") && $user->rights->societe->lire) {
/*
* Last suppliers
*/
-if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->societe->lire) {
+if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index eea44ab7387..1bcffd9e5f9 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -312,8 +312,8 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'Contact';
$objectlabel = 'Contact';
- $permissiontoread = $user->rights->societe->lire;
- $permissiontodelete = $user->rights->societe->supprimer;
+ $permissiontoread = $user->hasRight('societe', 'lire');
+ $permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@@ -690,7 +690,7 @@ $arrayofmassactions = array(
// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
-if ($user->rights->societe->supprimer) {
+if ($user->hasRight('societe', 'supprimer')) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if ($user->rights->societe->creer) {
diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php
index c66a49557d0..77cd3234cd8 100644
--- a/htdocs/core/ajax/objectonoff.php
+++ b/htdocs/core/ajax/objectonoff.php
@@ -67,7 +67,7 @@ if (!empty($user->socid)) {
$socid = $user->socid;
}
-//$user->rights->societe->lire = 0;$user->rights->fournisseur->lire = 0;
+//$user->hasRight('societe', 'lire') = 0;$user->rights->fournisseur->lire = 0;
//restrictedArea($user, 'societe', $id);
if (in_array($field, array('status'))) {
diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php
index 364b79932ef..cb934debef3 100644
--- a/htdocs/core/boxes/box_clients.php
+++ b/htdocs/core/boxes/box_clients.php
@@ -86,7 +86,7 @@ class box_clients extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max));
- if ($user->rights->societe->lire) {
+ if ($user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index f257d7db18d..f051fe5ade3 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
- if ($user->rights->societe->lire && $user->rights->societe->contact->lire) {
+ if ($user->hasRight('societe', 'lire') && $user->rights->societe->contact->lire) {
$sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
$sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php
index 2bf5a2c0693..ec82f1a57e4 100644
--- a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php
+++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php
@@ -86,7 +86,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastOutstandingBillReached", $max));
- if ($user->rights->societe->lire) {
+ if ($user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php
index a60d5c20a93..0f63582370c 100644
--- a/htdocs/core/boxes/box_dolibarr_state_board.php
+++ b/htdocs/core/boxes/box_dolibarr_state_board.php
@@ -114,8 +114,8 @@ class box_dolibarr_state_board extends ModeleBoxes
$conditions = array(
'users' => $user->hasRight('user', 'user', 'lire'),
'members' => isModEnabled('adherent') && $user->rights->adherent->lire,
- 'customers' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
- 'prospects' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
+ 'customers' => isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
+ 'prospects' => isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
'suppliers' => ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->lire)
|| (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)
|| (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)
diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php
index 59280aeec62..1c14ac0be4f 100644
--- a/htdocs/core/boxes/box_fournisseurs.php
+++ b/htdocs/core/boxes/box_fournisseurs.php
@@ -81,7 +81,7 @@ class box_fournisseurs extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max));
- if ($user->rights->societe->lire) {
+ if ($user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php
index 3341e08107d..90ffc82a5d8 100644
--- a/htdocs/core/boxes/box_goodcustomers.php
+++ b/htdocs/core/boxes/box_goodcustomers.php
@@ -69,7 +69,7 @@ class box_goodcustomers extends ModeleBoxes
$this->enabled = 0; // not enabled by default. Very slow on large database
}
- $this->hidden = empty($user->rights->societe->lire);
+ $this->hidden = !$user->hasRight('societe', 'lire');
}
/**
@@ -90,7 +90,7 @@ class box_goodcustomers extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max));
- if ($user->rights->societe->lire) {
+ if ($user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,";
$sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php
index 205cf09419c..69e8432a879 100644
--- a/htdocs/core/boxes/box_prospect.php
+++ b/htdocs/core/boxes/box_prospect.php
@@ -86,7 +86,7 @@ class box_prospect extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max));
- if ($user->rights->societe->lire) {
+ if ($user->hasRight('societe', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php
index 6267c6ff390..c763bc1a04e 100644
--- a/htdocs/core/class/html.formcontract.class.php
+++ b/htdocs/core/class/html.formcontract.class.php
@@ -104,7 +104,7 @@ class FormContract
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
- if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) {
+ if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) {
// Do nothing
} else {
$labeltoshow = dol_trunc($obj->ref, 18);
diff --git a/htdocs/core/class/html.formintervention.class.php b/htdocs/core/class/html.formintervention.class.php
index 107e9ba378a..751e77eafe1 100644
--- a/htdocs/core/class/html.formintervention.class.php
+++ b/htdocs/core/class/html.formintervention.class.php
@@ -99,7 +99,7 @@ class FormIntervention
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
- if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) {
+ if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) {
// Do nothing
} else {
$labeltoshow = dol_trunc($obj->ref, 18);
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 4d34211ed17..d4c3b1aa21f 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -206,7 +206,7 @@ class FormProjets
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
- if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) {
+ if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) {
// Do nothing
} else {
if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) { // We discard closed except if selected
diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php
index 96bd34143c7..cb5a7f41f8f 100644
--- a/htdocs/core/lib/agenda.lib.php
+++ b/htdocs/core/lib/agenda.lib.php
@@ -104,7 +104,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
}
}
- if (isModEnabled('societe') && !empty($user->rights->societe->lire)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire')) {
print '
';
print img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth inline-block"');
print $form->select_company($socid, 'search_socid', '', ' ', 0, 0, null, 0, 'minwidth100 maxwidth500');
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 9cadb431ec5..b4ae935677b 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -242,7 +242,7 @@ function societe_prepare_head(Societe $object)
$h++;
}
- if (isModEnabled('website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) {
+ if (isModEnabled('website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && ($user->hasRight('societe', 'lire'))) {
$head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.urlencode($object->id);
$head[$h][1] = $langs->trans("WebSiteAccounts");
$nbNote = 0;
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index ce6f9b38320..1c0d7d1aab1 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -421,7 +421,7 @@ function restrictedArea(User $user, $features, $objectid = 0, $tableandshare = '
}
if ($feature == 'societe') {
- if (empty($user->rights->societe->lire) && empty($user->rights->fournisseur->lire)) {
+ if (!$user->hasRight('societe', 'lire') && empty($user->rights->fournisseur->lire)) {
$readok = 0;
$nbko++;
}
@@ -831,7 +831,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
if ($user->socid != $objectid) {
return false;
}
- } elseif (isModEnabled("societe") && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) {
+ } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && empty($user->rights->societe->client->voir))) {
// If internal user: Check permission for internal users that are restricted on their objects
$sql = "SELECT COUNT(sc.fk_soc) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -857,7 +857,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")";
$sql .= " AND dbt.fk_soc = ".((int) $user->socid);
- } elseif (isModEnabled("societe") && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) {
+ } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && empty($user->rights->societe->client->voir))) {
// If internal user: Check permission for internal users that are restricted on their objects
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
diff --git a/htdocs/hrm/position_card.php b/htdocs/hrm/position_card.php
index 746e1265a0b..168756d9851 100644
--- a/htdocs/hrm/position_card.php
+++ b/htdocs/hrm/position_card.php
@@ -337,7 +337,7 @@ function displayPositionCard(&$object)
// */
// $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id;
// $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id;
-// $genallowed = $user->rights->societe->lire;
+// $genallowed = $user->hasRight('societe', 'lire');
// $delallowed = $user->rights->societe->creer;
//
// print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
diff --git a/htdocs/margin/index.php b/htdocs/margin/index.php
index 8363cd331c4..79595d5a8ee 100644
--- a/htdocs/margin/index.php
+++ b/htdocs/margin/index.php
@@ -27,7 +27,7 @@ require '../main.inc.php';
if ($user->rights->produit->lire) {
$page = 'productMargins';
-} elseif ($user->rights->societe->lire) {
+} elseif ($user->hasRight('societe', 'lire')) {
$page = 'customerMargins';
} else {
$page = 'agentMargins';
diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php
index 802541b98ca..10e449026fa 100644
--- a/htdocs/margin/lib/margins.lib.php
+++ b/htdocs/margin/lib/margins.lib.php
@@ -71,7 +71,7 @@ function marges_prepare_head()
$h++;
}
- if ($user->rights->societe->lire) {
+ if ($user->hasRight('societe', 'lire')) {
$head[$h][0] = DOL_URL_ROOT."/margin/customerMargins.php";
$head[$h][1] = $langs->trans("CustomerMargins");
$head[$h][2] = 'customerMargins';
diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php
index d1ba18f82fd..fb9a38ed442 100644
--- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php
+++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php
@@ -263,7 +263,7 @@ for ($i = 1; $i <= 4; $i++) {
control->tpl['id'].'&action=edit&token='.newToken().'&canvas='.urlencode($canvas); ?>">trans("Modify"); ?>
-rights->societe->supprimer) { ?>
+hasRight('societe', 'supprimer')) { ?>
use_javascript_ajax) { ?>
trans('Delete'); ?>
@@ -283,7 +283,7 @@ for ($i = 1; $i <= 4; $i++) {
*/
$filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid;
$urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid;
-$genallowed = $user->rights->societe->lire;
+$genallowed = $user->hasRight('societe', 'lire');
$delallowed = $user->rights->societe->creer;
print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang);
diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php
index 98979c917d4..369ef413fc1 100644
--- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php
+++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php
@@ -190,7 +190,7 @@ if ($this->control->tpl['action_delete']) {
control->tpl['id'].'&action=edit&token='.newToken().'&canvas='.urlencode($canvas); ?>">trans("Modify"); ?>
-rights->societe->supprimer) { ?>
+hasRight('societe', 'supprimer')) { ?>
use_javascript_ajax) { ?>
trans('Delete'); ?>
@@ -209,7 +209,7 @@ if ($this->control->tpl['action_delete']) {
*/
$filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid;
$urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid;
-$genallowed = $user->rights->societe->lire;
+$genallowed = $user->hasRight('societe', 'lire');
$delallowed = $user->rights->societe->creer;
print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang);
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index bdc48872c03..4b612df0c00 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -137,9 +137,9 @@ if (!empty($canvas)) {
}
// Permissions
-$permissiontoread = $user->rights->societe->lire;
+$permissiontoread = $user->hasRight('societe', 'lire');
$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0);
+$permissiontodelete = $user->hasRight('societe', 'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0);
$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
@@ -914,7 +914,7 @@ if (empty($reshook)) {
}
// Delete third party
- if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) {
+ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'supprimer')) {
$object->fetch($socid);
$object->oldcopy = clone $object;
$result = $object->delete($socid, $user);
@@ -3247,7 +3247,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete);
- if ($user->rights->societe->supprimer) {
+ if ($user->hasRight('societe', 'supprimer')) {
$deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken();
$buttonId = 'action-delete-no-ajax';
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile
@@ -3277,7 +3277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
*/
$filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id;
$urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id;
- $genallowed = $user->rights->societe->lire;
+ $genallowed = $user->hasRight('societe', 'lire');
$delallowed = $user->rights->societe->creer;
print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index f197a1b7024..7fe72779c6c 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -132,7 +132,7 @@ class Thirdparties extends DolibarrApi
{
$obj_ret = array();
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -527,7 +527,7 @@ class Thirdparties extends DolibarrApi
*/
public function delete($id)
{
- if (!DolibarrApiAccess::$user->rights->societe->supprimer) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'supprimer')) {
throw new RestException(401);
}
$result = $this->company->fetch($id);
@@ -848,7 +848,7 @@ class Thirdparties extends DolibarrApi
*/
public function getOutStandingProposals($id, $mode = 'customer')
{
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -890,7 +890,7 @@ class Thirdparties extends DolibarrApi
*/
public function getOutStandingOrder($id, $mode = 'customer')
{
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -931,7 +931,7 @@ class Thirdparties extends DolibarrApi
*/
public function getOutStandingInvoices($id, $mode = 'customer')
{
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -972,7 +972,7 @@ class Thirdparties extends DolibarrApi
*/
public function getSalesRepresentatives($id, $mode = 0)
{
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -1015,7 +1015,7 @@ class Thirdparties extends DolibarrApi
{
$obj_ret = array();
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -1439,7 +1439,7 @@ class Thirdparties extends DolibarrApi
*/
public function getSocieteAccounts($id, $site = null)
{
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401);
}
@@ -1870,7 +1870,7 @@ class Thirdparties extends DolibarrApi
{
global $conf;
- if (!DolibarrApiAccess::$user->rights->societe->lire) {
+ if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login.'. No read permission on thirdparties.');
}
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 1d0bdfe39a1..e161cd8668c 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -124,10 +124,10 @@ $result = $db->query($sql);
if ($result) {
while ($objp = $db->fetch_object($result)) {
$found = 0;
- if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) {
$found = 1; $third['prospect']++;
}
- if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) {
$found = 1; $third['customer']++;
}
if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) {
@@ -150,10 +150,10 @@ $thirdpartygraph .= '
| '.$langs->trans("St
if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) {
$thirdpartygraph .= ' |
|---|
| ';
$dataseries = array();
- if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
$dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
}
- if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
$dataseries[] = array($langs->trans("Customers"), round($third['customer']));
}
if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
@@ -173,12 +173,12 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
$thirdpartygraph .= $dolgraph->show();
$thirdpartygraph .= ' |
'."\n";
} else {
- if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
$statstring = "
";
$statstring .= '| '.$langs->trans("Prospects").' | '.round($third['prospect']).' | ';
$statstring .= "
";
}
- if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
+ if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
$statstring .= "
";
$statstring .= '| '.$langs->trans("Customers").' | '.round($third['customer']).' | ';
$statstring .= "
";
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index ff6de888284..680ab8aff82 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -383,8 +383,8 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'Societe';
$objectlabel = 'ThirdParty';
- $permissiontoread = $user->rights->societe->lire;
- $permissiontodelete = $user->rights->societe->supprimer;
+ $permissiontoread = $user->hasRight('societe', 'lire');
+ $permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@@ -898,7 +898,7 @@ if ($user->rights->societe->creer) {
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
$arrayofmassactions = array();
}
-if ($user->rights->societe->supprimer) {
+if ($user->hasRight('societe', 'supprimer')) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php
index 30b19e59d8b..fe5654a0d06 100644
--- a/htdocs/societe/paymentmodes.php
+++ b/htdocs/societe/paymentmodes.php
@@ -79,7 +79,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('thirdpartybancard', 'globalcard'));
// Permissions
-$permissiontoread = $user->rights->societe->lire;
+$permissiontoread = $user->hasRight('societe', 'lire');
$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php
$permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write)));
diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php
index 8de63dfeffc..9ca58ab0bf4 100644
--- a/htdocs/societe/website.php
+++ b/htdocs/societe/website.php
@@ -161,8 +161,8 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'WebsiteAccount';
$objectlabel = 'WebsiteAccount';
- $permissiontoread = $user->rights->societe->lire;
- $permissiontodelete = $user->rights->societe->supprimer;
+ $permissiontoread = $user->hasRight('societe', 'lire');
+ $permissiontodelete = $user->hasRight('societe', 'supprimer');
$uploaddir = $conf->societe->multidir_output[$object->entity];
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -250,7 +250,7 @@ print dol_get_fiche_end();
$newcardbutton = '';
if (isModEnabled('website')) {
- if (!empty($user->rights->societe->lire)) {
+ if ($user->hasRight('societe', 'lire')) {
$newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id));
} else {
$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0);
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index 80656681015..0551532b00f 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -491,7 +491,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
-if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) {
+if ($socid && !$projectid && !$project_ref && $user->hasRight('societe', 'lire')) {
$socstat = new Societe($db);
$res = $socstat->fetch($socid);
if ($res > 0) {