diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 1f3d8d56cd6..8c46be39826 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -446,7 +446,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/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 101bd33ea6f..8d227b7ce1b 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -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/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/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/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/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 '
' . $langs->trans("CreateBill") . '
'; } else { @@ -1699,7 +1699,7 @@ if ($action == 'create') { } } - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { if (empty($object->suspended)) { print '
id.'&token='.newToken().'">'.$langs->trans("Disable").'
'; } else { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 83836b24dec..164ff6bd696 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4434,7 +4434,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 +4498,7 @@ class Facture extends CommonInvoice $remise = 0; } - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { $error = 0; $this->db->begin(); 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/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_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/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 '
'.$langs->trans("AddBill").'
'; } else { print '
'.$langs->trans("AddBill").'
'; 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 ''.$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 ''.$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/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..9eeb0559364 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -271,17 +271,17 @@ class modMyModule extends DolibarrModules $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) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->hasRight('mymodule', 'myobject', 'delete')) $r++; /* END MODULEBUILDER PERMISSIONS */ 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/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/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/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/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; }*/