From 46012a65202fa040a453b5af3a76a5504a7b1351 Mon Sep 17 00:00:00 2001 From: hystepik Date: Tue, 16 May 2023 15:36:27 +0200 Subject: [PATCH] fix : php 8.1 warnings --- htdocs/compta/facture/agenda.php | 2 +- htdocs/compta/facture/prelevement.php | 4 ++-- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/product.lib.php | 10 +++++----- htdocs/product/agenda.php | 2 +- htdocs/product/card.php | 6 +++--- htdocs/product/document.php | 2 +- htdocs/product/list.php | 28 +++++++++++++-------------- htdocs/product/note.php | 2 +- htdocs/product/price.php | 14 +++++++------- htdocs/product/stats/facture.php | 2 +- htdocs/projet/card.php | 22 ++++++++++----------- htdocs/projet/document.php | 2 +- htdocs/projet/element.php | 2 +- htdocs/projet/list.php | 20 +++++++++---------- htdocs/projet/messaging.php | 2 +- htdocs/projet/note.php | 2 +- htdocs/projet/tasks.php | 8 ++++---- htdocs/variants/list.php | 6 +++--- 19 files changed, 70 insertions(+), 70 deletions(-) diff --git a/htdocs/compta/facture/agenda.php b/htdocs/compta/facture/agenda.php index 45f495c1723..2442f9ce662 100644 --- a/htdocs/compta/facture/agenda.php +++ b/htdocs/compta/facture/agenda.php @@ -194,7 +194,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('paymentbagendaybanktransfer', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''."\n"; $buttonlabel = $langs->trans("MakeWithdrawRequest"); - $user_perms = $user->rights->prelevement->bons->creer; + $user_perms = $user->hasRight('prelevement', 'bons', 'creer'); if ($type == 'bank-transfer') { $buttonlabel = $langs->trans("MakeBankTransferOrder"); - $user_perms = $user->rights->paymentbybanktransfer->create; + $user_perms = $user->hasRight('paymentbybanktransfer', 'create'); } // Add a transfer request diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c566b09ebf9..0e4cbe516f2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2340,14 +2340,14 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } elseif ($object->element == 'product') { //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; - if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->hasRight('produit', 'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { $morehtmlstatus .= ''.$object->getLibStatut(6, 0).''; } $morehtmlstatus .= '   '; //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; - if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->hasRight('produit', 'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 408f661e2b9..aedd01805dc 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -130,7 +130,7 @@ function product_prepare_head($object) } if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { // If physical product we can stock (or service with option) - if (isModEnabled('stock') && $user->rights->stock->lire) { + if (isModEnabled('stock') && $user->hasRight('stock', 'lire')) { $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; $head[$h][1] = $langs->trans("Stock"); $head[$h][2] = 'stock'; @@ -457,7 +457,7 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier proposals - if (isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->lire) { + if (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire')) { $nblines++; $ret = $product->load_stats_proposal_supplier($socid); if ($ret < 0) { @@ -495,7 +495,7 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier orders - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) { + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire'))) { $nblines++; $ret = $product->load_stats_commande_fournisseur($socid); if ($ret < 0) { @@ -552,7 +552,7 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier invoices - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) { + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { $nblines++; $ret = $product->load_stats_facture_fournisseur($socid); if ($ret < 0) { @@ -592,7 +592,7 @@ function show_stats_for_company($product, $socid) } // BOM - if (isModEnabled('bom') && $user->rights->bom->read) { + if (isModEnabled('bom') && $user->hasRight('bom', 'read')) { $nblines++; $ret = $product->load_stats_bom($socid); if ($ret < 0) { diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index 84dcbbf2ab9..671b74a2714 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -191,7 +191,7 @@ if ($id > 0 || $ref) { $out = ''; $morehtmlcenter = ''; if (isModEnabled('agenda')) { - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) { if (get_class($objproduct) == 'Product') { $out .= '&prodid='.$objproduct->id.'&origin=product&originid='.$id; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 50ac40b545a..99071758252 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -194,9 +194,9 @@ if ($object->id > 0) { $hookmanager->initHooks(array('productcard', 'globalcard')); // Permissions -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); -$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'read')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); +$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'supprimer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'supprimer'))); /* diff --git a/htdocs/product/document.php b/htdocs/product/document.php index af75cbc71ce..9b6876150d2 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -113,7 +113,7 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -$permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); /* diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 644a4a80912..1847bdae10a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -244,10 +244,10 @@ $arrayfields = array( 'p.numbuyprice'=>array('label'=>"BuyingPriceNumShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>43), 'p.pmp'=>array('label'=>"PMPValueShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>44), 'p.cost_price'=>array('label'=>"CostPrice", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>45), - 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>50), - 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>51), - 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>52), - 'stock_virtual'=>array('label'=>"VirtualStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical), 'position'=>53), + 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>50), + 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>51), + 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>52), + 'stock_virtual'=>array('label'=>"VirtualStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical), 'position'=>53), 'p.tobatch'=>array('label'=>"ManageLotSerial", 'checked'=>0, 'enabled'=>(isModEnabled('productbatch')), 'position'=>60), 'p.fk_country'=>array('label'=>"Country", 'checked'=>0, 'position'=>100), 'p.fk_state'=>array('label'=>"State", 'checked'=>0, 'position'=>101), @@ -373,9 +373,9 @@ if (empty($reshook)) { $objectlabel = 'Products'; } - $permissiontoread = $user->rights->{$rightskey}->lire; - $permissiontodelete = $user->rights->{$rightskey}->supprimer; - $permissiontoadd = $user->rights->{$rightskey}->creer; + $permissiontoread = $user->hasRight($rightskey, 'lire'); + $permissiontodelete = $user->hasRight($rightskey, 'supprimer'); + $permissiontoadd = $user->hasRight($rightskey, 'creer'); $uploaddir = $conf->product->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -807,15 +807,15 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($user->rights->{$rightskey}->supprimer) { +if ($user->hasRight($rightskey, 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if ($user->rights->{$rightskey}->creer) { +if ($user->hasRight($rightskey, 'creer')) { $arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus"); $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice"); } -if (isModEnabled('category') && $user->rights->{$rightskey}->creer) { +if (isModEnabled('category') && $user->hasRight($rightskey, 'creer')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields', 'preupdateprice'))) { @@ -828,11 +828,11 @@ $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars i $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($type === "") { - $perm = ($user->rights->produit->creer || $user->rights->service->creer); + $perm = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); } elseif ($type == Product::TYPE_SERVICE) { - $perm = $user->rights->service->creer; + $perm = $user->hasRight('service', 'creer'); } elseif ($type == Product::TYPE_PRODUCT) { - $perm = $user->rights->produit->creer; + $perm = $user->hasRight('produit', 'creer'); } $oldtype = $type; $params = array(); @@ -1510,7 +1510,7 @@ while ($i < $imaxinloop) { } // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. - if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock + if ((isModEnabled('stock') && $user->hasRight('stock', 'lire') && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock if ($product_static->type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service $option = 'nobatch'; if (empty($arrayfields['stock_virtual']['checked'])) { diff --git a/htdocs/product/note.php b/htdocs/product/note.php index 8354fa96029..a3f02813ee0 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -50,7 +50,7 @@ if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); } -$permissionnote = ($user->rights->produit->creer || $user->rights->service->creer); // Used by the include of actions_setnotes.inc.php +$permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index c573a2a26c6..2c583fda1db 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1333,12 +1333,12 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been if (empty($reshook)) { if ($object->isVariant()) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print '
' . $langs->trans("UpdateDefaultPrice") . '
'; } } else { if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print '
' . $langs->trans("UpdateDefaultPrice") . '
'; } else { print '
' . $langs->trans("UpdateDefaultPrice") . '
'; @@ -1346,7 +1346,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a } if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print '
id . '">' . $langs->trans("AddCustomerPrice") . '
'; } else { print '
' . $langs->trans("AddCustomerPrice") . '
'; @@ -1354,13 +1354,13 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a } if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print '
' . $langs->trans("UpdateVAT") . '
'; } else { print '
' . $langs->trans("UpdateVAT") . '
'; } - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print '
' . $langs->trans("UpdateLevelPrices") . '
'; } else { print '
' . $langs->trans("UpdateLevelPrices") . '
'; @@ -1378,7 +1378,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a * Edit price area */ -if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'edit_vat' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print load_fiche_titre($langs->trans("UpdateVAT"), ''); print '
'; @@ -2339,7 +2339,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''.price($object->price_min_ttc).''; print ''; print ''; - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { + if ($user->hasRight('produit', 'supprimer') || $user->hasRight('service', 'supprimer')) { print ''; print 'id.'">'; print img_info($langs->trans('PriceByCustomerLog')); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 2bdb1ad6d4a..c5209b725b5 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -153,7 +153,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.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; $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/card.php b/htdocs/projet/card.php index ea7c3e51d35..1d2f0817c20 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -104,9 +104,9 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti accessforbidden(); } -$permissiontoadd = $user->rights->projet->creer; -$permissiontodelete = $user->rights->projet->supprimer; -$permissiondellink = $user->rights->projet->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('projet', 'creer'); +$permissiontodelete = $user->hasRight('projet', 'supprimer'); +$permissiondellink = $user->hasRight('projet', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -1504,7 +1504,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // Back to draft if (!getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') && !getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT')) { - if ($object->statut != Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($object->statut != Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_setdraft&confirm=yes&token='.newToken().'&id='.$object->id, ''); } else { @@ -1514,7 +1514,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Modify - if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { + if ($object->statut != Project::STATUS_CLOSED && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, ''); } else { @@ -1523,7 +1523,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Validate - if ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($object->statut == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); } else { @@ -1570,7 +1570,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Clone - if ($user->rights->projet->creer) { + if ($user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id, ''); } else { @@ -1579,8 +1579,8 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Delete - if ($user->rights->projet->supprimer || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { - if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { + if ($user->hasRight('projet', 'supprimer') || ($object->statut == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer'))) { + if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer'))) { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false); @@ -1605,8 +1605,8 @@ if ($action == 'create' && $user->rights->projet->creer) { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->project->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->projet->lire && $userAccess > 0); - $delallowed = ($user->rights->projet->creer && $userWrite > 0); + $genallowed = ($user->hasRight('projet', 'lire') && $userAccess > 0); + $delallowed = ($user->hasRight('projet', 'creer') && $userWrite > 0); print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', '', '', $object); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 4e7620476c4..19ecebb2214 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -84,7 +84,7 @@ $socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); -$permissiontoadd = $user->rights->projet->creer; +$permissiontoadd = $user->hasRight('projet', 'creer'); /* diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index c72dcbccda8..daadc99410a 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -492,7 +492,7 @@ $listofreferent = array( 'lang'=>'sendings', 'buttonnew'=>'CreateShipment', 'testnew'=>0, - 'test'=>$conf->expedition->enabled && $user->rights->expedition->lire), + 'test'=>$conf->expedition->enabled && $user->hasRight('expedition', 'lire')), 'mrp'=>array( 'name'=>"MO", 'title'=>"ListMOAssociatedProject", diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 4d751918432..5d96adbd7fb 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -317,14 +317,14 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Project'; $objectlabel = 'Project'; - $permissiontoread = $user->rights->projet->lire; - $permissiontodelete = $user->rights->projet->supprimer; - $permissiontoadd = $user->rights->projet->creer; + $permissiontoread = $user->hasRight('projet', 'lire'); + $permissiontodelete = $user->hasRight('projet', 'supprimer'); + $permissiontoadd = $user->hasRight('projet', 'creer'); $uploaddir = $conf->project->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Close records - if (!$error && $massaction == 'close' && $user->rights->projet->creer) { + if (!$error && $massaction == 'close' && $user->hasRight('projet', 'creer')) { $db->begin(); $objecttmp = new $objectclass($db); @@ -903,14 +903,14 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->projet->creer) { +if ($user->hasRight('projet', 'creer')) { $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close"); $arrayofmassactions['preaffectuser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AffectUser"); } -if ($user->rights->projet->supprimer) { +if ($user->hasRight('projet', 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (isModEnabled('category') && $user->rights->projet->creer) { +if (isModEnabled('category') && $user->hasRight('projet', 'creer')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preaffectuser'))) { @@ -930,7 +930,7 @@ if ($search_usage_event_organization == 1) { $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('projet', 'creer')); print ''; if ($optioncss != '') { @@ -950,7 +950,7 @@ $texthelp = ''; if ($search_project_user == $user->id) { $texthelp .= $langs->trans("MyProjectsDesc"); } else { - if ($user->rights->projet->all->lire && !$socid) { + if ($user->hasRight('projet', 'all', 'lire') && !$socid) { $texthelp .= $langs->trans("ProjectsDesc"); } else { $texthelp .= $langs->trans("ProjectsPublicDesc"); @@ -1001,7 +1001,7 @@ if ($user->rights->user->user->lire) { } // Filter on categories -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $formcategory = new FormCategory($db); $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx'); } diff --git a/htdocs/projet/messaging.php b/htdocs/projet/messaging.php index 09e49c41c0f..807008c78c5 100644 --- a/htdocs/projet/messaging.php +++ b/htdocs/projet/messaging.php @@ -161,7 +161,7 @@ print dol_get_fiche_end(); // Actions buttons $out = ''; -$permok = $user->rights->agenda->myactions->create; +$permok = $user->hasRight('agenda', 'myactions', 'create'); if ($permok) { $out .= '&projectid='.$object->id; } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 3ca7949b35a..dd4672fa98b 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -50,7 +50,7 @@ $socid = 0; $hookmanager->initHooks(array('projetnote')); $result = restrictedArea($user, 'projet', $id, 'projet&project'); -$permissionnote = $user->rights->projet->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('projet', 'creer'); // Used by the include of actions_setnotes.inc.php /* diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index f0f98e3df6c..742867781f5 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -240,8 +240,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Task'; $objectlabel = 'Tasks'; - $permissiontoread = $user->rights->projet->lire; - $permissiontodelete = $user->rights->projet->supprimer; + $permissiontoread = $user->hasRight('projet', 'lire'); + $permissiontodelete = $user->hasRight('projet', 'supprimer'); $uploaddir = $conf->project->dir_output.'/tasks'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -555,7 +555,7 @@ if ($id > 0 || !empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array(); - if ($user->rights->projet->creer) { + if ($user->hasRight('projet', 'creer')) { $arrayofmassactions['preclonetasks'] = img_picto('', 'rightarrow', 'class="pictofixedwidth"').$langs->trans("Clone"); } if ($permissiontodelete) { @@ -853,7 +853,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Link to create task $linktocreatetaskParam = array(); $linktocreatetaskUserRight = false; - if ($user->rights->projet->all->creer || $user->rights->projet->creer) { + if ($user->hasRight('projet', 'all', 'creer') || $user->hasRight('projet', 'creer')) { if ($object->public || $userWrite > 0) { $linktocreatetaskUserRight = true; } else { diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 47a2087e3bf..6b27a567ec9 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -140,9 +140,9 @@ $arrayfields['nb_products'] = array( $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->variants->read; -$permissiontoadd = $user->rights->variants->write; -$permissiontodelete = $user->rights->variants->delete; +$permissiontoread = $user->hasRight('variants', 'read'); +$permissiontoadd = $user->hasRight('variants', 'write'); +$permissiontodelete = $user->hasRight('variants', 'delete'); // Security check if (!isModEnabled('variants')) {