diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 585d5b664cb..53650a3cd28 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -720,7 +720,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
// List of mass actions available
$arrayofmassactions = array();
-if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
+if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
$arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto');
$arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto');
$arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual');
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index 9031c73624b..b61b82aeca2 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -381,7 +381,7 @@ if (empty($reshook)) {
$param = '&type='.$type.$param;
}
- //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
+ //if ($action == 'delbookkeepingyearconfirm' && $user->hasRight('accounting', 'mouvements', 'supprimer')_tous) {
// $delmonth = GETPOST('delmonth', 'int');
// $delyear = GETPOST('delyear', 'int');
// if ($delyear == -1) {
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 987d35512a5..8c46be39826 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -166,7 +166,7 @@ if (empty($reshook)) {
}
-if ($massaction == 'ventil' && $user->rights->accounting->bind->write) {
+if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) {
$msg = '';
//print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
$desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}');
$desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").' ', $desc);
@@ -894,10 +895,10 @@ if (empty($action) || $action == 'view') {
print '
';
}
print '';
- if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
+ if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') {
print '
';
}
- if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
+ if ($acctSupplierNotConfigured) {
print '
';
} else {
if ($in_bookkeeping == 'notyet') {
@@ -1023,7 +1024,7 @@ if (empty($action) || $action == 'view') {
print "
".$invoicestatic->getNomUrl(1)." ";
// Account
print "
";
- $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
+ $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'));
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print ''.$langs->trans("MainAccountForSuppliersNotDefined").' ';
} else {
@@ -1067,7 +1068,7 @@ if (empty($action) || $action == 'view') {
print " ";
// Subledger account
print "
";
- if (!empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT)) {
+ if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) {
print length_accounta($tabcompany[$key]['code_compta']);
}
@@ -1097,7 +1098,7 @@ if (empty($action) || $action == 'view') {
}
// VAT Reverse charge
- if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
+ if ($mysoc->country_code == 'FR' || getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
$has_vat = false;
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index e8178ad63d3..3f7b4ecdeb5 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -109,7 +109,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
-if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer as code_compta,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
@@ -117,26 +117,26 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
$sql .= " s.code_compta_fournisseur,";
}
$sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
-if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql .= " ppe.accountancy_code_sell";
} else {
$sql .= " p.accountancy_code_sell";
}
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
-if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
-if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
}
$sql .= " WHERE fd.fk_code_ventilation > 0";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing
$sql .= " AND f.fk_statut > 0";
-if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup
+if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { // Non common setup
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
} else {
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
@@ -146,8 +146,8 @@ if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
// Define begin binding date
-if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
- $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
+if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
+ $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
}
// Already in bookkeeping or not
if ($in_bookkeeping == 'already') {
@@ -177,8 +177,8 @@ if ($result) {
$num = $db->num_rows($result);
// Variables
- $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
- $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
+ $cptcli = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined');
+ $cpttva = getDolGlobalString('ACCOUNTING_VAT_SOLD_ACCOUNT', 'NotDefined');
$i = 0;
while ($i < $num) {
@@ -190,9 +190,9 @@ if ($result) {
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
if ($obj->product_type == 0) {
- $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
+ $compta_prod = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'NotDefined');
} else {
- $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
+ $compta_prod = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'NotDefined');
}
}
@@ -257,7 +257,7 @@ if ($result) {
// It also seems that credit notes on situation invoices are correctly saved (but it depends on the version used in fact).
// For credit notes, we hope to have situation_ratio = 1 so the compensation has no effect to avoid introducing troubles with credit notes.
$total_ttc = $obj->total_ttc * $situation_ratio;
- if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY) && $obj->retained_warranty > 0) {
+ if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
$retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT');
$tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
$total_ttc -= $retained_warranty;
@@ -315,11 +315,11 @@ if ($action == 'writebookkeeping') {
$invoicestatic = new Facture($db);
$accountingaccountcustomer = new AccountingAccount($db);
- $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
+ $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
$accountingaccountcustomerwarranty = new AccountingAccount($db);
- $accountingaccountcustomerwarranty->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY, true);
+ $accountingaccountcustomerwarranty->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0;
@@ -381,7 +381,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
- $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY;
+ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
$bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty");
@@ -430,7 +430,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
- $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
+ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER');
$bookkeeping->label_compte = $accountingaccountcustomer->label;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount");
@@ -488,7 +488,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_client;
- if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
+ if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
@@ -657,7 +657,7 @@ $form = new Form($db);
// Export
if ($action == 'exportcsv') { // ISO and not UTF8 !
- $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
+ $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
$filename = 'journal';
$type_export = 'journal';
@@ -704,7 +704,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$val["ref"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
- print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY).'"'.$sep;
+ print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$langs->trans("Thirdparty").'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep;
@@ -723,7 +723,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$val["ref"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
- print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER).'"'.$sep;
+ print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$langs->trans("Thirdparty").'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep;
@@ -800,7 +800,7 @@ if (empty($action) || $action == 'view') {
$exportlink = '';
$builddate = dol_now();
$description = $langs->trans("DescJournalOnlyBindedVisible").' ';
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
$description .= $langs->trans("DepositsAreNotIncluded");
} else {
$description .= $langs->trans("DepositsAreIncluded");
@@ -815,7 +815,8 @@ if (empty($action) || $action == 'view') {
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
// Button to write into Ledger
- if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ $acctCustomerNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), ['','-1']);
+ if ($acctCustomerNotConfigured) {
print ''.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
$desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}');
$desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").' ', $desc);
@@ -823,10 +824,10 @@ if (empty($action) || $action == 'view') {
print '
';
}
print '';
- if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
+ if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') {
print '
';
}
- if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ if ($acctCustomerNotConfigured) {
print '
';
} else {
if ($in_bookkeeping == 'notyet') {
@@ -950,7 +951,7 @@ if (empty($action) || $action == 'view') {
print "
".$invoicestatic->getNomUrl(1)." ";
// Account
print "
";
- $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY);
+ $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'));
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print ''.$langs->trans("MainAccountForCustomersNotDefined").' ';
} else {
@@ -980,7 +981,7 @@ if (empty($action) || $action == 'view') {
print " ".$invoicestatic->getNomUrl(1)." ";
// Account
print "
";
- $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
+ $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'));
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print ''.$langs->trans("MainAccountForCustomersNotDefined").' ';
} else {
@@ -1024,7 +1025,7 @@ if (empty($action) || $action == 'view') {
print " ";
// Subledger account
print "
";
- if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
+ if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
print length_accounta($tabcompany[$key]['code_compta']);
}
diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php
index 306b88d11ea..b393c0f54ce 100644
--- a/htdocs/accountancy/supplier/card.php
+++ b/htdocs/accountancy/supplier/card.php
@@ -57,7 +57,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
* Actions
*/
-if ($action == 'ventil' && $user->rights->accounting->bind->write) {
+if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) {
if (!$cancel) {
if ($codeventil < 0) {
$codeventil = 0;
diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php
index 5d212e57ccf..d6df336d979 100644
--- a/htdocs/accountancy/supplier/index.php
+++ b/htdocs/accountancy/supplier/index.php
@@ -91,7 +91,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
* Actions
*/
-if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) {
+if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) {
// Clean database
$db->begin();
$sql1 = "UPDATE ".$db->prefix()."facture_fourn_det as fd";
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index 2c4fece83f0..06fd0369f03 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -133,7 +133,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_tvaintra = '';
}
-if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) {
+if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
$error = 0;
if (!(GETPOST('account_parent', 'int') >= 0)) {
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 2b8fea60e51..8d227b7ce1b 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -169,7 +169,7 @@ if (empty($reshook)) {
}
-if ($massaction == 'ventil' && $user->rights->accounting->bind->write) {
+if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) {
$msg = '';
if (!empty($mesCasesCochees)) {
@@ -453,7 +453,7 @@ if ($result) {
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
);
- //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
+ //if ($user->hasRight('mymodule', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
if ($massaction !== 'set_default_account') {
$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index aaef5aa96a7..44b2fb349d6 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -1008,7 +1008,7 @@ class AdherentType extends CommonObject
//$return .= ' ';
- if ($user->rights->adherent->configurer) {
+ if ($user->hasRight('adherent', 'configurer')) {
$return .= 'ref).'">'.img_edit().' ';
} else {
$return .= ' ';
diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php
index c466ff7ff9d..a7503190a08 100644
--- a/htdocs/adherents/ldap.php
+++ b/htdocs/adherents/ldap.php
@@ -57,7 +57,7 @@ if ($id > 0 || !empty($ref)) {
// $User is the user who edits, $object->user_id is the id of the related user in the edited member
$caneditfielduser = ((($user->id == $object->user_id) && !empty($user->rights->user->self->creer))
|| (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
- $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
|| (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
}
}
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index d800c181c18..31dec948f89 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -134,7 +134,7 @@ if ($reshook < 0) {
}
// Create third party from a member
-if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) {
+if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
if ($result > 0) {
// Creation of thirdparty
$company = new Societe($db);
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 988693a8d26..dcf8722fcbe 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -350,7 +350,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
} else {
print ' ';
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- if ($user->rights->adherent->configurer) {
+ if ($user->hasRight('adherent', 'configurer')) {
print 'rowid.'">'.img_edit().' ';
}
}
@@ -374,7 +374,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print ''.yn($objp->vote).' ';
print ''.$membertype->getLibStatut(5).' ';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- if ($user->rights->adherent->configurer) {
+ if ($user->hasRight('adherent', 'configurer')) {
print 'rowid.'">'.img_edit().' ';
}
}
diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php
index ee0ae57e0e2..059802e9e88 100644
--- a/htdocs/api/class/api_documents.class.php
+++ b/htdocs/api/class/api_documents.class.php
@@ -403,7 +403,7 @@ class Documents extends DolibarrApi
throw new RestException(404, 'Purchase order not found');
}
- $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->fournisseur->dir_output."/commande/".dol_sanitizeFileName($object->ref);
} elseif ($modulepart == 'shipment' || $modulepart == 'expedition') {
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
diff --git a/htdocs/asset/model/accountancy_codes.php b/htdocs/asset/model/accountancy_codes.php
index b39a72bb7a3..539e11204a3 100644
--- a/htdocs/asset/model/accountancy_codes.php
+++ b/htdocs/asset/model/accountancy_codes.php
@@ -53,8 +53,8 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
}
-$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
-$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
+$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
+$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
// Security check (enable the most restrictive one)
if ($user->socid > 0) accessforbidden();
diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php
index 44a0fa504a3..31c49d5e40f 100644
--- a/htdocs/asset/model/agenda.php
+++ b/htdocs/asset/model/agenda.php
@@ -82,8 +82,8 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/model/" . $object->id;
}
-$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
-$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
+$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
+$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
// Security check (enable the most restrictive one)
if ($user->socid > 0) accessforbidden();
diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php
index 3eb75eded08..11e94e53ace 100644
--- a/htdocs/asset/model/card.php
+++ b/htdocs/asset/model/card.php
@@ -69,9 +69,9 @@ if (empty($action) && empty($id) && empty($ref)) {
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
-$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
+$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'delete')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $permissiontoadd; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
diff --git a/htdocs/asset/model/depreciation_options.php b/htdocs/asset/model/depreciation_options.php
index e8519e581d9..5f4a3276202 100644
--- a/htdocs/asset/model/depreciation_options.php
+++ b/htdocs/asset/model/depreciation_options.php
@@ -53,8 +53,8 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
}
-$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
-$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
+$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
+$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
// Security check (enable the most restrictive one)
if ($user->socid > 0) accessforbidden();
diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php
index d87a9ea55c8..dc6c544abaf 100644
--- a/htdocs/asset/model/list.php
+++ b/htdocs/asset/model/list.php
@@ -121,9 +121,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
-$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
-$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write)));
-$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete)));
+$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
+$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write)));
+$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'delete')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete)));
// Security check
if (!isModEnabled('asset')) {
diff --git a/htdocs/asset/model/note.php b/htdocs/asset/model/note.php
index c3490445429..9e26aee3e19 100644
--- a/htdocs/asset/model/note.php
+++ b/htdocs/asset/model/note.php
@@ -51,8 +51,8 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
}
-$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
-$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
+$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)));
+$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
$permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php
// Security check (enable the most restrictive one)
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index a262e8d8885..3a01c3b9c2d 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -112,11 +112,11 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') {
$tmpobject = new Product($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'product';
- } elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) {
+ } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
$tmpobject = new Societe($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'supplier';
- } elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) {
+ } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
$tmpobject = new Societe($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'customer';
@@ -125,7 +125,7 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') {
$tmpobject = new Adherent($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'member';
- } elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
+ } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$tmpobject = new Contact($db);
$result = $tmpobject->fetch($removeelem);
@@ -140,7 +140,7 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') {
$tmpobject = new Project($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'project';
- } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) {
+ } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$tmpobject = new User($db);
$result = $tmpobject->fetch($removeelem);
@@ -174,13 +174,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
if ($elemid && $action == 'addintocategory' &&
(($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) ||
- ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) ||
- ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) ||
+ ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) ||
+ ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) ||
($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) ||
($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) ||
($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) ||
- ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) ||
- ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) ||
+ ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) ||
+ ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) ||
($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
)) {
if ($type == Categorie::TYPE_PRODUCT) {
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index e6c4ac3060d..158cfc3aef0 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -155,7 +155,7 @@ $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month')
$result = restrictedArea($user, 'agenda', $object, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
-$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create);
+$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
/*
@@ -215,7 +215,7 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt
// Link to a project
if (empty($reshook) && $action == 'classin' && ($user->hasRight('agenda', 'allactions', 'create') ||
- (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) {
+ (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')))) {
//$object->fetch($id);
$object->setProject(GETPOST('projectid', 'int'));
}
@@ -970,7 +970,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes
$object->fetch_userassigned();
$object->oldcopy = dol_clone($object);
- if ($user->rights->agenda->myactions->delete
+ if ($user->hasRight('agenda', 'myactions', 'delete')
|| $user->rights->agenda->allactions->delete) {
$result = $object->delete();
@@ -1089,7 +1089,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') {
// Actions to delete doc
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
-$permissiontoadd = ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
+$permissiontoadd = ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'read')));
if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
@@ -2478,21 +2478,21 @@ if ($id > 0) {
if (empty($reshook)) {
if ($action != 'edit') {
if ($user->hasRight('agenda', 'allactions', 'create') ||
- (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
+ (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
print '';
} else {
print '';
}
if ($user->hasRight('agenda', 'allactions', 'create') ||
- (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
+ (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
print '';
} else {
print '';
}
if ($user->rights->agenda->allactions->delete ||
- (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) {
+ (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'delete'))) {
print '';
} else {
print '';
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 8879e48edd6..b79dfb084c5 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -2179,7 +2179,7 @@ class ActionComm extends CommonObject
if ($exportholiday == 1) {
$langs->load("holiday");
- $title = $langs->trans("Holidays");
+ $title = $langs->transnoentities("Holidays");
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php
index 4f7a944070b..908b4cc1d9a 100644
--- a/htdocs/comm/action/class/api_agendaevents.class.php
+++ b/htdocs/comm/action/class/api_agendaevents.class.php
@@ -289,7 +289,7 @@ class AgendaEvents extends DolibarrApi
*/
public function delete($id)
{
- if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) {
+ if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'delete')) {
throw new RestException(401, "Insufficient rights to delete your Agenda Event");
}
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 851f4419179..66d115c171c 100644
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -92,7 +92,7 @@ if ($user->socid && $socid) {
$result = restrictedArea($user, 'societe', $socid);
}
-$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create);
+$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
$permissiontoadd = $usercancreate;
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index d9089f03c14..461897ecab0 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -1875,7 +1875,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
}
} else {
if ($user->hasRight('agenda', 'allactions', 'create') ||
- (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
+ (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
$cssclass .= " movable cursormove";
} else {
$cssclass .= " unmovable";
diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php
index ee34d07ea4b..9d9baff3c3e 100644
--- a/htdocs/comm/action/info.php
+++ b/htdocs/comm/action/info.php
@@ -53,7 +53,7 @@ if ($user->socid && $socid) {
$result = restrictedArea($user, 'societe', $socid);
}
-$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create);
+$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
/*
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 342d0ba1a25..79330cd57bf 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -401,7 +401,7 @@ $arrayofmassactions = array(
if ($user->rights->agenda->allactions->delete) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
-if (isModEnabled('category') && $user->rights->agenda->myactions->create) {
+if (isModEnabled('category') && $user->hasRight('agenda', 'myactions', 'create')) {
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php
index 81e5cd0d9d2..fe6c733713b 100644
--- a/htdocs/comm/multiprix.php
+++ b/htdocs/comm/multiprix.php
@@ -54,7 +54,7 @@ $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid
* Actions
*/
-if ($action == 'setpricelevel' && $user->rights->societe->creer) {
+if ($action == 'setpricelevel' && $user->hasRight('societe', 'creer')) {
$soc = new Societe($db);
$soc->fetch($id);
$soc->setPriceLevel(GETPOST("price_level"), $user);
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 17231dde517..bc11bc8e4b1 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -2800,7 +2800,7 @@ if ($action == 'create') {
print '' . $langs->trans('AmountTTC') . ' ';
print '' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . ' ';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
- print '' . price($object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ' ';
+ print '' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ' ';
}
print ' ';
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index c9ca03380a0..e7d386e348a 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -68,7 +68,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permissiontocreate) {
//if ($user->rights->societe->creer)
- //if ($user->rights->facture->creer)
+ //if ($user->hasRight('facture', 'creer'))
$amount_ttc_1 = GETPOST('amount_ttc_1', 'alpha');
$amount_ttc_1 = price2num($amount_ttc_1);
@@ -159,7 +159,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi
if ($action == 'setremise' && $permissiontocreate) {
//if ($user->rights->societe->creer)
- //if ($user->rights->facture->creer)
+ //if ($user->hasRight('facture', 'creer'))
$amount = price2num(GETPOST('amount', 'alpha'), '', 2);
$desc = GETPOST('desc', 'alpha');
@@ -199,7 +199,7 @@ if ($action == 'setremise' && $permissiontocreate) {
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $permissiontocreate) {
//if ($user->rights->societe->creer)
- //if ($user->rights->facture->creer)
+ //if ($user->hasRight('facture', 'creer'))
$db->begin();
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 778df650514..2736bf80d64 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -2742,7 +2742,7 @@ if ($action == 'create' && $usercancreate) {
print '
' . price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ' ';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount TTC
- print '
' . price($object->total_ttc, 1, '', 1, -1, -1, $object->multicurrency_code) . ' ';
+ print '
' . price($object->multicurrency_total_ttc, 1, '', 1, -1, -1, $object->multicurrency_code) . ' ';
}
print '';
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 3ada37889db..6344bcec5d2 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -2089,7 +2089,7 @@ if ($resql) {
// If module invoices enabled and user with invoice creation permissions
if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
print '
';
print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').' ';
diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php
index c4610916e94..62122b71d52 100644
--- a/htdocs/commande/list_det.php
+++ b/htdocs/commande/list_det.php
@@ -1601,7 +1601,7 @@ if ($resql) {
// If module invoices enabled and user with invoice creation permissions
if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
print '
';
print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').' ';
diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php
index 8e7ccc4183f..33342098dbc 100644
--- a/htdocs/compta/bank/class/paymentvarious.class.php
+++ b/htdocs/compta/bank/class/paymentvarious.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018-2023 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ class PaymentVarious extends CommonObject
/**
* @var string ID to identify managed object
*/
- public $element = 'variouspayment';
+ public $element = 'payment_various';
/**
* @var string Name of table without prefix where object is stored
@@ -184,8 +184,6 @@ class PaymentVarious extends CommonObject
public function __construct(DoliDB $db)
{
$this->db = $db;
- $this->element = 'payment_various';
- $this->table_element = 'payment_various';
}
/**
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 4efbabbaf49..374280d4f8a 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -1229,7 +1229,7 @@ if ($action == 'create') {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
}
@@ -1684,7 +1684,7 @@ if ($action == 'create') {
),
);
if (empty($object->suspended)) {
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) {
print '';
} else {
@@ -1699,7 +1699,7 @@ if ($action == 'create') {
}
}
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
if (empty($object->suspended)) {
print '';
} else {
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 3580fa33e30..f1f69b76969 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -4801,7 +4801,6 @@ if ($action == 'create') {
if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) {
$sign = -1; // We invert sign for output
}
-
print '';
// Amount HT
print '' . $langs->trans('AmountHT') . ' ';
@@ -4849,7 +4848,7 @@ if ($action == 'create') {
print '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . ' ';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount TTC
- print '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ' ';
+ print '' . price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ' ';
}
print ' ';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 83836b24dec..5702c078aca 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -237,9 +237,15 @@ class Facture extends CommonInvoice
*/
public $lines = array();
+ /**
+ * @var FactureLigne
+ */
public $line;
public $extraparams = array();
+ /**
+ * @var int ID facture rec
+ */
public $fac_rec;
public $date_pointoftax;
@@ -4434,7 +4440,7 @@ class Facture extends CommonInvoice
$remise = 0;
}
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
$remise = price2num($remise, 2);
$error = 0;
@@ -4498,7 +4504,7 @@ class Facture extends CommonInvoice
$remise = 0;
}
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
$error = 0;
$this->db->begin();
@@ -6008,6 +6014,9 @@ class FactureLigne extends CommonInvoiceLine
*/
public $table_element = 'facturedet';
+ /**
+ * @var FactureLigne
+ */
public $oldline;
//! From llx_facturedet
@@ -6065,6 +6074,16 @@ class FactureLigne extends CommonInvoiceLine
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db handler d'acces base de donnee
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
+
/**
* Load invoice line from database
*
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 8625be6438e..56ef08d1f1e 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -854,7 +854,7 @@ while ($i < $imaxinloop) {
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
- if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) {
+ if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) {
if ($invoicerectmp->isMaxNbGenReached()) {
print $langs->trans("MaxNumberOfGenerationReached");
} elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
@@ -1044,7 +1044,7 @@ while ($i < $imaxinloop) {
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print ' ';
- if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) {
+ if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) {
if ($invoicerectmp->isMaxNbGenReached()) {
print $langs->trans("MaxNumberOfGenerationReached");
} elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php
index c3c774b79e7..84d9db320ef 100644
--- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php
+++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php
@@ -51,7 +51,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
date_when, 'day'); ?>
rights->facture->lire) {
+ if ($user->hasRight('facture', 'lire')) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
}
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index 865ce719291..69aa54365cf 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -537,7 +537,7 @@ print '';
if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
if ($user->socid == 0 && $object->statut == 0 && $action == '') {
- if ($user->rights->facture->paiement) {
+ if ($user->hasRight('facture', 'paiement')) {
print '
'.$langs->trans('Valid').' ';
}
}
diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php
index 8d89326d2c2..4a1d44b6c92 100644
--- a/htdocs/compta/payment_sc/card.php
+++ b/htdocs/compta/payment_sc/card.php
@@ -246,8 +246,7 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{
if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
{
- if ($user->rights->facture->paiement)
- {
+ if ($user->hasRight('facture', 'paiement')){
print '
'.$langs->trans('Valid').' ';
}
}
diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php
index eec0cff4d6f..bf4eb7ecaef 100644
--- a/htdocs/compta/payment_vat/card.php
+++ b/htdocs/compta/payment_vat/card.php
@@ -287,8 +287,7 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{
if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
{
- if ($user->rights->facture->paiement)
- {
+ if ($user->hasRight('facture', 'paiement')) {
print '
'.$langs->trans('Valid').' ';
}
}
diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
index 20be2b468b4..157e00c5c4a 100644
--- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php
+++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
@@ -110,7 +110,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
} else {
// Confirm delete contact
- if ($action == 'delete' && $user->rights->societe->contact->supprimer) {
+ if ($action == 'delete' && $user->hasRight('societe', 'contact', 'supprimer')) {
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $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 adf5bb722d3..127375b8c92 100644
--- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
+++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
@@ -142,7 +142,7 @@ if (empty($user->socid)) {
print '
control->tpl['id'].'&action=edit&token='.newToken().'&canvas='.$canvas.'">'.$langs->trans('Modify').' ';
}
- if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
+ if (!$this->control->tpl['user_id'] && $user->hasRight('user', 'user', 'creer')) {
print '
control->tpl['id'].'&action=create_user&token='.newToken().'&canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").' ';
}
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 739c4145db8..285201a574d 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -143,7 +143,7 @@ if (empty($reshook)) {
}
// Creation utilisateur depuis contact
- if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
+ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->hasRight('user', 'user', 'creer')) {
// Recuperation contact actuel
$result = $object->fetch($id);
@@ -313,7 +313,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) {
+ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'contact', 'supprimer')) {
$result = $object->fetch($id);
$object->oldcopy = clone $object;
@@ -1390,7 +1390,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '
';
print $langs->trans('ProspectLevel');
print ' ';
- if ($action != 'editlevel' && $user->rights->societe->contact->creer) {
+ if ($action != 'editlevel' && $user->hasRight('societe', 'contact', 'creer')) {
print ' id.'">'.img_edit($langs->trans('Modify'), 1).' ';
}
print '
';
@@ -1491,7 +1491,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $dolibarr_user->getLoginUrl(-1);
} else {
//print '
'.$langs->trans("NoDolibarrAccess").' ';
- if (!$object->user_id && $user->rights->user->user->creer) {
+ if (!$object->user_id && $user->hasRight('user', 'user', 'creer')) {
print '
'.img_picto($langs->trans("CreateDolibarrLogin"), 'add', 'class="pictofixedwidth"').$langs->trans("CreateDolibarrLogin").' ';
}
}
@@ -1527,11 +1527,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
// Activer
- if ($object->statut == 0 && $user->rights->societe->contact->creer) {
+ if ($object->statut == 0 && $user->hasRight('societe', 'contact', 'creer')) {
print '
'.$langs->trans("Reactivate").' ';
}
// Desactiver
- if ($object->statut == 1 && $user->rights->societe->contact->creer) {
+ if ($object->statut == 1 && $user->hasRight('societe', 'contact', 'creer')) {
print '
'.$langs->trans("DisableUser").' ';
}
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 2d64c5b8921..a9341cf5d63 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -847,7 +847,7 @@ $arrayofmassactions = array(
if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
-if (isModEnabled('category') && $user->rights->societe->creer) {
+if (isModEnabled('category') && $user->hasRight('societe', 'creer')) {
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
}
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index ba5fde87468..f2a05d0eb10 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -50,7 +50,7 @@ $errors = array();
* Action
*/
-if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact->creer) {
+if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'contact', 'creer')) {
$ret = $object->fetch($id);
// Note: Correct date should be completed with location to have exact GM time of birth.
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index d5d0858ab38..46b475fd5e8 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -2150,7 +2150,7 @@ if ($action == 'create') {
if (isModEnabled('facture') && $object->statut > 0) {
$langs->load("bills");
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params);
} else {
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index f051fe5ade3..47ad55399ad 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
- if ($user->hasRight('societe', 'lire') && $user->rights->societe->contact->lire) {
+ if ($user->hasRight('societe', 'lire') && $user->hasRight('societe', 'contact', 'lire')) {
$sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
$sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php
index 6a59c6f0d56..a724f26c0c3 100644
--- a/htdocs/core/boxes/box_factures.php
+++ b/htdocs/core/boxes/box_factures.php
@@ -87,7 +87,7 @@ class box_factures extends ModeleBoxes
'limit'=> dol_strlen($text)
);
- if ($user->rights->facture->lire) {
+ if ($user->hasRight('facture', 'lire')) {
$sql = "SELECT f.rowid as facid";
$sql .= ", f.ref, f.type, f.total_ht";
$sql .= ", f.total_tva";
diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php
index 06124d4ab35..ac05d51e607 100644
--- a/htdocs/core/boxes/box_factures_fourn.php
+++ b/htdocs/core/boxes/box_factures_fourn.php
@@ -84,7 +84,7 @@ class box_factures_fourn extends ModeleBoxes
'text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."SupplierBills", $max)
);
- if ($user->rights->fournisseur->facture->lire) {
+ if ($user->hasRight('fournisseur', 'facture', 'lire')) {
$langs->load("bills");
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php
index 34dc015a1db..96b9fc63d84 100644
--- a/htdocs/core/boxes/box_graph_invoices_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_permonth.php
@@ -103,7 +103,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
- if ($user->rights->facture->lire) {
+ if ($user->hasRight('facture', 'lire')) {
$mesg = '';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php
index 0f2c7bdb92f..915fb0336fe 100644
--- a/htdocs/core/boxes/box_graph_invoices_peryear.php
+++ b/htdocs/core/boxes/box_graph_invoices_peryear.php
@@ -95,7 +95,7 @@ class box_graph_invoices_peryear extends ModeleBoxes
if ($user->socid) $socid = $user->socid;
if (empty($user->rights->societe->client->voir) || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
- if ($user->rights->facture->lire) {
+ if ($user->hasRight('facture', 'lire')) {
$mesg = '';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
index 87952f008c8..b92862d5089 100644
--- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
@@ -102,7 +102,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
- if ($user->rights->fournisseur->facture->lire) {
+ if ($user->hasRight('fournisseur', 'facture', 'lire')) {
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php
index e9404254b0a..efee61607ba 100644
--- a/htdocs/core/boxes/box_members_by_tags.php
+++ b/htdocs/core/boxes/box_members_by_tags.php
@@ -93,7 +93,7 @@ class box_members_by_tags extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByTags").($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : ''));
- if ($user->rights->adherent->lire) {
+ if ($user->hasRight('adherent', 'lire')) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$stats = new AdherentStats($this->db, $user->socid, $user->id);
diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php
index 046c7031ece..72db5ec4f92 100644
--- a/htdocs/core/boxes/box_members_by_type.php
+++ b/htdocs/core/boxes/box_members_by_type.php
@@ -94,7 +94,7 @@ class box_members_by_type extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : ''));
- if ($user->rights->adherent->lire) {
+ if ($user->hasRight('adherent', 'lire')) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
$stats = new AdherentStats($this->db, $user->socid, $user->id);
// Show array
diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php
index 5c6082f1032..788695a1d36 100644
--- a/htdocs/core/boxes/box_members_last_modified.php
+++ b/htdocs/core/boxes/box_members_last_modified.php
@@ -90,7 +90,7 @@ class box_members_last_modified extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max));
- if ($user->rights->adherent->lire) {
+ if ($user->hasRight('adherent', 'lire')) {
$sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql .= " a.datec, a.tms as datem, a.statut as status, a.datefin as date_end_subscription,";
$sql .= ' a.photo, a.email, a.gender, a.morphy,';
diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php
index e7f1d99137d..324d0df218d 100644
--- a/htdocs/core/boxes/box_members_last_subscriptions.php
+++ b/htdocs/core/boxes/box_members_last_subscriptions.php
@@ -92,7 +92,7 @@ class box_members_last_subscriptions extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("LastSubscriptionsModified", $max));
- if ($user->rights->adherent->lire) {
+ if ($user->hasRight('adherent', 'lire')) {
$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql .= " a.gender, a.email, a.photo, a.morphy,";
$sql .= " a.datefin as date_end_subscription,";
diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php
index fe406ad29a3..f42ba94e688 100644
--- a/htdocs/core/boxes/box_members_subscriptions_by_year.php
+++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php
@@ -90,7 +90,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleMembersSubscriptionsByYear", $max));
- if ($user->rights->adherent->lire) {
+ if ($user->hasRight('adherent', 'lire')) {
$num = 0;
$line = 0;
// List of subscription by year
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index c602d13cbf7..cfe7527cb02 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -1324,7 +1324,8 @@ $(document).on('select2:open', (e) => {
console.log("Execute the focus (click on combo or use space when on component");
const target = $(e.target);
if (target && target.length) {
- const id = target[0].id || target[0].name;
+ let id = target[0].id || target[0].name;
+ if (id.substr(-2) == "[]") id = id.substr(0,id.length-2);
document.querySelector('input[aria-controls*='+id+']').focus();
}
});
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 5d34d5c243d..2f1082c7ca9 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3298,7 +3298,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
$htmllink .= '?chat" alt="'.$langs->trans("Chat").' '.$value.'" title="'.dol_escape_htmltag($langs->trans("Chat").' '.$value).'">';
$htmllink .= '
';
$htmllink .= '';
- if (($cid || $socid) && isModEnabled('agenda') && $user->rights->agenda->myactions->create) {
+ if (($cid || $socid) && isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'create')) {
$addlink = 'AC_SKYPE';
$link = '';
if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
@@ -3634,7 +3634,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
}
}
- //if (($cid || $socid) && isModEnabled('agenda') && $user->rights->agenda->myactions->create)
+ //if (($cid || $socid) && isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'create'))
if (isModEnabled('agenda') && $user->hasRight("agenda", "myactions", "create")) {
$type = 'AC_TEL';
$link = '';
diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php
index 453b34529b4..2f416e2e296 100644
--- a/htdocs/core/lib/modulebuilder.lib.php
+++ b/htdocs/core/lib/modulebuilder.lib.php
@@ -657,44 +657,28 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
$table .= "|".$attUnique;
}
$table .="\n";
- $countKeys = count($keys);
- for ($j=0;$j<$countKeys;$j++) {
- $string = $keys[$j];
+ foreach ($keys as $string) {
$string = trim($string, "'");
$string = rtrim($string, ",");
-
- $array = [];
- eval("\$array = [$string];");
+ $array = eval("return [$string];");
// check if is array after cleaning string
if (!is_array($array)) {
return -1;
}
- // name of field
- $field = array_keys($array);
- // all values of each property
- $values = array_values($array);
+ $field = array_keys($array);
+ $values = array_values($array)[0];
// check each field has all properties and add it if missed
- if (count($values[0]) <=22) {
- foreach ($attributesUnique as $cle) {
- if (!in_array($cle, array_keys($values[0]))) {
- $values[0][$cle] = '';
- }
+ foreach ($attributesUnique as $attUnique) {
+ if (!array_key_exists($attUnique, $values)) {
+ $values[$attUnique] = '';
}
}
- //reorganize $values with order attributeUnique
- $valuesRestructured = array();
- foreach ($attributesUnique as $key) {
- if (array_key_exists($key, $values[0])) {
- $valuesRestructured[$key] = $values[0][$key];
- }
- }
- // write all values of properties for each field
- $table .= "|*".$field[0]."*|";
- $table .= implode("|", array_values($valuesRestructured))."\n";
+ $table .= "|*" . $field[0] . "*|";
+ $table .= implode("|", $values) . "\n";
}
// end table
$table .= "|===";
@@ -780,8 +764,7 @@ function writePermsInAsciiDoc($file, $destfile)
$string .= "\n";
//content table
$array = explode(";", $content);
- $indexIgnored = 15;
- $permissions = array_slice($array, $indexIgnored, null, true);
+ $permissions = array_filter($array);
// delete occurrences "$r++" and ID
$permissions = str_replace('$r++', 1, $permissions);
@@ -806,21 +789,12 @@ function writePermsInAsciiDoc($file, $destfile)
array_pop($permsN);
// Group permissions by Object and add it to string
- $temp_array = [];
$final_array = [];
- $countRights = count($permsN);
- for ($i = 0; $i < $countRights ; $i++) {
- // Add current element to temporary array
- $temp_array[] = $permsN[$i];
- // add them to the final array and empty the temporary array
- if (count($temp_array) == 2) {
- $final_array[] = $temp_array;
- $temp_array = [];
- }
- }
- // add it to the final array
- if (count($temp_array) > 0) {
+ $index = 0;
+ while ($index < count($permsN)) {
+ $temp_array = [$permsN[$index], $permsN[$index + 1]];
$final_array[] = $temp_array;
+ $index += 2;
}
$result = array();
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index a2c45f725c3..17b6d17114a 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -608,13 +608,13 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
}
} elseif (!empty($feature2)) { // This is for permissions on 2 levels (module->object->write)
foreach ($feature2 as $subfeature) {
- if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) {
+ if ($subfeature == 'user' && $user->id == $objectid && $user->hasRight('user', 'self', 'creer')) {
continue; // User can edit its own card
}
- if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) {
+ if ($subfeature == 'user' && $user->id == $objectid && $user->hasRight('user', 'self', 'password')) {
continue; // User can edit its own password
}
- if ($subfeature == 'user' && $user->id != $objectid && $user->rights->user->user->password) {
+ if ($subfeature == 'user' && $user->id != $objectid && $user->hasRight('user', 'user', 'password')) {
continue; // User can edit another user's password
}
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index 8058deb387b..552881fd6cc 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -40,7 +40,7 @@ function user_prepare_head(User $object)
$canreadperms = true;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
- $canreadperms = ($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
+ $canreadperms = ($user->admin || ($user->id != $object->id && $user->hasRight('user', 'user_advance', 'readperms')) || ($user->id == $object->id && $user->hasRight('user', 'self_advance', 'readperms')));
}
$h = 0;
diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php
index 25e0f914807..e4258d45aba 100644
--- a/htdocs/core/tpl/contacts.tpl.php
+++ b/htdocs/core/tpl/contacts.tpl.php
@@ -151,7 +151,7 @@ if ($permission) {
$nbofcontacts = $form->num;
$newcardbutton = '';
- if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) {
+ if (!empty($object->socid) && $object->socid > 1 && $user->hasRight('societe', 'creer')) {
$newcardbutton .= '
id).'" title="'.$langs->trans('NewContact').'"> ';
}
print $newcardbutton;
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 90a04aedf58..2073d0bfd40 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -2593,7 +2593,7 @@ if ($action == 'create') {
// Create bill
if (isModEnabled('facture') && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED)) {
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
// TODO show button only if (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))
// If we do that, we must also make this option official.
print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 1108bd7446b..ba1f1d05046 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -1660,7 +1660,7 @@ if ($action == 'create') {
if (isModEnabled('facture') && $object->statut > Fichinter::STATUS_DRAFT) {
$langs->load("bills");
if ($object->statut < Fichinter::STATUS_BILLED) {
- if ($user->rights->facture->creer) {
+ if ($user->hasRight('facture', 'creer')) {
print '
';
} else {
print '
';
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 4a88ee02fca..62de4dc4eca 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -807,7 +807,7 @@ if ($object->id > 0) {
$langs->load('bills');
$facturestatic = new FactureFournisseur($db);
- if ($user->rights->fournisseur->facture->lire) {
+ if ($user->hasRight('fournisseur', 'facture', 'lire')) {
// TODO move to DAO class
$sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc, f.paye,';
$sql .= ' SUM(pf.amount) as am';
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 731480db581..194a5db4f5d 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -2600,7 +2600,7 @@ if ($action == 'create') {
//if (isModEnabled('facture'))
//{
if (isModEnabled("supplier_invoice") && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled
- if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
+ if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->rights->supplier_invoice->creer) {
print '
'.$langs->trans("CreateBill").' ';
}
}
@@ -2612,7 +2612,7 @@ if ($action == 'create') {
print '
id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("ClassifyBilled").' ';
} else {
if (!empty($object->linkedObjectsIds['invoice_supplier'])) {
- if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
+ if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->rights->supplier_invoice->creer) {
print '
id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("ClassifyBilled").' ';
}
} else {
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index 776c1e62fe2..6d667f76b8d 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -1184,7 +1184,7 @@ if ($resql) {
}
}
- if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
+ if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->rights->supplier_invoice->creer) {
$arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
}
if ($permissiontodelete) {
diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php
index b957726f69e..684c7d01b11 100644
--- a/htdocs/fourn/facture/list-rec.php
+++ b/htdocs/fourn/facture/list-rec.php
@@ -873,7 +873,7 @@ if ($resql) {
}
// Action column
print '
';
- if ($user->rights->facture->creer && empty($supplierinvoicerectmp->suspended)) {
+ if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) {
if ($supplierinvoicerectmp->isMaxNbGenReached()) {
print $langs->trans("MaxNumberOfGenerationReached");
} elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
index e9ec8accf30..86ba45c5f48 100644
--- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
@@ -51,7 +51,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
ref_supplier; ?>
date, 'day'); ?>
rights->fournisseur->facture->lire) {
+ if ($user->hasRight('fournisseur', 'facture', 'lire')) {
$sign = 1;
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
$sign = -1;
diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php
index b1118374237..cafff521df7 100644
--- a/htdocs/fourn/paiement/card.php
+++ b/htdocs/fourn/paiement/card.php
@@ -373,7 +373,7 @@ if ($result > 0) {
// Delete payment
if ($user->socid == 0 && $action == '') {
- if ($user->rights->fournisseur->facture->supprimer) {
+ if ($user->hasRight('fournisseur', 'facture', 'supprimer')) {
if ($allow_delete) {
print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
} else {
diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php
index 029f1bd2308..b369a363625 100644
--- a/htdocs/fourn/product/list.php
+++ b/htdocs/fourn/product/list.php
@@ -141,7 +141,7 @@ $arrayofmassactions = array(
'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
-if ($user->rights->mymodule->supprimer) {
+if ($user->hasRight('mymodule', 'supprimer')) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php
index 495b095fb4d..dcb743f5a6a 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_card.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_card.php
@@ -211,7 +211,7 @@ if ($action == 'create') {
print ' ';
print $langs->trans($object->fields['answer']['label']).' ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, 0, true, ROWS_9, '100%');
+ $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
$out = $doleditor->Create(1);
print $out;
@@ -276,7 +276,7 @@ if (($id || $ref) && $action == 'edit') {
print ' ';
print $langs->trans($object->fields['answer']['label']).' ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, 0, true, ROWS_9, '100%');
+ $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
$out = $doleditor->Create(1);
print $out;
@@ -453,7 +453,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print ' ';
print $langs->trans($object->fields['answer']['label']).' ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, 0, true, ROWS_9, '100%', 1);
+ $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%', 1);
$out = $doleditor->Create(1);
print $out;
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 1ca41cadfb7..1fe46109c61 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -316,6 +316,7 @@ ErrorFixThisHere=Fix this here
ErrorTheUrlOfYourDolInstanceDoesNotMatchURLIntoOAuthSetup=Error: The URL of you current instance (%s) does not match the URL defined into your OAuth2 login setup (%s). Doing OAuth2 login in such a configuration is not allowed.
ErrorMenuExistValue=A Menu already exist with this Title or URL
ErrorSVGFilesNotAllowedAsLinksWithout=SVG files are not allowed as external links without option %s
+ErrorTypeMenu=Impossible to add another menu for the same module on the navbar, not handle yet
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 14bf3e959f5..cee77697d33 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -312,6 +312,7 @@ ErrorEqualModule=Module invalide dans %s .
ErrorFieldValue=La valeur pour %s est incorrecte
ErrorCoherenceMenu=Le champ %s est requis lorsque %s vaut 'left'
ErrorMenuExistValue=Un menu existe déjà avec ce titre ou cette URL
+ErrorTypeMenu=Impossible de rajouter un autre menu sur la navbar pour le même module ,pas encore traité
# Warnings
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 99d2bf28bbd..d6527adc0a8 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1473,7 +1473,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
'mon module'=>$module,
'Mon module'=>$module,
'htdocs/modulebuilder/template/'=>strtolower($modulename),
- //'myobject'=>strtolower($objectname),
+ 'myobject'=>strtolower($objectname),
'MyObject'=>$objectname,
//'MYOBJECT'=>strtoupper($objectname),
'---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '')
@@ -2499,6 +2499,10 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) {
setEventMessages($langs->trans("ErrorCoherenceMenu", $langs->transnoentities("leftmenu"), $langs->transnoentities("type")), null, 'errors');
}
}
+ if (GETPOST('type', 'alpha') == 'top') {
+ $error++;
+ setEventMessages($langs->trans("ErrorTypeMenu", $langs->transnoentities("type")), null, 'errors');
+ }
$moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
if (!$error) {
@@ -2599,6 +2603,11 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int')) {
} else {
$menuModify['enabled'] = "0";
}
+
+ if (GETPOST('type', 'alpha') == 'top') {
+ $error++;
+ setEventMessages($langs->trans("ErrorTypeMenu", $langs->transnoentities("type")), null, 'errors');
+ }
if (!$error) {
//update menu
$result = reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php
index 2b79d0dfcea..9a09b4d70b7 100644
--- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php
@@ -296,7 +296,7 @@ class ActionsMyModule
global $user;
if ($parameters['features'] == 'myobject') {
- if ($user->rights->mymodule->myobject->read) {
+ if ($user->hasRight('mymodule', 'myobject', 'read')) {
$this->results['result'] = 1;
return 1;
} else {
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index bcf72d401ae..934908254ae 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -268,21 +268,26 @@ class modMyModule extends DolibarrModules
$r = 0;
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
- $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ /*$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = 'Read objects of MyModule'; // Permission label
$this->rights[$r][4] = 'myobject';
- $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read)
+ $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight('mymodule', 'myobject', 'read'))
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label
$this->rights[$r][4] = 'myobject';
- $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->write)
+ $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight('mymodule', 'myobject', 'write'))
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label
$this->rights[$r][4] = 'myobject';
+
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete)
- $r++;
+ $r++;*/
+
+
+
+
/* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add
diff --git a/htdocs/modulebuilder/template/doc/Documentation.asciidoc b/htdocs/modulebuilder/template/doc/Documentation.asciidoc
index a6dc59eea14..e649ad16fe2 100644
--- a/htdocs/modulebuilder/template/doc/Documentation.asciidoc
+++ b/htdocs/modulebuilder/template/doc/Documentation.asciidoc
@@ -37,7 +37,7 @@ This document was generated using Dolibarr ERP CRM process
:toc: manual
:toc-placement: preamble
-<<<
+
== INTRODUCTION
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 56872c26289..a443753a8a7 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -149,19 +149,19 @@ foreach ($object->fields as $key => $val) {
}
// List of fields to search into when doing a "search in all"
-$fieldstosearchall = array();
-foreach ($object->fields as $key => $val) {
- if (!empty($val['searchall'])) {
- $fieldstosearchall['t.'.$key] = $val['label'];
- }
-}
-$parameters = array('fieldstosearchall'=>$fieldstosearchall);
-$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook > 0) {
- $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
-} elseif ($reshook == 0) {
- $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
-}
+// $fieldstosearchall = array();
+// foreach ($object->fields as $key => $val) {
+// if (!empty($val['searchall'])) {
+// $fieldstosearchall['t.'.$key] = $val['label'];
+// }
+// }
+// $parameters = array('fieldstosearchall'=>$fieldstosearchall);
+// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+// if ($reshook > 0) {
+// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
+// } elseif ($reshook == 0) {
+// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
+// }
// Definition of array of fields for columns
$arrayfields = array();
diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php
index ba0f2c2a1ab..58e2fac591d 100644
--- a/htdocs/partnership/class/partnership_type.class.php
+++ b/htdocs/partnership/class/partnership_type.class.php
@@ -95,7 +95,7 @@ class PartnershipType extends CommonObject
}
// Example to show how to set values of fields definition dynamically
- /*if ($user->rights->mymodule->myobject->read) {
+ /*if ($user->hasRight('mymodule', 'myobject', 'read')) {
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 672d7575e3f..0b57af620e3 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -242,7 +242,7 @@ if (empty($reshook)) {
$action = '';
}
// merge products
- if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) {
+ if ($action == 'confirm_merge' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
$error = 0;
$productOriginId = GETPOST('product_origin', 'int');
$productOrigin = new Product($db);
diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php
index 349b41584d4..ab95a3c6e48 100644
--- a/htdocs/product/stats/facture_fournisseur.php
+++ b/htdocs/product/stats/facture_fournisseur.php
@@ -137,7 +137,7 @@ if ($id > 0 || !empty($ref)) {
print dol_get_fiche_end();
- if ($user->rights->fournisseur->facture->lire) {
+ if ($user->hasRight('fournisseur', 'facture', 'lire')) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,";
$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle as label, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty";
if (empty($user->rights->societe->client->voir) && !$socid) {
diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php
index 149a6aacf41..74cca76c6c2 100644
--- a/htdocs/product/stats/facturerec.php
+++ b/htdocs/product/stats/facturerec.php
@@ -154,7 +154,7 @@ if ($id > 0 || !empty($ref)) {
if ($showmessage && $nboflines > 1) {
print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).' ';
- } elseif ($user->rights->facture->lire) {
+ } elseif ($user->hasRight('facture', 'lire')) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
$sql .= "f.titre, f.datec, f.rowid as facid, f.suspended as suspended,";
$sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 9dc6090c3d7..ceb3fb11c5f 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -630,7 +630,7 @@ $listofreferent = array(
'lang'=>'agenda',
'buttonnew'=>'AddEvent',
'testnew'=>$user->rights->agenda->myactions->create,
- 'test'=> isModEnabled('agenda') && $user->rights->agenda->myactions->read),
+ 'test'=> isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'read')),
*/
);
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
index 7b28d571bc5..d532d7cd117 100644
--- a/htdocs/reception/list.php
+++ b/htdocs/reception/list.php
@@ -860,7 +860,7 @@ $arrayofmassactions = array(
// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
-if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
+if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->rights->supplier_invoice->creer) {
$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisReceptions");
}
if ($massaction == 'createbills') {
diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php
index 80558b67e49..af6983e26c6 100644
--- a/htdocs/recruitment/recruitmentcandidature_card.php
+++ b/htdocs/recruitment/recruitmentcandidature_card.php
@@ -201,7 +201,7 @@ if (empty($reshook)) {
}
// Create user from a member
- if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
+ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->hasRight('user', 'user', 'creer')) {
$jobposition = new RecruitmentJobPosition($db);
$jobposition->fetch($object->fk_recruitmentjobposition);
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index 75e53fc72c2..db9201852d5 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -188,7 +188,7 @@ if (empty($reshook)) {
$action = '';
}
- if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) {
+ if ($action == 'confirm_merge' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
$error = 0;
$soc_origin_id = GETPOST('soc_origin', 'int');
$soc_origin = new Societe($db);
@@ -413,7 +413,7 @@ if (empty($reshook)) {
// Add new or update third party
if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode'))
- && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) {
+ && ($action == 'add' || $action == 'update') && $user->hasRight('societe', 'creer')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!GETPOST('name')) {
@@ -933,31 +933,31 @@ if (empty($reshook)) {
}
// Set third-party type
- if ($action == 'set_thirdpartytype' && $user->rights->societe->creer) {
+ if ($action == 'set_thirdpartytype' && $user->hasRight('societe', 'creer')) {
$object->fetch($socid);
$result = $object->setThirdpartyType(GETPOST('typent_id', 'int'));
}
// Set incoterm
- if ($action == 'set_incoterms' && $user->rights->societe->creer && isModEnabled('incoterm')) {
+ if ($action == 'set_incoterms' && $user->hasRight('societe', 'creer') && isModEnabled('incoterm')) {
$object->fetch($socid);
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// Set parent company
- if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
+ if ($action == 'set_thirdparty' && $user->hasRight('societe', 'creer')) {
$object->fetch($socid);
$result = $object->setParent(GETPOST('parent_id', 'int'));
}
// Set sales representatives
- if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) {
+ if ($action == 'set_salesrepresentatives' && $user->hasRight('societe', 'creer')) {
$object->fetch($socid);
$result = $object->setSalesRep(GETPOST('commercial', 'array'));
}
// warehouse
- if ($action == 'setwarehouse' && $user->rights->societe->creer) {
+ if ($action == 'setwarehouse' && $user->hasRight('societe', 'creer')) {
$result = $object->setWarehouse(GETPOST('fk_warehouse', 'int'));
}
@@ -3192,7 +3192,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $dolibarr_user->getLoginUrl(-1);
} else {
//print ''.$langs->trans("NoDolibarrAccess").' ';
- if (!$object->user_id && $user->rights->user->user->creer) {
+ if (!$object->user_id && $user->hasRight('user', 'user', 'creer')) {
print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").' ';
}
}
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index c25713959d2..9a4b95afade 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -147,7 +147,7 @@ if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print ' '.$langs->trans('Prefix').' '.$object->prefix_comm.' ';
}
-//if (isModEnabled('agenda') && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
+//if (isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'read')) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
$elementTypeArray = array();
if ($object->client) {
diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php
index f626139abcb..03530c2449a 100644
--- a/htdocs/societe/societecontact.php
+++ b/htdocs/societe/societecontact.php
@@ -78,7 +78,7 @@ $hookmanager->initHooks(array('contactthirdparty', 'globalcard'));
* Actions
*/
-if ($action == 'addcontact' && $user->rights->societe->creer) {
+if ($action == 'addcontact' && $user->hasRight('societe', 'creer')) {
$result = $object->fetch($id);
if ($result > 0 && $id > 0) {
@@ -98,14 +98,14 @@ if ($action == 'addcontact' && $user->rights->societe->creer) {
$mesg = '
'.$object->error.'
';
}
}
-} elseif ($action == 'swapstatut' && $user->rights->societe->creer) {
+} elseif ($action == 'swapstatut' && $user->hasRight('societe', 'creer')) {
// bascule du statut d'un contact
if ($object->fetch($id)) {
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
} else {
dol_print_error($db);
}
-} elseif ($action == 'deletecontact' && $user->rights->societe->creer) {
+} elseif ($action == 'deletecontact' && $user->hasRight('societe', 'creer')) {
// Efface un contact
$object->fetch($id);
$result = $object->delete_contact(GETPOST("lineid", 'int'));
diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php
index 8c467882a01..1a5a93bbabd 100644
--- a/htdocs/societe/website.php
+++ b/htdocs/societe/website.php
@@ -349,7 +349,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
-if ($user->rights->mymodule->delete) {
+if ($user->hasRight('mymodule', 'delete')) {
$arrayofmassactions['predelete'] = '
'.$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 676dd851400..cd0f51df4d3 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -1862,7 +1862,7 @@ if ($action == 'create') {
print '
' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . ' ';
if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount TTC
- print '
' . price($object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ' ';
+ print '
' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ' ';
}
print '';
diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php
index 334ea7cd1ab..f10309d08ca 100644
--- a/htdocs/ticket/class/cticketcategory.class.php
+++ b/htdocs/ticket/class/cticketcategory.class.php
@@ -194,7 +194,7 @@ class CTicketCategory extends CommonObject
}
// Example to show how to set values of fields definition dynamically
- /*if ($user->rights->mymodule->myobject->read) {
+ /*if ($user->hasRight('mymodule', 'myobject', 'read')) {
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php
index 7923a4127c4..f594dd02176 100644
--- a/htdocs/user/agenda_extsites.php
+++ b/htdocs/user/agenda_extsites.php
@@ -61,7 +61,7 @@ $socid = 0;
if ($user->socid > 0) {
$socid = $user->socid;
}
-$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
+$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php
index fc7efd23749..8038fab4ece 100644
--- a/htdocs/user/bank.php
+++ b/htdocs/user/bank.php
@@ -61,7 +61,7 @@ $socid = 0;
if ($user->socid > 0) {
$socid = $user->socid;
}
-$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
+$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
$object = new User($db);
if ($id > 0 || !empty($ref)) {
@@ -287,7 +287,7 @@ if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer ||
print '
';
print '
';
}
-if ($id && $action == 'create' && $user->rights->user->user->creer) {
+if ($id && $action == 'create' && $user->hasRight('user', 'user', 'creer')) {
if ($conf->use_javascript_ajax) {
print "\n