From fa849696fb4cc76df97953c1f31db50e024b5f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:16:02 +0200 Subject: [PATCH 01/15] use isModEnabled --- htdocs/comm/propal/card.php | 2 +- htdocs/core/boxes/box_actions.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 16 +++++++------- htdocs/core/modules/modAgenda.class.php | 22 +++++++++---------- htdocs/core/modules/modECM.class.php | 2 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modService.class.php | 6 ++--- .../doc/doc_generic_project_odt.modules.php | 2 +- .../project/doc/pdf_beluga.modules.php | 2 +- ...terface_50_modAgenda_ActionsAuto.class.php | 2 +- htdocs/fichinter/card-rec.php | 8 +++---- htdocs/fichinter/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card-rec.php | 4 ++-- htdocs/fourn/facture/card.php | 2 +- htdocs/mrp/class/mo.class.php | 2 +- htdocs/product/admin/price_rules.php | 6 ++--- htdocs/product/admin/product.php | 6 ++--- htdocs/product/admin/product_extrafields.php | 4 ++-- .../admin/product_supplier_extrafields.php | 4 ++-- htdocs/product/index.php | 4 ++-- htdocs/projet/element.php | 2 +- htdocs/projet/tasks/time.php | 6 ++--- htdocs/public/agenda/agendaexport.php | 2 +- .../societe/class/api_thirdparties.class.php | 2 +- htdocs/societe/consumption.php | 2 +- htdocs/workstation/workstation_agenda.php | 4 ++-- 28 files changed, 61 insertions(+), 61 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 356e28ccc31..3a3fdfe50a0 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2904,7 +2904,7 @@ if ($action == 'create') { } } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print '' . $langs->trans("AddAction") . ''; }*/ diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index a47f5d4f744..7b149ba4085 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -60,7 +60,7 @@ class box_actions extends ModeleBoxes $this->db = $db; - $this->enabled = $conf->agenda->enabled; + $this->enabled = isModEnabled('agenda'); $this->hidden = !($user->hasRight('agenda', 'myactions', 'read')); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d2294f781ab..d927c4588b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3584,7 +3584,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } } - //if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + //if (($cid || $socid) && isModEnabled('agenda') && $user->rights->agenda->myactions->create) if (isModEnabled('agenda') && $user->hasRight("agenda", "myactions", "create")) { $type = 'AC_TEL'; $link = ''; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index d77ed72c8db..9c2a54ff2a5 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -13,7 +13,7 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; -- old: (module, enabled, rowid, ...) insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 1__+MAX_llx_menu__, '', '1', __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModeEnabled('supplier_order') || isModEnabled('supplier_invoice')))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', '$conf->product->enabled || $conf->service->enabled', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', 'isModEnabled("product") || isModEnabled("service")', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 16__+MAX_llx_menu__, 'bom|mrp', '$conf->bom->enabled || $conf->mrp->enabled', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->rights->bom->read||$user->rights->mrp->read', '', 0, 31, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 7__+MAX_llx_menu__, 'projet', '$conf->project->enabled', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 32, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 5__+MAX_llx_menu__, 'propal|commande|fournisseur|supplier_order|supplier_invoice|contrat|ficheinter', '$conf->propal->enabled || $conf->commande->enabled || $conf->supplier_order->enabled || $conf->contrat->enabled || $conf->ficheinter->enabled', __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 40, __ENTITY__); @@ -115,10 +115,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && $conf->categorie->enabled', __HANDLER__, 'left', 671__+MAX_llx_menu__, 'companies', '', 670__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=4', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Product - Product -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'products', 'product', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=product&type=0', 'Products', 0, 'products', '$user->rights->produit->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=product&action=create&type=0', 'NewProduct', 1, 'products', '$user->rights->produit->creer', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?mainmenu=products&type=0', 'MenuStocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'products', 'product', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=product&type=0', 'Products', 0, 'products', '$user->rights->produit->lire', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=product&action=create&type=0', 'NewProduct', 1, 'products', '$user->rights->produit->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?mainmenu=products&type=0', 'MenuStocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?mainmenu=products&type=0&search_subjecttolotserial=1', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2806__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php?mainmenu=products', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__); @@ -127,9 +127,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?mainmenu=products&id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 8, __ENTITY__); -- Product - Services -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("service")', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("service")', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("service")', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?mainmenu=products&id=all&leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__); -- Product - Stocks diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 38debb8633a..4c2b86e59b7 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -113,7 +113,7 @@ class modAgenda extends DolibarrModules //------------ $datestart = dol_now(); $this->cronjobs = array( - 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart), + 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'isModEnabled("agenda")', 'datestart'=>$datestart), ); // Permissions @@ -212,7 +212,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>86, 'perms'=>'$user->rights->agenda->myactions->read || $user->rights->resource->read', - 'enabled'=>'$conf->agenda->enabled || $conf->resource->enabled', + 'enabled'=>'isModEnabled("agenda") || $conf->resource->enabled', 'target'=>'', 'user'=>2, ); @@ -228,7 +228,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>100, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2, ); @@ -242,7 +242,7 @@ class modAgenda extends DolibarrModules 'langs'=>'commercial', 'position'=>101, 'perms'=>'($user->hasRight("agenda", "myactions", "create")||$user->hasRight("agenda", "allactions", "create"))', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -257,7 +257,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>140, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -271,7 +271,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>141, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -285,7 +285,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>142, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -329,7 +329,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>110, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -343,7 +343,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>111, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -357,7 +357,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>112, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -400,7 +400,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>160, 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 09556b43cd8..3dbd624bb51 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -127,7 +127,7 @@ class modECM extends DolibarrModules 'langs'=>'ecm', 'position'=>82, 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup', - 'enabled'=>'$conf->ecm->enabled', + 'enabled'=>'isModEnabled("ecm")', 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 247069f8401..d8192a37df4 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -168,7 +168,7 @@ class modProduct extends DolibarrModules 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>300, - 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index d323bf382ef..4828513a8ff 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -135,7 +135,7 @@ class modService extends DolibarrModules 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>300, - 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both @@ -284,7 +284,7 @@ class modService extends DolibarrModules $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" } - if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) + if (!isModEnabled("product")) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice $r++; @@ -705,7 +705,7 @@ class modService extends DolibarrModules $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled } - if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) + if (!isModEnabled("product")) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 653d40e9ef6..af807516c30 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -1048,7 +1048,7 @@ class doc_generic_project_odt extends ModelePDFProjects 'class' => 'ActionComm', 'table' => 'actioncomm', 'disableamount' => 1, - 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire + 'test' => isModEnabled('agenda') && $user->rights->agenda->allactions->lire ), ); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index ba175dc7c52..525c3bd2ece 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -462,7 +462,7 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, + 'test'=> isModEnabled('agenda') && $user->rights->agenda->allactions->read, 'lang'=>'agenda') ); diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 71e0d18fc99..f0e019a82e1 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -76,7 +76,7 @@ class InterfaceActionsAuto extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->agenda) || empty($conf->agenda->enabled)) { + if (!isModEnabled('agenda')) { return 0; // Module not active, we do nothing } diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index de6d5f97c24..75b1c944192 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -398,9 +398,9 @@ if ($action == 'create') { print '
'; $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) { + if (!isModEnabled("service")) { $title = $langs->trans("Products"); - } elseif (empty($conf->product->enabled)) { + } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } @@ -709,9 +709,9 @@ if ($action == 'create') { */ $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) { + if (!isModEnabled("service")) { $title = $langs->trans("Products"); - } elseif (empty($conf->product->enabled)) { + } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a4244195bfa..64c6d399966 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1643,7 +1643,7 @@ if ($action == 'create') { } // Proposal - if ($conf->service->enabled && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) { + if (isModEnabled("service") && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED) { if ($user->rights->propal->creer) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 2aeb13d762c..dff3ed98858 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2462,7 +2462,7 @@ if ($action == 'create') { } } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print '
' . $langs->trans("AddAction") . '
'; }*/ diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index fb8179f2042..1e08deb7fd0 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -1059,9 +1059,9 @@ if ($action == 'create') { print dol_get_fiche_end(); $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) { + if (!isModEnabled("service")) { $title = $langs->trans("Products"); - } elseif (empty($conf->product->enabled)) { + } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 393c32e500a..bfd0f1a184a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3946,7 +3946,7 @@ if ($action == 'create') { } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print '
' . $langs->trans("AddAction") . '
'; }*/ diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 100043ef055..0c93e2dd835 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -100,7 +100,7 @@ class Mo extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1), 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:(t.status:=:1)', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>'$conf->bom->enabled', 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300', 'csslist'=>'nowraponall', 'picto'=>'bom'), 'mrptype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>34, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth150', 'csslist'=>'minwidth150 center'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'$conf->product->enabled', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'isModEnabled("product")', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'2', 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200', 'alwayseditable'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'css'=>'maxwidth400', 'csslist'=>'tdoverflowmax150'), diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index 4fa0c293b2d..561c8d48e90 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -30,7 +30,7 @@ $langs->loadLangs(array('admin', 'products')); $action = GETPOST('action', 'aZ09'); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { +if (!$user->admin || (!isModEnabled("product") && !isModEnabled("service"))) { accessforbidden(); } @@ -119,10 +119,10 @@ while ($result = $db->fetch_object($query)) { $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $tab = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $tab = $langs->trans('Products'); } diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index f6e0d42bfe4..f79b8ab982e 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -41,7 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $langs->loadLangs(array("admin", "products")); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { +if (!$user->admin || (!isModEnabled("product") && !isModEnabled("service"))) { accessforbidden(); } @@ -271,10 +271,10 @@ $formbarcode = new FormBarCode($db); $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $tab = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $tab = $langs->trans('Products'); } diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php index 4885c595097..d5b97555ba4 100644 --- a/htdocs/product/admin/product_extrafields.php +++ b/htdocs/product/admin/product_extrafields.php @@ -66,10 +66,10 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $title = $langs->trans('ProductServiceSetup'); $textobject = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $textobject = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $textobject = $langs->trans('Products'); } diff --git a/htdocs/product/admin/product_supplier_extrafields.php b/htdocs/product/admin/product_supplier_extrafields.php index afd46f104ae..6469c3d9b42 100644 --- a/htdocs/product/admin/product_supplier_extrafields.php +++ b/htdocs/product/admin/product_supplier_extrafields.php @@ -67,10 +67,10 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $title = $langs->trans('ProductServiceSetup'); $textobject = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $textobject = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $textobject = $langs->trans('Products'); } diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 32a07ae40d4..d31e365295f 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -73,11 +73,11 @@ if (!isset($_GET["type"])) { $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } -if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled)) { +if ((isset($_GET["type"]) && $_GET["type"] == 0) || !isModEnabled("service")) { $transAreaType = $langs->trans("ProductsArea"); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } -if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled)) { +if ((isset($_GET["type"]) && $_GET["type"] == 1) || !isModEnabled("product")) { $transAreaType = $langs->trans("ServicesArea"); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 1d264548b11..98f841013ba 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -629,7 +629,7 @@ $listofreferent = array( 'lang'=>'agenda', 'buttonnew'=>'AddEvent', 'testnew'=>$user->rights->agenda->myactions->create, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->myactions->read), + 'test'=> isModEnabled('agenda') && $user->rights->agenda->myactions->read), */ ); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index fbec220b671..0da51607eb8 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1458,7 +1458,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; print ''; - if ($conf->service->enabled) { + if (isModEnabled("service")) { print ''; print ''; print $langs->trans('ServiceToUseOnLines'); @@ -1750,7 +1750,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; - if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + if (isModEnabled("service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { print ''.$langs->trans("Product").''; } } @@ -1829,7 +1829,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; print ''; - if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + if (isModEnabled("service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { print ''; print img_picto('', 'product'); print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1); diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index e8d9f986f91..e9bca76cdbc 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -84,7 +84,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; // Security check -if (empty($conf->agenda->enabled)) { +if (!isModEnabled('agenda')) { httponly_accessforbidden('Module Agenda not enabled'); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 8552f257fcc..e0386ddd1c6 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -577,7 +577,7 @@ class Thirdparties extends DolibarrApi throw new RestException(501, 'Module "Thirdparties" needed for this request'); } - if (empty($conf->product->enabled)) { + if (!isModEnabled("product")) { throw new RestException(501, 'Module "Products" needed for this request'); } diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 07436ae6140..5b993769449 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 ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); +//if (isModEnabled('agenda') && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); if ($object->client) { print ''; diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index a3036ad19c7..d665f1efcc4 100644 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -222,7 +222,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled)) { + if (isModEnabled('agenda')) { if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { @@ -232,7 +232,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); From 15c60e29f41ed996ba7cecf5a40ed5be068084be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:18:47 +0200 Subject: [PATCH 02/15] use isModEnabled --- htdocs/core/modules/modAgenda.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 4c2b86e59b7..20a2016939f 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -212,7 +212,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>86, 'perms'=>'$user->rights->agenda->myactions->read || $user->rights->resource->read', - 'enabled'=>'isModEnabled("agenda") || $conf->resource->enabled', + 'enabled'=>'isModEnabled("agenda") || isModEnabled("resource")', 'target'=>'', 'user'=>2, ); From a38a303e1ce34f3b1b23b3ce064716814fb83c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:23:34 +0200 Subject: [PATCH 03/15] use isModEnabled --- htdocs/commande/list_det.php | 4 ++-- htdocs/contrat/list.php | 4 ++-- .../modules/mailings/advthirdparties.modules.php | 2 +- .../core/modules/mailings/thirdparties.modules.php | 2 +- htdocs/core/modules/modTicket.class.php | 14 +++++++------- htdocs/projet/activity/perday.php | 3 +-- htdocs/projet/activity/permonth.php | 3 +-- htdocs/projet/activity/perweek.php | 3 +-- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/user/card.php | 2 +- 11 files changed, 19 insertions(+), 22 deletions(-) diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 78f7c687175..c0855371f6d 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -875,7 +875,7 @@ if ($resql) { $moreforfilter .= ''; } // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled("categorie") && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -883,7 +883,7 @@ if ($resql) { $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); $moreforfilter .= '
'; } - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + if (isModEnabled("categorie") && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a671297b0de..c51a4398cf1 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -if (!empty($conf->categorie->enabled)) { +if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -701,7 +701,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->right $moreforfilter .= '
'; } // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 6137bcca2ff..ced14b802a0 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -253,7 +253,7 @@ class mailing_advthirdparties extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - if (empty($conf->categorie->enabled)) { + if (!isModEnabled("categorie")) { $num = 0; // Force empty list if category module is not enabled } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index f34eb600228..53cba7c915f 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -295,7 +295,7 @@ class mailing_thirdparties extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - if (empty($conf->categorie->enabled)) { + if (!isModEnabled("categorie")) { $num = 0; // Force empty list if category module is not enabled } diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 67c27178987..01ae671bad7 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -157,7 +157,7 @@ class modTicket extends DolibarrModules 'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"), 'tabfieldinsert' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"), 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"), - 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled && getDolGlobalString('TICKET_ENABLE_RESOLUTION')), + 'tabcond' => array(isModEnabled("ticket"), isModEnabled("ticket"), isModEnabled("ticket"), isModEnabled("ticket") && getDolGlobalString('TICKET_ENABLE_RESOLUTION')), 'tabhelp' => array( array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), @@ -238,7 +238,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/index.php', 'langs' => 'ticket', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position' => 88, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules 'target' => '', 'user' => 2); // 0=Menu for internal users, 1=external users, 2=both @@ -253,7 +253,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/index.php', 'langs' => 'ticket', 'position' => 101, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 2); @@ -266,7 +266,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/card.php?action=create', 'langs' => 'ticket', 'position' => 102, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->write', 'target' => '', 'user' => 2); @@ -280,7 +280,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/list.php?search_fk_status=non_closed', 'langs' => 'ticket', 'position' => 103, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 2); @@ -294,7 +294,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed', 'langs' => 'ticket', 'position' => 105, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 0); @@ -307,7 +307,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/stats/index.php', 'langs' => 'ticket', 'position' => 107, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 0); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 5438ea6e47f..9c4e47037c2 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -495,8 +495,7 @@ print '
'; $moreforfilter = ''; // Filter on categories -/*if (!empty($conf->categorie->enabled)) -{ +/*if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index e6226ca677c..bff135b713f 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -410,8 +410,7 @@ $moreforfilter = ''; // Filter on categories /* -if (!empty($conf->categorie->enabled)) -{ +if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b3aa85e6226..1d3a6ef3c2c 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -546,8 +546,7 @@ $moreforfilter = ''; // Filter on categories /* - if (!empty($conf->categorie->enabled)) - { + if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 17f4d66168b..92cbda347ae 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1006,7 +1006,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire) { $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx'); } // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index adf86b7ac49..b922b1cbed6 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -806,7 +806,7 @@ $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form- $moreforfilter .= '
'; // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_TASK_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_TASK_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index cafb1ae847b..570b78f7604 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -353,7 +353,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; // Go back to create page } else { - if (!empty($conf->categorie->enabled)) { + if (isModEnabled("categorie")) { // Categories association $usercats = GETPOST('usercats', 'array'); $object->setCategories($usercats); From 7760ba86dabee47c985bbd1019f56991acc5164c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:33:36 +0200 Subject: [PATCH 04/15] use isModEnabled --- .../template/class/myobject.class.php | 2 +- .../core/modules/modMyModule.class.php | 18 +++++++++--------- ...e_99_modMyModule_MyModuleTriggers.class.php | 2 +- .../modulebuilder/template/mymoduleindex.php | 4 ++-- .../template/myobject_contact.php | 3 +-- .../template/myobject_document.php | 3 +-- .../modulebuilder/template/myobject_note.php | 3 +-- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d57a1fca39f..dac32970ae6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -121,7 +121,7 @@ class MyObject extends CommonObject 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1), 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'OrganizationEventLinkToThirdParty', 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'isModEnabled("project")', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1, 'cssview'=>'wordbreak'), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1, 'cssview'=>'wordbreak'), diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 2788c78fc37..e8f3f26772b 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -221,7 +221,7 @@ class modMyModule extends DolibarrModules // Name of columns with primary key (try to always name it 'rowid') 'tabrowid'=>array("rowid", "rowid", "rowid"), // Condition to show each dictionary - 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled), + 'tabcond'=>array(isModEnabled('mymodule'), isModEnabled('mymodule'), isModEnabled('mymodule')), // Tooltip for every fields of dictionaries: DO NOT PUT AN EMPTY ARRAY 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), ...), ); @@ -252,13 +252,13 @@ class modMyModule extends DolibarrModules // 'frequency' => 2, // 'unitfrequency' => 3600, // 'status' => 0, - // 'test' => '$conf->mymodule->enabled', + // 'test' => 'isModEnabled("mymodule")', // 'priority' => 50, // ), ); // Example: $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'isModEnabled("mymodule")', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'isModEnabled("mymodule")', 'priority'=>50) // ); // Permissions provided by this module @@ -437,11 +437,11 @@ class modMyModule extends DolibarrModules // Create extrafields during init //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('mymodule_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result2=$extrafields->addExtraField('mymodule_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result3=$extrafields->addExtraField('mymodule_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result4=$extrafields->addExtraField('mymodule_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result1=$extrafields->addExtraField('mymodule_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result2=$extrafields->addExtraField('mymodule_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result3=$extrafields->addExtraField('mymodule_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result4=$extrafields->addExtraField('mymodule_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); // Permissions $this->remove($options); diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index c51bc01376c..9420c83b8c0 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -90,7 +90,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->mymodule) || empty($conf->mymodule->enabled)) { + if (!isModEnabled('mymodule')) { return 0; // If module is not enabled, we do nothing } diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 3b7b1b13009..3c7cc5f9ec5 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -186,8 +186,8 @@ END MODULEBUILDER DRAFT MYOBJECT */ print '
'; -$NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; +$NBMAX = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); +$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT // Last modified myobject diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 9568201238c..4f384a006e5 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -175,8 +175,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) - { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index ff1756e2b15..7ffa467cdc0 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -193,8 +193,7 @@ $morehtmlref = '
'; // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) - { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 1f3bf7c9fd4..584a7ccd9e3 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -168,8 +168,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) - { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) From 40c5be6f7fb01e57bef049e1ccfa7ce7ef49b92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:37:07 +0200 Subject: [PATCH 05/15] use isModEnabled --- htdocs/modulebuilder/template/myobject_agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index c752dd41632..81d8c93f240 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -211,7 +211,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { From cfa10bb8ba27e31f33dbdfac43a1fbab4ee965ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:40:07 +0200 Subject: [PATCH 06/15] use isModEnabled --- .../modulebuilder/template/core/boxes/mymodulewidget1.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 7ea4b553e71..ace98374461 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -101,8 +101,10 @@ class mymodulewidget1 extends ModeleBoxes $this->param = $param; - //$this->enabled = $conf->global->FEATURES_LEVEL > 0; // Condition when module is enabled or not - //$this->hidden = ! ($user->rights->mymodule->myobject->read); // Condition when module is visible by user (test on permission) + // Condition when module is enabled or not + // $this->enabled = getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0; + // Condition when module is visible by user (test on permission) + // $this->hidden = !$user->hasRight('mymodule', 'myobject', 'read'); } /** From 1cb2a9afd1dca313a6ce7958d12623620ea1ea68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:49:27 +0200 Subject: [PATCH 07/15] fix doc --- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/mrp/class/mo.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e10139f3711..f3975e58125 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1732,8 +1732,8 @@ class BOMLine extends CommonObjectLine */ public $childBom = array(); - /* - * Service Workstation + /** + * @var int Service Workstation */ public $fk_default_workstation; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 44775b996b6..46b33051fd9 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1744,8 +1744,8 @@ class MoLine extends CommonObjectLine public $import_key; public $fk_parent_line; - /* - * Service Workstation + /** + * @var int Service Workstation */ public $fk_default_workstation; From 77441f2dd2d72e9ef669f9a802a613b8ca049d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 23:39:02 +0200 Subject: [PATCH 08/15] use isModEnabled --- htdocs/core/lib/functions.lib.php | 14 +++++++------- htdocs/core/tpl/login.tpl.php | 4 ++-- htdocs/core/tpl/passwordforgotten.tpl.php | 4 ++-- htdocs/core/tpl/passwordreset.tpl.php | 4 ++-- htdocs/public/demo/index.php | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d927c4588b2..8b722efd411 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3801,22 +3801,22 @@ function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $char // TODO Remove this block, we can add this using the hook now $showgmap = $showomap = 0; - if (($element == 'thirdparty' || $element == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) { + if (($element == 'thirdparty' || $element == 'societe') && isModEnabled('google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) { $showgmap = 1; } - if ($element == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { + if ($element == 'contact' && isModEnabled('google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { $showgmap = 1; } - if ($element == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { + if ($element == 'member' && isModEnabled('google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { $showgmap = 1; } - if (($element == 'thirdparty' || $element == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { + if (($element == 'thirdparty' || $element == 'societe') && isModEnabled('openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { $showomap = 1; } - if ($element == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { + if ($element == 'contact' && isModEnabled('openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { $showomap = 1; } - if ($element == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { + if ($element == 'member' && isModEnabled('openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { $showomap = 1; } if ($showgmap) { @@ -9779,7 +9779,7 @@ function printCommonFooter($zone = 'private') // Google Analytics // TODO Add a hook here - if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { + if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index a1045beedb9..71c8b33c5a3 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -447,7 +447,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Remove this, and add content into hook getLoginPageExtraOptions() instead -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -468,7 +468,7 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { ?>

diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index deec94ee004..f43a2c63d9e 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -287,7 +287,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Remove this, and add content into hook getPasswordForgottenPageExtraOptions() instead -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -308,7 +308,7 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { ?>

diff --git a/htdocs/core/tpl/passwordreset.tpl.php b/htdocs/core/tpl/passwordreset.tpl.php index e3202ff511f..3b1bed10338 100644 --- a/htdocs/core/tpl/passwordreset.tpl.php +++ b/htdocs/core/tpl/passwordreset.tpl.php @@ -328,7 +328,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Remove this, and add content into hook getPasswordForgottenPageExtraOptions() instead -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -349,7 +349,7 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { ?>

diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index f7274d5b06b..c71f1d86dc7 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -434,7 +434,7 @@ print '
'; // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { print '
'."\n"; print '