diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index f3b6dfcf5fb..2314007b8c9 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1158,7 +1158,7 @@ if ($mode == 'marketplace') { - global->API_RESTRICT_ON_IP)) { $allowedip = explode(' ', $conf->global->API_RESTRICT_ON_IP); $ipremote = getUserRemoteIP(); if (!in_array($ipremote, $allowedip)) { - dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); + dol_syslog('Remote ip is '.$ipremote.', not into list ' . getDolGlobalString('API_RESTRICT_ON_IP')); print 'APIs are not allowed from the IP '.$ipremote; header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); //session_destroy(); diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index e69de5f62fc..42b87a56caa 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -144,7 +144,7 @@ class Login // Renew the hash if (empty($tmpuser->api_key) || $reset) { $tmpuser->getrights(); - if (empty($tmpuser->rights->user->self->creer)) { + if (!$tmpuser->hasRight('user', 'self', 'creer')) { if (empty($tmpuser->api_key)) { throw new RestException(403, 'No API token set for this user and user need write permission on itself to reset its API token'); } else { diff --git a/htdocs/api/index.php b/htdocs/api/index.php index ebf6c7e8091..008af056681 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -201,7 +201,7 @@ if (!empty($conf->global->API_RESTRICT_ON_IP)) { $allowedip = explode(' ', $conf->global->API_RESTRICT_ON_IP); $ipremote = getUserRemoteIP(); if (!in_array($ipremote, $allowedip)) { - dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); + dol_syslog('Remote ip is '.$ipremote.', not into list ' . getDolGlobalString('API_RESTRICT_ON_IP')); print 'APIs are not allowed from the IP '.$ipremote; header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); //session_destroy(); diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 7f6c95e8d36..0fe877ae139 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -1525,7 +1525,7 @@ class Asset extends CommonObject if (!empty($conf->global->ASSET_ASSET_ADDON)) { $mybool = false; - $file = $conf->global->ASSET_ASSET_ADDON.".php"; + $file = getDolGlobalString('ASSET_ASSET_ADDON') . ".php"; $classname = $conf->global->ASSET_ASSET_ADDON; // Include file with class diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index 11d94714db8..2e5c85d4d5d 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -55,7 +55,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo '
| '.$form->textwithpicto($langs->trans("AccountStatement"), $langs->trans("InputReceiptNumber"))." | "; - if ($user->rights->banque->consolidate) { + if ($user->hasRight('banque', 'consolidate')) { print ''; if ($objp->rappro) { print 'rappro ? ' disabled' : '').'>'; @@ -687,7 +687,7 @@ if ($result) { print ' | |||||||||||||||||||||||||||||||||||||
| '; - if ($user->rights->banque->consolidate) { + if ($user->hasRight('banque', 'consolidate')) { print ' | '; print 'rappro ? ' checked="checked"' : '')).'">'; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index d50d9fea98e..44b317a97e2 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -348,7 +348,7 @@ $arrayofmassactions = array( if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (isModEnabled('category') && $user->rights->banque->modifier) { +if (isModEnabled('category') && $user->hasRight('banque', 'modifier')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { @@ -375,7 +375,7 @@ print ''; $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->hasRight('banque', 'configurer')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index dc451f6a438..43c72e4a8f5 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -403,7 +403,7 @@ if (empty($numref)) { print ' | '.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, empty($object->currency_code)?$conf->currency:$object->currency_code).' | '; print ''; - if ($user->rights->banque->consolidate && $action != 'editbankreceipt') { + if ($user->hasRight('banque', 'consolidate') && $action != 'editbankreceipt') { print 'id.($page > 0 ? '&page='.$page : '').'&action=editbankreceipt&token='.newToken().'&brref='.urlencode($objp->numr).'">'.img_edit().''; } print ' | '; @@ -682,7 +682,7 @@ if (empty($numref)) { print ''.price(price2num($total, 'MT'))." | \n"; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { + if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) { print 'id.'&num='.$numref).'">'; print img_edit(); print " | "; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 9989dfed000..7ef137de862 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -45,7 +45,7 @@ $socid = 0; if ($user->socid > 0) { $socid = $user->socid; } -if (!$user->rights->banque->transfer) { +if (!$user->hasRight('banque', 'transfer')) { accessforbidden(); } @@ -63,7 +63,7 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } -if ($action == 'add' && !empty($user->rights->banque->transfer)) { +if ($action == 'add' && $user->hasRight('banque', 'transfer')) { $langs->load('errors'); $i = 1; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index d166a3c2e82..b6f75227cf9 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -639,10 +639,10 @@ if ($id) { $editvalue = ''; if (isModEnabled('accounting')) { print '|||||||||||||||||||||||||||||||||
| '; - print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); + print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); print ' | ';
if ($action == 'editaccountancy_code') {
- print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
+ print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0);
} else {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $object->accountancy_code, 1);
diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php
index 58e4d3680b9..752932e5a80 100644
--- a/htdocs/compta/bank/various_payment/document.php
+++ b/htdocs/compta/bank/various_payment/document.php
@@ -100,7 +100,7 @@ if ($object->id) {
// Project
if (isModEnabled('project')) {
$langs->load("projects");
- if ($user->rights->banque->modifier && 0) {
+ if ($user->hasRight('banque', 'modifier') && 0) {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
}
diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php
index 06f243a9847..e244db093ac 100644
--- a/htdocs/compta/bank/various_payment/info.php
+++ b/htdocs/compta/bank/various_payment/info.php
@@ -60,7 +60,7 @@ $morehtmlref = ' ';
// Project
if (isModEnabled('project')) {
$langs->load("projects");
- if ($user->rights->banque->modifier && 0) {
+ if ($user->hasRight('banque', 'modifier') && 0) {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
}
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index f248414b30e..d6360fda876 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -446,7 +446,7 @@ $newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitleSeparator();
-$newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier);
+$newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('banque', 'modifier'));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php
index 80d8b3d58e1..7bc7d80aa26 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_list.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_list.php
@@ -131,7 +131,7 @@ if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
-if (empty($user->rights->cashdesk->run) && empty($user->rights->takepos->run)) {
+if (!$user->hasRight('cashdesk', 'run') && !$user->hasRight('takepos', 'run')) {
accessforbidden();
}
diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php
index c3d625c01e4..e702e05ea2c 100644
--- a/htdocs/compta/cashcontrol/report.php
+++ b/htdocs/compta/cashcontrol/report.php
@@ -80,7 +80,7 @@ if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
-if (empty($user->rights->cashdesk->run) && empty($user->rights->takepos->run)) {
+if (!$user->hasRight('cashdesk', 'run') && !$user->hasRight('takepos', 'run')) {
accessforbidden();
}
diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index e8f3d3fea06..9a2e887a354 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -134,7 +134,7 @@ if ($year) {
print ''.$langs->trans("DescTaxAndDividendsArea").' '; print " "; -if (isModEnabled('tax') && $user->rights->tax->charges->lire) { +if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { // Social contributions only print load_fiche_titre($langs->trans("SocialContributions").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); @@ -267,7 +267,7 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { } // VAT -if (isModEnabled('tax') && $user->rights->tax->charges->lire) { +if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { print " "; $tva = new Tva($db); diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index c5fe5ae9868..c747ad745cf 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -95,16 +95,16 @@ if ($mode == 'search') { $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea"; $sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta "; -if (empty($user->rights->societe->client->voir) && !$socid) { +if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st"; -if (empty($user->rights->societe->client->voir) && !$socid) { +if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)"; $sql .= " AND s.entity IN (".getEntity('societe').")"; -if (empty($user->rights->societe->client->voir) && !$socid) { +if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if (dol_strlen($stcomm)) { diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index e7929a12697..a07b5831240 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -62,7 +62,7 @@ $permissionnote = $user->rights->deplacement->creer; // Used by the include of a include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -if ($action == 'validate' && $user->rights->deplacement->creer) { +if ($action == 'validate' && $user->hasRight('deplacement', 'creer')) { $object->fetch($id); if ($object->statut == Deplacement::STATUS_DRAFT) { $result = $object->setStatut(1); @@ -73,7 +73,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { setEventMessages($object->error, $object->errors, 'errors'); } } -} elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) { +} elseif ($action == 'classifyrefunded' && $user->hasRight('deplacement', 'creer')) { $object->fetch($id); if ($object->statut == Deplacement::STATUS_VALIDATED) { $result = $object->setStatut(Deplacement::STATUS_REFUNDED); @@ -84,7 +84,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { setEventMessages($object->error, $object->errors, 'errors'); } } -} elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) { +} elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->hasRight('deplacement', 'supprimer')) { $result = $object->delete($user); if ($result >= 0) { header("Location: index.php"); @@ -92,7 +92,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { } else { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == 'add' && $user->rights->deplacement->creer) { +} elseif ($action == 'add' && $user->hasRight('deplacement', 'creer')) { if (!GETPOST('cancel', 'alpha')) { $error = 0; @@ -135,7 +135,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { header("Location: index.php"); exit; } -} elseif ($action == 'update' && $user->rights->deplacement->creer) { +} elseif ($action == 'update' && $user->hasRight('deplacement', 'creer')) { // Update record if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); @@ -160,14 +160,14 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } -} elseif ($action == 'classin' && $user->rights->deplacement->creer) { +} elseif ($action == 'classin' && $user->hasRight('deplacement', 'creer')) { // Set into a project $object->fetch($id); $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) { dol_print_error($db, $object->error); } -} elseif ($action == 'setdated' && $user->rights->deplacement->creer) { +} elseif ($action == 'setdated' && $user->hasRight('deplacement', 'creer')) { // Set fields $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); $object->fetch($id); @@ -175,7 +175,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { if ($result < 0) { dol_print_error($db, $object->error); } -} elseif ($action == 'setkm' && $user->rights->deplacement->creer) { +} elseif ($action == 'setkm' && $user->hasRight('deplacement', 'creer')) { $object->fetch($id); $result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) { @@ -276,7 +276,7 @@ if ($action == 'create') { print dol_get_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); - if ($action == 'edit' && $user->rights->deplacement->creer) { + if ($action == 'edit' && $user->hasRight('deplacement', 'creer')) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -388,9 +388,9 @@ if ($action == 'create') { // Type print ' ';
- print $form->editfieldkey("Type", 'type', $langs->trans($object->type), $object, $user->rights->deplacement->creer, 'select:types_fees');
+ print $form->editfieldkey("Type", 'type', $langs->trans($object->type), $object, $user->hasRight('deplacement', 'creer'), 'select:types_fees');
print ' | ';
- print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->rights->deplacement->creer, 'select:types_fees');
+ print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->hasRight('deplacement', 'creer'), 'select:types_fees');
print ' | ';
- print $form->editfieldkey("Date", 'dated', $object->date, $object, $user->rights->deplacement->creer, 'datepicker');
+ print $form->editfieldkey("Date", 'dated', $object->date, $object, $user->hasRight('deplacement', 'creer'), 'datepicker');
print ' | ';
- print $form->editfieldval("Date", 'dated', $object->date, $object, $user->rights->deplacement->creer, 'datepicker');
+ print $form->editfieldval("Date", 'dated', $object->date, $object, $user->hasRight('deplacement', 'creer'), 'datepicker');
print ' | ';
- print $form->editfieldkey("FeesKilometersOrAmout", 'km', $object->km, $object, $user->rights->deplacement->creer, 'numeric:6');
+ print $form->editfieldkey("FeesKilometersOrAmout", 'km', $object->km, $object, $user->hasRight('deplacement', 'creer'), 'numeric:6');
print ' | ';
- print $form->editfieldval("FeesKilometersOrAmout", 'km', $object->km, $object, $user->rights->deplacement->creer, 'numeric:6');
+ print $form->editfieldval("FeesKilometersOrAmout", 'km', $object->km, $object, $user->hasRight('deplacement', 'creer'), 'numeric:6');
print " |
';
// Label of social contribution
- $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
+ $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->hasRight('tax', 'charges', 'creer'), 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->hasRight('tax', 'charges', 'creer'), 'string', '', null, null, '', 1);
$morehtmlref .= ' ';
$linkback = ''.$langs->trans("BackToList").'';
diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php
index ea9ea7b5a37..c850d05e036 100644
--- a/htdocs/compta/tva/info.php
+++ b/htdocs/compta/tva/info.php
@@ -47,7 +47,7 @@ $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
* Actions
*/
-if ($action == 'setlib' && $user->rights->tax->charges->creer) {
+if ($action == 'setlib' && $user->hasRight('tax', 'charges', 'creer')) {
$object->fetch($id);
$result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY');
if ($result < 0) {
@@ -74,8 +74,8 @@ print dol_get_fiche_head($head, 'info', $langs->trans("VATPayment"), -1, 'paymen
$morehtmlref = '';
// Label of social contribution
-$morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
-$morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
+$morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->hasRight('tax', 'charges', 'creer'), 'string', '', 0, 1);
+$morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->hasRight('tax', 'charges', 'creer'), 'string', '', null, null, '', 1);
$morehtmlref .= ' ';
$linkback = ''.$langs->trans("BackToList").'';
diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php
index 2419e74c5c9..72b679464b3 100644
--- a/htdocs/contact/agenda.php
+++ b/htdocs/contact/agenda.php
@@ -176,7 +176,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// Confirm deleting contact
- if ($user->rights->societe->contact->supprimer) {
+ if ($user->hasRight('societe', 'contact', 'supprimer')) {
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
index 127375b8c92..1a66208288f 100644
--- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
+++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
@@ -138,7 +138,7 @@ if (!empty($this->control->tpl['action_delete'])) {
if (empty($user->socid)) {
print '';
- if ($user->rights->societe->contact->creer) {
+ if ($user->hasRight('societe', 'contact', 'creer')) {
print 'control->tpl['id'].'&action=edit&token='.newToken().'&canvas='.$canvas.'">'.$langs->trans('Modify').'';
}
@@ -146,7 +146,7 @@ if (empty($user->socid)) {
print 'control->tpl['id'].'&action=create_user&token='.newToken().'&canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'';
}
- if ($user->rights->societe->contact->supprimer) {
+ if ($user->hasRight('societe', 'contact', 'supprimer')) {
print 'control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas.'">'.$langs->trans('Delete').'';
}
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index f405ce799b5..264e73e3601 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -520,7 +520,7 @@ if (empty($reshook)) {
}
// Update extrafields
- if ($action == 'update_extras' && !empty($user->rights->societe->contact->creer)) {
+ if ($action == 'update_extras' && $user->hasRight('societe', 'contact', 'creer')) {
$object->oldcopy = dol_clone($object, 2);
// Fill array 'array_options' with data from update form
@@ -593,7 +593,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// Confirm deleting contact
- if ($user->rights->societe->contact->supprimer) {
+ if ($user->hasRight('societe', 'contact', 'supprimer')) {
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
@@ -617,7 +617,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$head = contact_prepare_head($object);
}
- if ($user->rights->societe->contact->creer) {
+ if ($user->hasRight('societe', 'contact', 'creer')) {
if ($action == 'create') {
/*
* Fiche en mode creation
@@ -1529,7 +1529,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
}
- if ($user->rights->societe->contact->creer) {
+ if ($user->hasRight('societe', 'contact', 'creer')) {
print ''.$langs->trans('Modify').'';
}
@@ -1543,8 +1543,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
// Delete
- if ($user->rights->societe->contact->supprimer) {
- print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().($backtopage ? '&backtopage='.urlencode($backtopage) : ''), 'delete', $user->rights->societe->contact->supprimer);
+ if ($user->hasRight('societe', 'contact', 'supprimer')) {
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().($backtopage ? '&backtopage='.urlencode($backtopage) : ''), 'delete', $user->hasRight('societe', 'contact', 'supprimer'));
}
}
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index cc4bf2d267b..f1a931e657f 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -416,7 +416,7 @@ class Contact extends CommonObject
$sql = "SELECT count(sp.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
- if (empty($user->rights->societe->client->voir) && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
@@ -754,11 +754,11 @@ class Contact extends CommonObject
global $conf;
$dn = '';
if ($mode == 0) {
- $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
+ $dn = getDolGlobalString('LDAP_KEY_CONTACTS') . "=".$info[getDolGlobalString('LDAP_KEY_CONTACTS')]."," . getDolGlobalString('LDAP_CONTACT_DN');
} elseif ($mode == 1) {
$dn = $conf->global->LDAP_CONTACT_DN;
} elseif ($mode == 2) {
- $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS];
+ $dn = getDolGlobalString('LDAP_KEY_CONTACTS') . "=".$info[getDolGlobalString('LDAP_KEY_CONTACTS')];
}
return $dn;
}
@@ -785,13 +785,13 @@ class Contact extends CommonObject
// Fields
if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_FULLNAME')] = $this->fullname;
}
if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_NAME')] = $this->lastname;
}
if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_FIRSTNAME')] = $this->firstname;
}
if ($this->poste) {
@@ -801,7 +801,7 @@ class Contact extends CommonObject
$soc = new Societe($this->db);
$soc->fetch($this->socid);
- $info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_COMPANY')] = $soc->name;
if ($soc->client == 1) {
$info["businessCategory"] = "Customers";
}
@@ -813,34 +813,34 @@ class Contact extends CommonObject
}
}
if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_ADDRESS')] = $this->address;
}
if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_ZIP')] = $this->zip;
}
if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_TOWN')] = $this->town;
}
if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_COUNTRY')] = $this->country_code;
}
if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_PHONE')] = $this->phone_pro;
}
if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_HOMEPHONE')] = $this->phone_perso;
}
if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_MOBILE')] = $this->phone_mobile;
}
if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_FAX')] = $this->fax;
}
if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_DESCRIPTION')] = dol_string_nohtmltag($this->note_private, 2);
}
if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) {
- $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
+ $info[getDolGlobalString('LDAP_CONTACT_FIELD_MAIL')] = $this->email;
}
if (getDolGlobalString('LDAP_SERVER_TYPE') == 'egroupware') {
diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php
index 7b2374830b3..3b8d0ea0724 100644
--- a/htdocs/contact/consumption.php
+++ b/htdocs/contact/consumption.php
@@ -175,10 +175,10 @@ if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire')) {
if ($object->thirdparty->fournisseur) {
$thirdTypeArray['supplier'] = $langs->trans("supplier");
- if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
$elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
}
- if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire'))) {
$elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
}
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 0d66cc546d7..aa080b8ee5f 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -494,7 +494,7 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
}
@@ -503,7 +503,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
-if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { //restriction
$sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)";
}
if (!empty($userid)) { // propre au commercial
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index c24cd37ba18..70d7adff0e5 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -332,7 +332,7 @@ if ($action != 'edit') {
if ($user->socid == 0) {
print ' ';
- if ($user->rights->societe->contact->creer) {
+ if ($user->hasRight('societe', 'contact', 'creer')) {
print ''.$langs->trans('Modify').'';
}
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index fb7477a16b4..215b1dafe4a 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -405,7 +405,7 @@ if (!$error && $massaction == 'confirm_presend') {
if ($fromtype === 'user') {
$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
} elseif ($fromtype === 'company') {
- $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+ $from = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
} elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
$tmp = explode(',', $user->email_aliases);
$from = trim($tmp[($reg[1] - 1)]);
@@ -429,25 +429,25 @@ if (!$error && $massaction == 'confirm_presend') {
$sendtobcc = GETPOST('sendtoccc');
if ($objectclass == 'Propal') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROPOSAL_TO')));
}
if ($objectclass == 'Commande') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_ORDER_TO')));
}
if ($objectclass == 'Facture') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_INVOICE_TO')));
}
if ($objectclass == 'Supplier_Proposal') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
}
if ($objectclass == 'CommandeFournisseur') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO')));
}
if ($objectclass == 'FactureFournisseur') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO')));
}
if ($objectclass == 'Project') {
- $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
+ $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString('MAIN_MAIL_AUTOCOPY_PROJECT_TO')));
}
// $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
@@ -1739,8 +1739,8 @@ if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $conf
$defaultref = '';
$obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
- if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) {
- require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php';
+ if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . ".php")) {
+ require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . '.php';
$modTask = new $obj;
$defaultref = $modTask->getNextValue(0, $clone_task);
}
diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php
index 3d82fa9a136..496e23c99b3 100644
--- a/htdocs/core/actions_printing.inc.php
+++ b/htdocs/core/actions_printing.inc.php
@@ -28,7 +28,7 @@
// Filename to print must be provided into 'file' parameter
// Print file
-if ($action == 'print_file' && $user->rights->printing->read) {
+if ($action == 'print_file' && $user->hasRight('printing', 'read')) {
$langs->load("printing");
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
$objectprint = new PrintingDriver($db);
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 776c6d7d581..2d1299e502b 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -277,11 +277,11 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
$reg = array();
$fromtype = GETPOST('fromtype', 'alpha');
if ($fromtype === 'robot') {
- $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
+ $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM').'>';
} elseif ($fromtype === 'user') {
$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
} elseif ($fromtype === 'company') {
- $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+ $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
} elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
$tmp = explode(',', $user->email_aliases);
$from = trim($tmp[($reg[1] - 1)]);
@@ -322,7 +322,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
// Autocomplete the $sendtobcc
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
if (!empty($autocopy)) {
- $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
+ $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "") . getDolGlobalString($autocopy)));
}
$deliveryreceipt = GETPOST('deliveryreceipt');
diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php
index 166daafadd1..8b5db78cdd8 100644
--- a/htdocs/core/bookmarks_page.php
+++ b/htdocs/core/bookmarks_page.php
@@ -114,7 +114,7 @@ if (empty($conf->bookmark->enabled)) {
}
$newcardbutton = '';
- $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create&backtopage='.urlencode(DOL_URL_ROOT.'/bookmarks/list.php'), '', !empty($user->rights->bookmark->creer));
+ $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create&backtopage='.urlencode(DOL_URL_ROOT.'/bookmarks/list.php'), '', $user->hasRight('bookmark', 'creer'));
// Url to list bookmark
$bookmarkList .= ' ';
}
- if (isModEnabled('projet') && !empty($user->rights->projet->lire)) {
+ if (isModEnabled('projet') && $user->hasRight('projet', 'lire')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
$formproject = new FormProjets($db);
@@ -162,12 +162,12 @@ function show_array_actions_to_do($max = 5)
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN ";
$sql .= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
$sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
@@ -278,12 +278,12 @@ function show_array_last_actions_done($max = 5)
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN ";
$sql .= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
$sql .= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 31523e331e8..3d8439dcf07 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -131,14 +131,14 @@ function societe_prepare_head(Societe $object)
if (isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$supplier_module_enabled = 1;
}
- if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
+ if ($supplier_module_enabled == 1 && $object->fournisseur && $user->hasRight('fournisseur', 'lire')) {
$head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Supplier");
$head[$h][2] = 'supplier';
$h++;
}
- if (isModEnabled('project') && (!empty($user->rights->projet->lire))) {
+ if (isModEnabled('project') && ($user->hasRight('projet', 'lire'))) {
$nbProject = 0;
// Enable caching of thirdrparty count projects
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
@@ -279,7 +279,7 @@ function societe_prepare_head(Societe $object)
}
if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') {
- if (!empty($user->rights->partnership->read)) {
+ if ($user->hasRight('partnership', 'read')) {
$langs->load("partnership");
$nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
$head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?socid='.$object->id;
@@ -885,7 +885,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
// To verify role of users
$userAccess = $projecttmp->restrictedProjectArea($user);
- if ($user->rights->projet->lire && $userAccess > 0) {
+ if ($user->hasRight('projet', 'lire') && $userAccess > 0) {
print ''; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 81ed0b25731..0cfc5eed6d3 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -985,19 +985,19 @@ class CMailFile $res = true; $from = $this->smtps->getFrom('org'); if ($res && !$from) { - $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - Sender address '$from' invalid"; + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport)." - Sender address '$from' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res = false; } $dest = $this->smtps->getTo(); if ($res && !$dest) { - $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - Recipient address '$dest' invalid"; + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport)." - Recipient address '$dest' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res = false; } if ($res) { - dol_syslog("CMailFile::sendfile: sendMsg, HOST=".$server.", PORT=".$conf->global->$keyforsmtpport, LOG_DEBUG); + dol_syslog("CMailFile::sendfile: sendMsg, HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport), LOG_DEBUG); if (!empty($conf->global->MAIN_MAIL_DEBUG)) { $this->smtps->setDebug(true); @@ -1037,7 +1037,7 @@ class CMailFile if (empty($this->error)) { $this->error = $result; } - dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - ".$this->error, LOG_ERR); + dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport)." - ".$this->error, LOG_ERR); $res = false; if (!empty($conf->global->MAIN_MAIL_DEBUG)) { @@ -1161,7 +1161,7 @@ class CMailFile $this->mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this->logger)); } - dol_syslog("CMailFile::sendfile: mailer->send, HOST=".$server.", PORT=".$conf->global->$keyforsmtpport, LOG_DEBUG); + dol_syslog("CMailFile::sendfile: mailer->send, HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport), LOG_DEBUG); // send mail $failedRecipients = array(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8a6b5c9907a..c8c1234c673 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2139,12 +2139,12 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); $sql .= ", ".$this->db->prefix().$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".$this->db->prefix()."societe as s"; // If we need to link to societe to limit select to socid - } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { + } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid } - if ($restrictiononfksoc && empty($user->rights->societe->client->voir) && !$socid) { + if ($restrictiononfksoc && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " LEFT JOIN ".$this->db->prefix()."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; } if ($fieldid == 'rowid') { @@ -2152,10 +2152,10 @@ abstract class CommonObject } else { $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) } - if ($restrictiononfksoc == 1 && empty($user->rights->societe->client->voir) && !$socid) { + if ($restrictiononfksoc == 1 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND sc.fk_user = ".((int) $user->id); } - if ($restrictiononfksoc == 2 && empty($user->rights->societe->client->voir) && !$socid) { + if ($restrictiononfksoc == 2 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND (sc.fk_user = ".((int) $user->id).' OR te.fk_soc IS NULL)'; } if (!empty($filter)) { @@ -2167,7 +2167,7 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); $sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { @@ -2209,12 +2209,12 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); $sql .= ", ".$this->db->prefix().$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".$this->db->prefix()."societe as s"; // If we need to link to societe to limit select to socid - } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { + } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid } - if ($restrictiononfksoc && empty($user->rights->societe->client->voir) && !$socid) { + if ($restrictiononfksoc && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " LEFT JOIN ".$this->db->prefix()."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; } if ($fieldid == 'rowid') { @@ -2222,10 +2222,10 @@ abstract class CommonObject } else { $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) } - if ($restrictiononfksoc == 1 && empty($user->rights->societe->client->voir) && !$socid) { + if ($restrictiononfksoc == 1 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND sc.fk_user = ".((int) $user->id); } - if ($restrictiononfksoc == 2 && empty($user->rights->societe->client->voir) && !$socid) { + if ($restrictiononfksoc == 2 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND (sc.fk_user = ".((int) $user->id).' OR te.fk_soc IS NULL)'; } if (!empty($filter)) { @@ -2237,7 +2237,7 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); $sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity - } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && empty($user->rights->societe->client->voir) && !$socid) { + } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { @@ -8674,10 +8674,10 @@ abstract class CommonObject if ($element == 'facturerec') { $element = 'facture'; } elseif ($element == 'invoice_supplier_rec') { - return empty($user->rights->fournisseur->facture) ? null : $user->rights->fournisseur->facture; - } elseif ($module && !empty($user->rights->$module->$element)) { + return !$user->hasRight('fournisseur', 'facture') ? null : $user->hasRight('fournisseur', 'facture'); + } elseif ($module && $user->hasRight($module, $element)) { // for modules built with ModuleBuilder - return $user->rights->$module->$element; + return $user->hasRight($module, $element); } return $user->rights->$element; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1893ff44c04..c2e014ccc02 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1446,7 +1446,7 @@ class Form if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays"; } - if (empty($user->rights->societe->client->voir) && !$user->socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) { $sql .= ", " . $this->db->prefix() . "societe_commerciaux as sc"; } $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")"; @@ -1458,7 +1458,7 @@ class Form // if not, by testSqlAndScriptInject() only. $sql .= " AND (" . $filter . ")"; } - if (empty($user->rights->societe->client->voir) && !$user->socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); } if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) { @@ -3162,7 +3162,7 @@ class Form $opt .= ' pbq="' . $objp->price_by_qty_rowid . '" data-pbq="' . $objp->price_by_qty_rowid . '" data-pbqup="' . $objp->price_by_qty_unitprice . '" data-pbqbase="' . $objp->price_by_qty_price_base_type . '" data-pbqqty="' . $objp->price_by_qty_quantity . '" data-pbqpercent="' . $objp->price_by_qty_remise_percent . '"'; } if (isModEnabled('stock') && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - if (!empty($user->rights->stock->lire)) { + if ($user->hasRight('stock', 'lire')) { if ($objp->stock > 0) { $opt .= ' class="product_line_stock_ok"'; } elseif ($objp->stock <= 0) { @@ -3319,7 +3319,7 @@ class Form } if (isModEnabled('stock') && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - if (!empty($user->rights->stock->lire)) { + if ($user->hasRight('stock', 'lire')) { $opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS')); if ($objp->stock > 0) { @@ -3745,7 +3745,7 @@ class Form if (isModEnabled('stock') && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { $novirtualstock = ($showstockinlist == 2); - if (!empty($user->rights->stock->lire)) { + if ($user->hasRight('stock', 'lire')) { $outvallabel .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS')); if ($objp->stock > 0) { @@ -8159,7 +8159,7 @@ class Form $sql .= " INNER JOIN " . $this->db->prefix() . $tmparray[1] . " as parenttable ON parenttable.rowid = t." . $tmparray[0]; } if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') { - if (empty($user->rights->societe->client->voir) && !$user->socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) { $sql .= ", " . $this->db->prefix() . "societe_commerciaux as sc"; } } @@ -8193,7 +8193,7 @@ class Form } } if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') { - if (empty($user->rights->societe->client->voir) && !$user->socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) { $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); } } @@ -10338,7 +10338,7 @@ class Form } if (empty($projectsListId)) { - if (empty($usertofilter->rights->projet->all->lire)) { + if (!$usertofilter->hasRight('projet', 'all', 'lire')) { $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1); } @@ -10386,7 +10386,7 @@ class Form 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($usertofilter->rights->societe->lire)) { + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight('societe', 'lire')) { // Do nothing } else { if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) { diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 15a0d4b6d42..272b1a1713a 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -68,7 +68,7 @@ class FormAdmin global $conf, $langs; if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) { - $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; + $filter[getDolGlobalString('MAIN_DEFAULT_LANGUAGE_FILTER')] = 1; } $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1b3f335e8b4..fa305b18a9c 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1259,7 +1259,7 @@ class FormFile if ($user->hasRight('produit', 'creer') && $object->type == Product::TYPE_PRODUCT) { $permtoeditline = 1; } - if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) { + if ($user->hasRight('service', 'creer') && $object->type == Product::TYPE_SERVICE) { $permtoeditline = 1; } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b32eafcd79c..443f85c3fd7 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -613,7 +613,7 @@ class FormMail extends Form // Add also company main email if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL)) { - $s = (empty($conf->global->MAIN_INFO_SOCIETE_NOM)?$conf->global->MAIN_INFO_SOCIETE_EMAIL:$conf->global->MAIN_INFO_SOCIETE_NOM).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $s = (empty($conf->global->MAIN_INFO_SOCIETE_NOM)?$conf->global->MAIN_INFO_SOCIETE_EMAIL:$conf->global->MAIN_INFO_SOCIETE_NOM).' <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; $liste['company'] = array('label' => $s, 'data-html' => $s); } @@ -633,7 +633,7 @@ class FormMail extends Form if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && getDolGlobalString('MAIN_MAIL_EMAIL_FROM') != getDolGlobalString('MAIN_INFO_SOCIETE_MAIL')) { $s = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($this->frommail) { - $s .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; + $s .= ' <' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM').'>'; } array('label' => $s, 'data-html' => $s); } diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 134c7c0a7ec..0280d95fc0b 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -214,7 +214,7 @@ class FormMargin return; } - if (empty($user->rights->margins->liretous)) { + if (!$user->hasRight('margins', 'liretous')) { return; } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index a713cc880f7..9df44a1a6fc 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -515,7 +515,7 @@ class FormOther $sql_usr .= " WHERE u.entity IN (".getEntity('user').")"; } - if (empty($user->rights->user->user->lire)) { + if (!$user->hasRight('user', 'user', 'lire')) { $sql_usr .= " AND u.rowid = ".((int) $user->id); } if (!empty($user->socid)) { @@ -528,7 +528,7 @@ class FormOther } // Add existing sales representatives of thirdparty of external user - if (empty($user->rights->user->user->lire) && $user->socid) { + if (!$user->hasRight('user', 'user', 'lire') && $user->socid) { $sql_usr .= " UNION "; $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin"; $sql_usr .= " FROM ".$this->db->prefix()."user as u2, ".$this->db->prefix()."societe_commerciaux as sc"; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 39cb3590db5..bd42b58b4ec 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -168,7 +168,7 @@ class FormProjets extends Form } $projectsListId = false; - if (empty($user->rights->projet->all->lire)) { + if (!$user->hasRight('projet', 'all', 'lire')) { $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); } @@ -187,7 +187,7 @@ class FormProjets extends Form if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { $sql .= " AND (p.fk_soc=" . ((int) $socid) . " OR p.fk_soc IS NULL)"; } elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. - $sql .= " AND (p.fk_soc IN (" . $this->db->sanitize(((int) $socid) . ", " . $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) . ") OR p.fk_soc IS NULL)"; + $sql .= " AND (p.fk_soc IN (" . $this->db->sanitize(((int) $socid) . ", " . getDolGlobalString('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) . ") OR p.fk_soc IS NULL)"; } } if (!empty($filterkey)) { @@ -352,7 +352,7 @@ class FormProjets extends Form } if (empty($projectsListId)) { - if (empty($usertofilter->rights->projet->all->lire)) { + if (!$usertofilter->hasRight('projet', 'all', 'lire')) { $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1); } @@ -409,7 +409,7 @@ class FormProjets extends Form 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($usertofilter->rights->societe->lire)) { + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight('societe', 'lire')) { // Do nothing } else { if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) { diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 5cee5607497..65e1d7c1d2f 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -92,13 +92,13 @@ class FormSetup { global $langs; $this->db = $db; + $this->form = new Form($this->db); $this->formAttributes['action'] = $_SERVER["PHP_SELF"]; $this->formHiddenInputs['token'] = newToken(); $this->formHiddenInputs['action'] = 'update'; - if ($outputLangs) { $this->langs = $outputLangs; } else { @@ -664,6 +664,7 @@ class FormSetupItem /** * load conf value from databases + * * @return bool */ public function loadValueFromConf() @@ -680,6 +681,7 @@ class FormSetupItem /** * reload conf value from databases is an aliase of loadValueFromConf + * * @deprecated * @return bool */ @@ -740,6 +742,7 @@ class FormSetupItem /** * Set an override function for get data from post + * * @param callable $callBack a callable function * @return void */ @@ -750,7 +753,8 @@ class FormSetupItem /** * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php - * @return int -1 if KO, 0 nothing to do , 1 if OK + * + * @return int -1 if KO, 0 nothing to do , 1 if OK */ public function setValueFromPost() { @@ -790,6 +794,7 @@ class FormSetupItem /** * Get help text or generate it + * * @return int|string */ public function getHelpText() @@ -800,6 +805,7 @@ class FormSetupItem /** * Get field name text or generate it + * * @return false|int|string */ public function getNameText() @@ -810,6 +816,7 @@ class FormSetupItem /** * generate input field + * * @return bool|string */ public function generateInputField() @@ -880,6 +887,7 @@ class FormSetupItem /** * generatec default input field + * * @return string */ public function generateInputFieldText() @@ -890,6 +898,7 @@ class FormSetupItem /** * generate input field for textarea + * * @return string */ public function generateInputFieldTextarea() @@ -902,6 +911,7 @@ class FormSetupItem /** * generate input field for html + * * @return string */ public function generateInputFieldHtml() @@ -918,14 +928,14 @@ class FormSetupItem */ public function generateInputFieldCategories() { - global $conf; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($this->db); $tmp = explode(':', $this->type); - $out= img_picto('', 'category', 'class="pictofixedwidth"'); - $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + $out = img_picto('', 'category', 'class="pictofixedwidth"'); + $out .= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + return $out; } @@ -935,7 +945,8 @@ class FormSetupItem */ public function generateInputFieldEmailTemplate() { - global $conf, $user; + global $user; + $out = ''; if (preg_match('/emailtemplate:/', $this->type)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; @@ -963,6 +974,7 @@ class FormSetupItem /** * generate input field for secure key + * * @return string */ public function generateInputFieldSecureKey() @@ -982,6 +994,8 @@ class FormSetupItem /** + * generateInputFieldMultiSelect + * * @return string */ public function generateInputFieldMultiSelect() @@ -996,6 +1010,8 @@ class FormSetupItem /** + * generateInputFieldSelect + * * @return string */ public function generateInputFieldSelect() @@ -1087,9 +1103,9 @@ class FormSetupItem $out.= $this->generateOutputFieldSelect(); } elseif ($this->type == 'selectUser') { $out.= $this->generateOutputFieldSelectUser(); - } elseif ($this->type== 'html') { + } elseif ($this->type == 'html') { $out.= $this->fieldValue; - } elseif ($this->type== 'color') { + } elseif ($this->type == 'color') { $out.= $this->generateOutputFieldColor(); } elseif ($this->type == 'yesno') { if (!empty($conf->use_javascript_ajax)) { diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 79c4ae3e01f..31ca1a7bb93 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1553,7 +1553,7 @@ class Ldap $keygroup = 'LDAP_KEY_GROUPS'; } - $search = '('.$conf->global->$keygroup.'=*)'; + $search = '(' . getDolGlobalString($keygroup).'=*)'; $result = $this->search($this->groups, $search); if ($result) { $c = $result['count']; diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php old mode 100755 new mode 100644 index 6958742207d..9646327be06 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -949,7 +949,7 @@ class TimeSpent extends CommonObject if (!empty($conf->global->TIMESPENT_timespent_ADDON)) { $mybool = false; - $file = $conf->global->TIMESPENT_timespent_ADDON.".php"; + $file = getDolGlobalString('TIMESPENT_timespent_ADDON') . ".php"; $classname = $conf->global->TIMESPENT_timespent_ADDON; // Include file with class diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 4b538021da4..76a085372ee 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -82,7 +82,7 @@ class Translate $more = array(); $i = 0; foreach ($conf->file->dol_document_root as $dir) { - $newdir = $dir . $conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' + $newdir = $dir . getDolGlobalString('MAIN_FORCELANGDIR'); // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' if (!in_array($newdir, $this->dir)) { $more['module_' . $i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir. diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index b512b8c660b..8569d9b8fc3 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -914,7 +914,7 @@ class Utils $utils = new Utils($this->db); // Build HTML doc - $command = $conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC; + $command = getDolGlobalString('MODULEBUILDER_ASCIIDOCTOR') . ' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC; $outfile = $dirofmoduletmp.'/out.tmp'; $resarray = $utils->executeCLI($command, $outfile); @@ -929,7 +929,7 @@ class Utils } // Build PDF doc - $command = $conf->global->MODULEBUILDER_ASCIIDOCTORPDF.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOCPDF; + $command = getDolGlobalString('MODULEBUILDER_ASCIIDOCTORPDF') . ' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOCPDF; $outfile = $dirofmoduletmp.'/outpdf.tmp'; $resarray = $utils->executeCLI($command, $outfile); if ($resarray['result'] != '0') { diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 0f42870f541..c666f8a9469 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1067,7 +1067,7 @@ function purgeSessions($mysessionid) if (preg_match('/dol_login/i', $sessValues) && // limit to dolibarr session preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i', $sessValues) && // limit to current entity - preg_match('/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.')"/i', $sessValues)) { // limit to company name + preg_match('/dol_company\|s:([0-9]+):"(' . getDolGlobalString('MAIN_INFO_SOCIETE_NOM').')"/i', $sessValues)) { // limit to company name $tmp = explode('_', $file); $idsess = $tmp[1]; // We remove session if it's not ourself diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 7d8794fb0df..1a49715dac3 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -112,7 +112,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ' ';
print $langs->trans("URLToLaunchCronJobs").': '; - $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; + $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey=' . getDolGlobalString('CRON_KEY').'&').'userlogin='.$user->login; print ' ';
print '';
print ' '.img_picto('', 'globe')."\n";
print ' ';
print ''.$langs->trans("OrToLaunchASpecificJob").' '; - $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; + $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey=' . getDolGlobalString('CRON_KEY').'&').'userlogin='.$user->login.'&id=cronjobid'; print ' ';
print '';
print ' '.img_picto('', 'globe')."\n";
@@ -128,7 +128,7 @@ function dol_print_cron_urls()
$pathtoscript = $conf->global->MAIN_DOL_SCRIPTS_ROOT;
}
- $file = $pathtoscript.'/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY).' '.$logintouse.' [cronjobid]';
+ $file = $pathtoscript.'/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY) ? 'securitykey' : '' . getDolGlobalString('CRON_KEY')).' '.$logintouse.' [cronjobid]';
print ' \n"; print ' '; @@ -145,7 +145,7 @@ function dol_print_cron_urls() if ($linuxlike) { print $langs->trans("CronExplainHowToRunUnix"); print ' '; - print ' '; + print ' '; } else { print $langs->trans("CronExplainHowToRunWin"); } diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index 3dbc277cca2..746e3cf13fe 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -39,7 +39,7 @@ function emailing_prepare_head(Mailing $object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('mailing', 'mailing_advance', 'recipient'))) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; $head[$h][1] = $langs->trans("MailRecipients"); if ($object->nbemail > 0) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 140de247d2a..6637e0f931e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1305,7 +1305,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable $return = move_uploaded_file($src_file_osencoded, $file_name_osencoded); if ($return) { dolChmod($file_name_osencoded); - dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); + dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=" . getDolGlobalString('MAIN_UMASK'), LOG_DEBUG); return $successcode; // Success } else { dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); @@ -2721,10 +2721,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; } elseif (($modulepart == 'holiday') && !empty($conf->holiday->dir_output)) { - if ($fuser->hasRight('holiday', $read) || !empty($fuser->rights->holiday->readall) || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('holiday', $read) || $fuser->hasRight('holiday', 'readall') || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; // If we known $id of holiday, call checkUserAccessToObject to check permission on properties and hierarchy of leave request - if ($refname && empty($fuser->rights->holiday->readall) && !preg_match('/^specimen/i', $original_file)) { + if ($refname && !$fuser->hasRight('holiday', 'readall') && !preg_match('/^specimen/i', $original_file)) { include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $tmpholiday = new Holiday($db); $tmpholiday->fetch('', $refname); @@ -2733,10 +2733,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->holiday->dir_output.'/'.$original_file; } elseif (($modulepart == 'expensereport') && !empty($conf->expensereport->dir_output)) { - if ($fuser->hasRight('expensereport', $lire) || !empty($fuser->rights->expensereport->readall) || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('expensereport', $lire) || $fuser->hasRight('expensereport', 'readall') || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; // If we known $id of expensereport, call checkUserAccessToObject to check permission on properties and hierarchy of expense report - if ($refname && empty($fuser->rights->expensereport->readall) && !preg_match('/^specimen/i', $original_file)) { + if ($refname && !$fuser->hasRight('expensereport', 'readall') && !preg_match('/^specimen/i', $original_file)) { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $tmpexpensereport = new ExpenseReport($db); $tmpexpensereport->fetch('', $refname); @@ -2836,7 +2836,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file = $conf->categorie->multidir_output[$entity].'/'.$original_file; } elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) { // Wrapping pour les prelevements - if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('prelevement', 'bons', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->prelevement->dir_output.'/'.$original_file; @@ -2980,7 +2980,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('propal').")"; } elseif (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->multidir_output[$entity])) { // Wrapping pour les commandes - if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('commande', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; @@ -3014,21 +3014,21 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; } elseif (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output)) { // Wrapping pour les commandes fournisseurs - if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('fournisseur', 'commande', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } elseif (($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') && !empty($conf->fournisseur->facture->dir_output)) { // Wrapping pour les factures fournisseurs - if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('fournisseur', 'facture', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } elseif ($modulepart == 'supplier_payment') { // Wrapping pour les rapport de paiements - if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('fournisseur', 'facture', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->fournisseur->payment->dir_output.'/'.$original_file; @@ -3045,7 +3045,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } } elseif ($modulepart == 'export_compta' && !empty($conf->accounting->dir_output)) { // Wrapping for accounting exports - if ($fuser->rights->accounting->bind->write || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('accounting', 'bind', 'write') || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->accounting->dir_output.'/'.$original_file; @@ -3111,7 +3111,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } } elseif ($modulepart == 'contract' && !empty($conf->contrat->multidir_output[$entity])) { // Wrapping pour les contrats - if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file)) { + if ($fuser->hasRight('contrat', $lire) || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->contrat->multidir_output[$entity].'/'.$original_file; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8a86752b31b..28d5b05c028 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1849,7 +1849,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = // If adding log inside HTML page is required if ((!empty($_REQUEST['logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML)) - || (!empty($user->rights->debugbar->read) && is_object($debugbar))) { + || ($user->hasRight('debugbar', 'read') && is_object($debugbar))) { $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$logLevels[$level]." ".$message; } @@ -2277,7 +2277,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $showimage = 1; $entity = (empty($object->entity) ? $conf->entity : $object->entity); $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1); - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->hasRight('barcode', 'lire_advance')) { $showbarcode = 0; } $modulepart = 'unknown'; @@ -4556,9 +4556,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { - $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module + $path = getDolGlobalString('MAIN_OVERWRITE_THEME_PATH') . '/theme/'.$theme; // If the theme does not have the same name as the module } elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { - $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme + $path = getDolGlobalString('MAIN_OVERWRITE_THEME_RES') . '/theme/' . getDolGlobalString('MAIN_OVERWRITE_THEME_RES'); // To allow an external module to overwrite image resources whatever is activated theme } elseif (!empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module } @@ -9993,7 +9993,7 @@ function printCommonFooter($zone = 'private') $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (!empty($conf->global->MAIN_HTML_FOOTER)) { - print $conf->global->MAIN_HTML_FOOTER."\n"; + print getDolGlobalString('MAIN_HTML_FOOTER') . "\n"; } print "\n"; @@ -10106,7 +10106,7 @@ function printCommonFooter($zone = 'private') print "/* JS CODE TO ENABLE to add memory info */\n"; print 'window.console && console.log("'; if (!empty($conf->global->MEMCACHED_SERVER)) { - print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - '; + print 'MEMCACHED_SERVER=' . getDolGlobalString('MEMCACHED_SERVER').' - '; } print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off'); if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable. @@ -10156,7 +10156,7 @@ function printCommonFooter($zone = 'private') } // Add DebugBar data - if (!empty($user->rights->debugbar->read) && is_object($debugbar)) { + if ($user->hasRight('debugbar', 'read') && is_object($debugbar)) { $debugbar['time']->stopMeasure('pageaftermaster'); print ''."\n"; $renderer = $debugbar->getRenderer(); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index b2935e867bf..ab745d212c2 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -501,16 +501,16 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) $sql .= ", s.rowid as socid, s.email"; $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", cc.rowid as country_id, cc.code as country_code"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; } $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').")"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } @@ -525,7 +525,7 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; $sql .= " cc.rowid, cc.code"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user"; } @@ -652,12 +652,12 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0) $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').')'; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -775,7 +775,7 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) $sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; @@ -783,7 +783,7 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) if ($socid) { $sql .= " AND f.fk_soc = ".((int) $socid); } - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY f.tms DESC"; @@ -883,7 +883,7 @@ function getPurchaseInvoiceLatestEditTable($maxCount = 5, $socid = 0) $sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; @@ -891,7 +891,7 @@ function getPurchaseInvoiceLatestEditTable($maxCount = 5, $socid = 0) if ($socid) { $sql .= " AND f.fk_soc = ".((int) $socid); } - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY f.tms DESC"; @@ -1002,12 +1002,12 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.entity IN (".getEntity('invoice').')'; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -1189,14 +1189,14 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = ff.fk_soc"; $sql .= " AND ff.entity = ".$conf->entity; $sql .= " AND ff.paye = 0"; $sql .= " AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; - if (empty($user->rights->societe->client->voir) && !$socid) { + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index a4761276203..2be76f7fab3 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -52,7 +52,7 @@ function member_prepare_head(Adherent $object) $h++; } - if (!empty($user->rights->adherent->cotisation->lire)) { + if ($user->hasRight('adherent', 'cotisation', 'lire')) { $nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0; $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Subscriptions"); @@ -64,7 +64,7 @@ function member_prepare_head(Adherent $object) } if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { - if (!empty($user->rights->partnership->read)) { + if ($user->hasRight('partnership', 'read')) { $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Partnerships"); diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index e9859e79cb6..29d00bc61bc 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -282,10 +282,10 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { - $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + $out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + order_ref)"; } if ($mode == 0) { - $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . $type.$ref, 2); } $out .= ($mode ? '' : ''); } @@ -305,10 +305,10 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { - $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + $out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + invoice_ref)"; } if ($mode == 0) { - $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . $type.$ref, 2); } $out .= ($mode ? '' : ''); } @@ -328,10 +328,10 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { - $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + $out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + contractline_ref)"; } if ($mode == 0) { - $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . $type.$ref, 2); } $out .= ($mode ? '' : ''); } @@ -354,10 +354,10 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { - $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$newtype."' + member_ref)"; + $out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$newtype."' + member_ref)"; } if ($mode == 0) { - $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$newtype.$ref, 2); + $out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . $newtype.$ref, 2); } $out .= ($mode ? '' : ''); } @@ -377,10 +377,10 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { - $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; + $out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + donation_ref)"; } if ($mode == 0) { - $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . $type.$ref, 2); } $out .= ($mode ? '' : ''); } @@ -400,10 +400,10 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { - $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + $out .= "hash('" . getDolGlobalString('PAYMENT_SECURITY_TOKEN')."' + '".$type."' + invoice_ref)"; } if ($mode == 0) { - $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . $type.$ref, 2); } $out .= ($mode ? '' : ''); } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d10884d6217..ea4ad55bf31 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -536,7 +536,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); } if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { - $stringaddress .= ($stringaddress ? "\n" : '').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; + $stringaddress .= ($stringaddress ? "\n" : '') . getDolGlobalString('PDF_ADD_MORE_AFTER_SOURCE_ADDRESS'); } } @@ -724,7 +724,7 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) // Add a background image on document only if good setup of const if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF != '-1')) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image - $filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF; + $filepath = $conf->mycompany->dir_output.'/logos/' . getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF'); if (file_exists($filepath)) { $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); } // Option for change opacity of background diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index f6c4bdcdb5f..e90e83a0a32 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -615,7 +615,7 @@ function show_stats_for_company($product, $socid) } // MO - if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { + if (isModEnabled('mrp') && $user->hasRight('mrp', 'read')) { $nblines++; $ret = $product->load_stats_mo($socid); if ($ret < 0) { @@ -679,7 +679,7 @@ function show_stats_for_batch($batch, $socid) print ' ';
//if ($showlineingray) print '';
- if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
+ if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || $user->hasRight('projet', 'all', 'lire')) {
print $projectstatic->getNomUrl(1);
} else {
print $projectstatic->getNomUrl(1, 'nolink');
@@ -1291,7 +1291,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
- if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
$disabledproject = 0;
$disabledtask = 0;
}
@@ -1648,7 +1648,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
- if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
$disabledproject = 0;
$disabledtask = 0;
}
@@ -2047,7 +2047,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
- if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
$disabledproject = 0;
$disabledtask = 0;
}
@@ -2340,7 +2340,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
- if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->hasRight('projet', 'all', 'creer')) {
$disabledproject = 0;
$disabledtask = 0;
}
diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php
index 598f8432a1c..113bc1984c6 100644
--- a/htdocs/core/lib/propal.lib.php
+++ b/htdocs/core/lib/propal.lib.php
@@ -42,8 +42,8 @@ function propal_prepare_head($object)
$head[$h][2] = 'comm';
$h++;
- if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->rights->expedition->lire)
- || (isModEnabled("expedition") && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->lire)))) {
+ if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'lire'))
+ || (isModEnabled("expedition") && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'lire'))))) {
$langs->load("sendings");
$text = '';
$head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id;
@@ -214,7 +214,7 @@ function getCustomerProposalPieChart($socid = 0)
$result= '';
- if (!isModEnabled('propal') || empty($user->rights->propal->lire)) {
+ if (!isModEnabled('propal') || !$user->hasRight('propal', 'lire')) {
return '';
}
@@ -225,7 +225,7 @@ function getCustomerProposalPieChart($socid = 0)
$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
@@ -233,7 +233,7 @@ function getCustomerProposalPieChart($socid = 0)
if ($user->socid) {
$sql .= ' AND p.fk_soc = '.((int) $user->socid);
}
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " AND p.fk_statut IN (".$db->sanitize(implode(" ,", $listofstatus)).")";
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 978fd100fe6..76358337690 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -242,7 +242,7 @@ function dol_hash($chain, $type = '0')
// Salt value
if (!empty($conf->global->MAIN_SECURITY_SALT) && $type != '4' && $type !== 'openldap') {
- $chain = $conf->global->MAIN_SECURITY_SALT.$chain;
+ $chain = getDolGlobalString('MAIN_SECURITY_SALT') . $chain;
}
if ($type == '1' || $type == 'sha1') {
@@ -506,27 +506,27 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$nbko++;
}
} elseif (($feature == 'societe' && (!empty($feature2) && in_array('contact', $feature2))) || $feature == 'contact') {
- if (empty($user->rights->societe->contact->lire)) {
+ if (!$user->hasRight('societe', 'contact', 'lire')) {
$readok = 0;
$nbko++;
}
} elseif ($feature == 'produit|service') {
- if (empty($user->rights->produit->lire) && empty($user->rights->service->lire)) {
+ if (!$user->hasRight('produit', 'lire') && !$user->hasRight('service', 'lire')) {
$readok = 0;
$nbko++;
}
} elseif ($feature == 'prelevement') {
- if (empty($user->rights->prelevement->bons->lire)) {
+ if (!$user->hasRight('prelevement', 'bons', 'lire')) {
$readok = 0;
$nbko++;
}
} elseif ($feature == 'cheque') {
- if (empty($user->rights->banque->cheque)) {
+ if (!$user->hasRight('banque', 'cheque')) {
$readok = 0;
$nbko++;
}
} elseif ($feature == 'projet') {
- if (empty($user->rights->projet->lire) && empty($user->rights->projet->all->lire)) {
+ if (!$user->hasRight('projet', 'lire') && !$user->hasRight('projet', 'all', 'lire')) {
$readok = 0;
$nbko++;
}
@@ -536,12 +536,12 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$nbko++;
}
} elseif ($feature == 'payment_supplier') {
- if (empty($user->rights->fournisseur->facture->lire)) {
+ if (!$user->hasRight('fournisseur', 'facture', 'lire')) {
$readok = 0;
$nbko++;
}
} elseif ($feature == 'payment_sc') {
- if (empty($user->rights->tax->charges->lire)) {
+ if (!$user->hasRight('tax', 'charges', 'lire')) {
$readok = 0;
$nbko++;
}
@@ -556,9 +556,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$tmpreadok = 1;
continue;
}
- if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) {
+ if (!empty($subfeature) && !$user->hasRight($feature, $subfeature, 'lire') && !$user->hasRight($feature, $subfeature, 'read')) {
$tmpreadok = 0;
- } elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) {
+ } elseif (empty($subfeature) && !$user->hasRight($feature, 'lire') && !$user->hasRight($feature, 'read')) {
$tmpreadok = 0;
} else {
$tmpreadok = 1;
@@ -570,9 +570,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$nbko++;
}
} elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) { // This is permissions on 1 level (module->read)
- if (empty($user->rights->$feature->lire)
- && empty($user->rights->$feature->read)
- && empty($user->rights->$feature->run)) {
+ if (!$user->hasRight($feature, 'lire')
+ && !$user->hasRight($feature, 'read')
+ && !$user->hasRight($feature, 'run')) {
$readok = 0;
$nbko++;
}
@@ -602,22 +602,22 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) {
foreach ($featuresarray as $feature) {
if ($feature == 'contact') {
- if (empty($user->rights->societe->contact->creer)) {
+ if (!$user->hasRight('societe', 'contact', 'creer')) {
$createok = 0;
$nbko++;
}
} elseif ($feature == 'produit|service') {
- if (empty($user->rights->produit->creer) && empty($user->rights->service->creer)) {
+ if (!$user->hasRight('produit', 'creer') && !$user->hasRight('service', 'creer')) {
$createok = 0;
$nbko++;
}
} elseif ($feature == 'prelevement') {
- if (!$user->rights->prelevement->bons->creer) {
+ if (!$user->hasRight('prelevement', 'bons', 'creer')) {
$createok = 0;
$nbko++;
}
} elseif ($feature == 'commande_fournisseur') {
- if (empty($user->rights->fournisseur->commande->creer) || empty($user->rights->supplier_order->creer)) {
+ if (!$user->hasRight('fournisseur', 'commande', 'creer') || !$user->hasRight('supplier_order', 'creer')) {
$createok = 0;
$nbko++;
}
@@ -627,17 +627,17 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$nbko++;
}
} elseif ($feature == 'cheque') {
- if (empty($user->rights->banque->cheque)) {
+ if (!$user->hasRight('banque', 'cheque')) {
$createok = 0;
$nbko++;
}
} elseif ($feature == 'import') {
- if (empty($user->rights->import->run)) {
+ if (!$user->hasRight('import', 'run')) {
$createok = 0;
$nbko++;
}
} elseif ($feature == 'ecm') {
- if (!$user->rights->ecm->upload) {
+ if (!$user->hasRight('ecm', 'upload')) {
$createok = 0;
$nbko++;
}
@@ -658,9 +658,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
continue; // User can edit another user's password
}
- if (empty($user->rights->$feature->$subfeature->creer)
- && empty($user->rights->$feature->$subfeature->write)
- && empty($user->rights->$feature->$subfeature->create)) {
+ if (!$user->hasRight($feature, $subfeature, 'creer')
+ && !$user->hasRight($feature, $subfeature, 'write')
+ && !$user->hasRight($feature, $subfeature, 'create')) {
$createok = 0;
$nbko++;
} else {
@@ -671,9 +671,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
}
} elseif (!empty($feature)) { // This is for permissions on 1 levels (module->write)
//print ' | feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit; - if (empty($user->rights->$feature->creer) - && empty($user->rights->$feature->write) - && empty($user->rights->$feature->create)) { + if (!$user->hasRight($feature, 'creer') + && !$user->hasRight($feature, 'write') + && !$user->hasRight($feature, 'create')) { $createok = 0; $nbko++; } @@ -718,13 +718,13 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') { foreach ($featuresarray as $feature) { if ($feature == 'bookmark') { - if (!$user->rights->bookmark->supprimer) { - if ($user->id != $object->fk_user || empty($user->rights->bookmark->creer)) { + if (!$user->hasRight('bookmark', 'supprimer')) { + if ($user->id != $object->fk_user || !$user->hasRight('bookmark', 'creer')) { $deleteok = 0; } } } elseif ($feature == 'contact') { - if (!$user->rights->societe->contact->supprimer) { + if (!$user->hasRight('societe', 'contact', 'supprimer')) { $deleteok = 0; } } elseif ($feature == 'produit|service') { @@ -732,19 +732,19 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $deleteok = 0; } } elseif ($feature == 'commande_fournisseur') { - if (!$user->rights->fournisseur->commande->supprimer) { + if (!$user->hasRight('fournisseur', 'commande', 'supprimer')) { $deleteok = 0; } } elseif ($feature == 'payment_supplier') { // Permission to delete a payment of an invoice is permission to edit an invoice. - if (!$user->rights->fournisseur->facture->creer) { + if (!$user->hasRight('fournisseur', 'facture', 'creer')) { $deleteok = 0; } } elseif ($feature == 'payment') { - if (!$user->rights->facture->paiement) { + if (!$user->hasRight('facture', 'paiement')) { $deleteok = 0; } } elseif ($feature == 'payment_sc') { - if (!$user->rights->tax->charges->creer) { + if (!$user->hasRight('tax', 'charges', 'creer')) { $deleteok = 0; } } elseif ($feature == 'banque') { @@ -752,36 +752,36 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $deleteok = 0; } } elseif ($feature == 'cheque') { - if (empty($user->rights->banque->cheque)) { + if (!$user->hasRight('banque', 'cheque')) { $deleteok = 0; } } elseif ($feature == 'ecm') { - if (!$user->rights->ecm->upload) { + if (!$user->hasRight('ecm', 'upload')) { $deleteok = 0; } } elseif ($feature == 'ftp') { - if (!$user->rights->ftp->write) { + if (!$user->hasRight('ftp', 'write')) { $deleteok = 0; } } elseif ($feature == 'salaries') { - if (!$user->rights->salaries->delete) { + if (!$user->hasRight('salaries', 'delete')) { $deleteok = 0; } } elseif ($feature == 'adherent') { - if (empty($user->rights->adherent->supprimer)) { + if (!$user->hasRight('adherent', 'supprimer')) { $deleteok = 0; } } elseif ($feature == 'paymentbybanktransfer') { - if (empty($user->rights->paymentbybanktransfer->create)) { // There is no delete permission + if (!$user->hasRight('paymentbybanktransfer', 'create')) { // There is no delete permission $deleteok = 0; } } elseif ($feature == 'prelevement') { - if (empty($user->rights->prelevement->bons->creer)) { // There is no delete permission + if (!$user->hasRight('prelevement', 'bons', 'creer')) { // There is no delete permission $deleteok = 0; } } elseif (!empty($feature2)) { // This is for permissions on 2 levels foreach ($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) { + if (!$user->hasRight($feature, $subfeature, 'supprimer') && !$user->hasRight($feature, $subfeature, 'delete')) { $deleteok = 0; } else { $deleteok = 1; @@ -790,9 +790,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', } } elseif (!empty($feature)) { // This is used for permissions on 1 level //print ' feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; - if (empty($user->rights->$feature->supprimer) - && empty($user->rights->$feature->delete) - && empty($user->rights->$feature->run)) { + if (!$user->hasRight($feature, 'supprimer') + && !$user->hasRight($feature, 'delete') + && !$user->hasRight($feature, 'run')) { $deleteok = 0; } } @@ -959,7 +959,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl if ($user->socid != $objectid) { return false; } - } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && empty($user->rights->societe->client->voir))) { + } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && !$user->hasRight('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"; @@ -985,7 +985,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->hasRight('societe', 'lire') && empty($user->rights->societe->client->voir))) { + } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && !$user->hasRight('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"; @@ -1004,7 +1004,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkonentitydone = 1; } if (in_array($feature, $checkproject) && $objectid > 0) { - if (isModEnabled('project') && empty($user->rights->projet->all->lire)) { + if (isModEnabled('project') && !$user->hasRight('projet', 'all', 'lire')) { $projectid = $objectid; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -1024,7 +1024,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkonentitydone = 1; } if (in_array($feature, $checktask) && $objectid > 0) { - if (isModEnabled('project') && empty($user->rights->projet->all->lire)) { + if (isModEnabled('project') && !$user->hasRight('projet', 'all', 'lire')) { $task = new Task($db); $task->fetch($objectid); $projectid = $task->fk_project; @@ -1058,7 +1058,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.".$dbt_keyfield." = ".((int) $user->socid); - } elseif (isModEnabled("societe") && empty($user->rights->societe->client->voir)) { + } elseif (isModEnabled("societe") && !$user->hasRight('societe', 'client', 'voir')) { // If internal user without permission to see all thirdparties: Check permission for internal users that are restricted on their objects if ($feature != 'ticket') { if (empty($dbt_keyfield)) { @@ -1092,7 +1092,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl // For events, check on users assigned to event if ($feature === 'agenda' && $objectid > 0) { // Also check owner or attendee for users without allactions->read - if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { + if ($objectid > 0 && !$user->hasRight('agenda', 'allactions', 'read')) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action = new ActionComm($db); $action->fetch($objectid); @@ -1115,7 +1115,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl } if ($feature == 'expensereport') { $useridtocheck = $object->fk_user_author; - if (!$user->rights->expensereport->readall) { + if (!$user->hasRight('expensereport', 'readall')) { if (!in_array($useridtocheck, $childids)) { return false; } diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 3677851a613..91287500281 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -54,7 +54,7 @@ function shipping_prepare_head($object) $h++; } - if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->lire) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'lire')) { // delivery link $object->fetchObjectLinked($object->id, $object->element); if (isset($object->linkedObjectsIds['delivery']) && is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) { // If there is a delivery @@ -140,7 +140,7 @@ function delivery_prepare_head($object) $h = 0; $head = array(); - if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->rights->expedition->lire) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'lire')) { $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; $head[$h][1] = $langs->trans("SendingCard"); $head[$h][2] = 'shipping'; diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index 131093659b9..d397ff26311 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -39,7 +39,7 @@ function stock_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (!empty($user->rights->stock->mouvement->lire)) { + if ($user->hasRight('stock', 'mouvement', 'lire')) { $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; $head[$h][1] = $langs->trans("StockMovements"); $head[$h][2] = 'movements'; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 168fa7fbc62..a772d841e7c 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -141,10 +141,10 @@ function user_prepare_head(User $object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'user'); - if ((isModEnabled('salaries') && !empty($user->rights->salaries->read)) - || (isModEnabled('hrm') && !empty($user->rights->hrm->employee->read)) - || (isModEnabled('expensereport') && !empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) - || (isModEnabled('holiday') && !empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->readall)) + if ((isModEnabled('salaries') && $user->hasRight('salaries', 'read')) + || (isModEnabled('hrm') && $user->hasRight('hrm', 'employee', 'read')) + || (isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire') && ($user->id == $object->id || $user->hasRight('expensereport', 'readall'))) + || (isModEnabled('holiday') && $user->hasRight('holiday', 'read') && ($user->id == $object->id || $user->hasRight('holiday', 'readall'))) ) { // Bank $head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id; @@ -365,7 +365,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ' '.$langs->trans("DefaultSkin").' | ';
- print ''.$conf->global->MAIN_THEME.' | ';
+ print '' . getDolGlobalString('MAIN_THEME').' | ';
print ' | ';
print ' | ';
print ''.$langs->trans("Mask").': | ';
- $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).' | ';
+ $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).' | ';
$texte .= ' | ';
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index adb695487d9..98b85c87912 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -270,7 +270,7 @@ class pdf_einstein extends ModelePDFCommandes
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index 2709278b7b1..719f135cec8 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -225,7 +225,7 @@ class pdf_strato extends ModelePDFContract
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
index 03b40ecfeec..91c00a56735 100644
--- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
+++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php
@@ -246,7 +246,7 @@ class pdf_storm extends ModelePDFDeliveryOrder
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php
index 0fcf8381438..663013072f5 100644
--- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php
+++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php
@@ -210,7 +210,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index 668666b24d3..b6bb671a63d 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -249,7 +249,7 @@ class pdf_espadon extends ModelePdfExpedition
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
index 7dfa66c3bf7..4ebd3106f80 100644
--- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
@@ -202,7 +202,7 @@ class pdf_merou extends ModelePdfExpedition
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index 477c1280a49..74d692a9670 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -277,7 +277,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
index c2d4799f75a..a7066ad41fb 100644
--- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
@@ -245,7 +245,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index c9727ded9e1..737323075c7 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -328,7 +328,7 @@ class pdf_crabe extends ModelePDFFactures
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index dac0d5e0d1f..308e7269aab 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -354,7 +354,7 @@ class pdf_sponge extends ModelePDFFactures
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index f6b0ed7ea9b..6acc1edf5e2 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -199,7 +199,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php
index 9fb21605fcd..bac5e4ee5b8 100644
--- a/htdocs/core/modules/member/doc/pdf_standard.class.php
+++ b/htdocs/core/modules/member/doc/pdf_standard.class.php
@@ -133,8 +133,8 @@ class pdf_standard extends CommonStickerGenerator
// Define background image
$backgroundimage = '';
- if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) {
- $backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND;
+ if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/' . getDolGlobalString('ADHERENT_CARD_BACKGROUND'))) {
+ $backgroundimage = $conf->adherent->dir_output.'/' . getDolGlobalString('ADHERENT_CARD_BACKGROUND');
}
// Print lines
diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php
index f6ca067d7c8..7ed730ea43e 100644
--- a/htdocs/core/modules/modAgenda.class.php
+++ b/htdocs/core/modules/modAgenda.class.php
@@ -477,7 +477,7 @@ class modAgenda extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
$this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
}
if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index 4fae3b1e0c9..8d4d5a7f21e 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -271,7 +271,7 @@ class modCommande extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
@@ -288,7 +288,7 @@ class modCommande extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('commande').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php
index 6c4488dfbb7..8efb4f44bee 100644
--- a/htdocs/core/modules/modDeplacement.class.php
+++ b/htdocs/core/modules/modDeplacement.class.php
@@ -129,12 +129,12 @@ class modDeplacement extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u';
$this->export_sql_end[$r] .= ', '.MAIN_DB_PREFIX.'deplacement as d';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' WHERE d.fk_user = u.rowid';
$this->export_sql_end[$r] .= ' AND d.entity IN ('.getEntity('deplacement').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR d.fk_soc IS NULL)';
}
@@ -142,7 +142,7 @@ class modDeplacement extends DolibarrModules
$childids = $user->getAllChildIds();
$childids[] = $user->id;
- if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) {
+ if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {
$this->export_sql_end[$r] .= ' AND d.fk_user IN ('.$this->db->sanitize(join(',', $childids)).')';
}
}
diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php
index 9fdef7671c3..6dd79d7a828 100644
--- a/htdocs/core/modules/modExpedition.class.php
+++ b/htdocs/core/modules/modExpedition.class.php
@@ -303,7 +303,7 @@ class modExpedition extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'expedition as c';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
@@ -320,7 +320,7 @@ class modExpedition extends DolibarrModules
}
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
}
diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php
index 911090c63d3..35dded1d39b 100644
--- a/htdocs/core/modules/modFacture.class.php
+++ b/htdocs/core/modules/modFacture.class.php
@@ -602,7 +602,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid';
@@ -622,7 +622,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_account as aa on fd.fk_code_ventilation = aa.rowid';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
$r++;
@@ -688,7 +688,7 @@ class modFacture extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid';
@@ -705,7 +705,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
$r++;
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index 3127a0d76bb..d58a208b606 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -374,7 +374,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@@ -386,7 +386,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.((int) $user->id);
}
@@ -439,7 +439,7 @@ class modFournisseur extends DolibarrModules
// End add extra fields object
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@@ -450,7 +450,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.((int) $user->id);
}
@@ -515,7 +515,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@@ -530,7 +530,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.((int) $user->id);
}
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index b7beb1f4d92..da8239c7998 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -276,7 +276,7 @@ class modPropale extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s ';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
@@ -291,7 +291,7 @@ class modPropale extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('propal').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php
index 7a606b9c0a8..81b43327ca9 100644
--- a/htdocs/core/modules/modReception.class.php
+++ b/htdocs/core/modules/modReception.class.php
@@ -227,7 +227,7 @@ class modReception extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'reception as c';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
@@ -243,7 +243,7 @@ class modReception extends DolibarrModules
}
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('reception').')';
- if (empty($user->rights->societe->client->voir)) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
}
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 4863dcbdc09..fce0c474d61 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -349,7 +349,7 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as pbacc ON s.fk_account = pbacc.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid';
$this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.((int) $user->id).' ';
if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
$subordinatesids = $user->getAllChildIds();
@@ -427,7 +427,7 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
@@ -436,7 +436,7 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
$this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('contact').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) {
+ if (is_object($user) && !$user->hasRight('societe', 'client', 'voir')) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.((int) $user->id).' ';
if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
$subordinatesids = $user->getAllChildIds();
diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php
index ac53946bb06..9d1cb622c15 100644
--- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php
@@ -394,7 +394,7 @@ class pdf_standard extends ModelePDFMovement
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
index 8bb66bda191..691fd91d38d 100644
--- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
+++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php
@@ -226,7 +226,7 @@ class pdf_vinci extends ModelePDFMo
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php
index 784ca628314..d7987b1dbec 100644
--- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php
+++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php
@@ -163,7 +163,7 @@ if (GETPOST('code')) { // We are coming from oauth provider page
} else {
//$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
//https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write
- $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->$keyforparamid.'&scope=read_write';
+ $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id=' . getDolGlobalString($keyforparamid).'&scope=read_write';
}
if (empty($url)) {
diff --git a/htdocs/core/modules/oauth/stripetest_oauthcallback.php b/htdocs/core/modules/oauth/stripetest_oauthcallback.php
index 8f4a15d7e77..39ff602db7d 100644
--- a/htdocs/core/modules/oauth/stripetest_oauthcallback.php
+++ b/htdocs/core/modules/oauth/stripetest_oauthcallback.php
@@ -163,7 +163,7 @@ if (GETPOST('code')) { // We are coming from oauth provider page
} else {
//$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
//https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write
- $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->$keyforparamid.'&scope=read_write';
+ $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id=' . getDolGlobalString($keyforparamid).'&scope=read_write';
}
if (empty($url)) {
diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php
index 6bfd01c2f1b..7cb608f09e5 100644
--- a/htdocs/core/modules/product/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php
@@ -189,7 +189,7 @@ class pdf_standard extends ModelePDFProduct
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
index f4f413758a3..9ac830d4cf5 100644
--- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
@@ -206,7 +206,7 @@ class pdf_baleine extends ModelePDFProjects
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
index a7cf4c50b96..027efd47f9e 100644
--- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
@@ -237,7 +237,7 @@ class pdf_beluga extends ModelePDFProjects
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php
index 60e03823f22..67138288687 100644
--- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php
@@ -196,7 +196,7 @@ class pdf_timespent extends ModelePDFProjects
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 27caa33087f..de07c221bb2 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -318,7 +318,7 @@ class pdf_azur extends ModelePDFPropales
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
index 0d1bb192820..ee00a19bc5c 100644
--- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
@@ -300,7 +300,7 @@ class pdf_cyan extends ModelePDFPropales
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
}
- $pagecount = $pdf->setSourceFile($logodir.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php
index 0601ab06b0a..4a3f8b0ef89 100644
--- a/htdocs/core/modules/rapport/pdf_paiement.class.php
+++ b/htdocs/core/modules/rapport/pdf_paiement.class.php
@@ -217,7 +217,7 @@ class pdf_paiement extends CommonDocGenerator
$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
@@ -226,7 +226,7 @@ class pdf_paiement extends CommonDocGenerator
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if (!empty($socid)) {
@@ -255,7 +255,7 @@ class pdf_paiement extends CommonDocGenerator
$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
@@ -264,7 +264,7 @@ class pdf_paiement extends CommonDocGenerator
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if (!empty($socid)) {
diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
index 3d6d282bf8e..28ab5a7ad66 100644
--- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php
+++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
@@ -254,7 +254,7 @@ class pdf_squille extends ModelePdfReception
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
$tplidx = $pdf->importPage(1);
}
diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php
index f6eb46fa1b5..a4e2fe68172 100644
--- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php
+++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php
@@ -93,8 +93,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
$texte .= '';
$texte .= '';
$texte .= '
|