From c674f00cb2b76eb9f3a819169e647eccc72036e4 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 15:27:42 +0200 Subject: [PATCH 1/6] Use isModEnabled --- htdocs/api/class/api_setup.class.php | 2 +- htdocs/api/index.php | 2 +- htdocs/bom/class/bom.class.php | 2 +- htdocs/bom/tpl/objectline_create.tpl.php | 2 +- htdocs/bom/tpl/objectline_title.tpl.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 9c7cc01630d..406172590d7 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1441,7 +1441,7 @@ class Setup extends DolibarrApi { global $conf; - if (empty($conf->socialnetworks->enabled)) { + if (!isModEnabled('socialnetworks')) { throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 4c0d36fdcfe..0abf864084d 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -237,7 +237,7 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $ // Defined if module is enabled $enabled = true; - if (empty($conf->$modulenameforenabled->enabled)) { + if (!isModEnabled($modulenameforenabled)) { $enabled = false; } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index af14185b3d0..d15de486560 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1376,7 +1376,7 @@ class BOM extends CommonObject $unit = measuringUnitString($line->fk_unit, '', '', 1); $qty = convertDurationtoHour($line->qty, $unit); - if ($conf->workstation->enabled && !empty($tmpproduct->fk_default_workstation)) { + if (isModEnabled('workstation') && !empty($tmpproduct->fk_default_workstation)) { $workstation = new Workstation($this->db); $res = $workstation->fetch($tmpproduct->fk_default_workstation); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 41aeec4b96f..0243928116e 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -84,7 +84,7 @@ if ($nolinesbefore) { print '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ''; } else { print '' . $form->textwithpicto($langs->trans('Unit'), '').''; - if ($conf->workstation->enabled) print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ''; + if (isModEnabled('workstation')) print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ''; print '' . $form->textwithpicto($langs->trans('TotalCost'), '') . ''; } diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index f93fb59fe0d..5252baf61ca 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -85,7 +85,7 @@ if ($filtertype != 1) { } else { print '' . $form->textwithpicto($langs->trans('Unit'), '').''; - if ($conf->workstation->enabled) print '' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . ''; + if (isModEnabled('workstation')) print '' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . ''; // Cost print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).''; From d06fef47f8e8a14ed9c17139d06ddb423d25d5b8 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 15:28:36 +0200 Subject: [PATCH 2/6] Use isModEnabled --- htdocs/bom/tpl/objectline_view.tpl.php | 4 ++-- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/action/class/cactioncomm.class.php | 8 ++++---- htdocs/comm/propal/list.php | 10 +++++----- htdocs/commande/card.php | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index a3b9df0bdf0..e4636081655 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -144,8 +144,8 @@ if ($filtertype != 1) { print ''; - //Poste de travail - if ($conf->workstation->enabled) { + // Work station + if (isModEnabled('workstation')) { $workstation = new Workstation($object->db); $res = $workstation->fetch($tmpproduct->fk_default_workstation); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 571815fb615..45dbbbf12c0 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2355,7 +2355,7 @@ class ActionComm extends CommonObject $nbMailSend = 0; $errorsMsg = array(); - if (empty($conf->agenda->enabled)) { // Should not happen. If module disabled, cron job should not be visible. + if (!isModEnabled('agenda')) { // Should not happen. If module disabled, cron job should not be visible. $langs->load("agenda"); $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda")); return 0; diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 2d57cfe1284..0942e1554a8 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -207,10 +207,10 @@ class CActionComm if ($obj->module == 'propal' && isModEnabled("propal") && !empty($user->rights->propale->lire)) { $qualified = 1; } - if ($obj->module == 'invoice_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (!empty($conf->rights->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire)))) { + if ($obj->module == 'invoice_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (isModEnabled('supplier_invoice') && !empty($user->rights->supplier_invoice->lire)))) { $qualified = 1; } - if ($obj->module == 'order_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (empty($conf->rights->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)))) { + if ($obj->module == 'order_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (!isModEnabled('supplier_order') && !empty($user->rights->supplier_order->lire)))) { $qualified = 1; } if ($obj->module == 'shipping' && isModEnabled("expedition") && !empty($user->rights->expedition->lire)) { @@ -228,7 +228,7 @@ class CActionComm $tmpobject = $regs[1]; $tmpmodule = $regs[2]; //var_dump($user->$tmpmodule); - if ($tmpmodule && isset($conf->$tmpmodule) && !empty($conf->$tmpmodule->enabled) && (!empty($user->rights->$tmpmodule->read) || !empty($user->rights->$tmpmodule->lire) || !empty($user->rights->$tmpmodule->$tmpobject->read) || !empty($user->rights->$tmpmodule->$tmpobject->lire))) { + if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule) && (!empty($user->rights->$tmpmodule->read) || !empty($user->rights->$tmpmodule->lire) || !empty($user->rights->$tmpmodule->$tmpobject->read) || !empty($user->rights->$tmpmodule->$tmpobject->lire))) { $qualified = 1; } } @@ -237,7 +237,7 @@ class CActionComm if (! in_array($obj->type, array('system', 'systemauto', 'module', 'moduleauto'))) { $tmpmodule = $obj->module; //var_dump($tmpmodule); - if ($tmpmodule && isset($conf->$tmpmodule) && !empty($conf->$tmpmodule->enabled)) { + if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule)) { $qualified = 1; } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 63399aa7a34..5b678a0f7ac 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; } require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -237,10 +237,10 @@ $arrayfields = array( 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>isModEnabled("multicurrency") && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>-1), - 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ddaaa57eeba..882d2d38cc7 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1866,7 +1866,7 @@ if ($action == 'create' && $usercancreate) { } // Incoterms - if (!empty($conf->incoterm->enabled)) { + if (isModEnabled('incoterm')) { print ''; print ''; print ''; @@ -2113,7 +2113,7 @@ if ($action == 'create' && $usercancreate) { // It may also break step of creating an order when invoicing must be done from proposals and not from orders $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); - if (!empty($deposit_percent_from_payment_terms) && !empty($conf->facture->enabled) && !empty($user->rights->facture->creer)) { + if (!empty($deposit_percent_from_payment_terms) && isModEnabled('facture') && !empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $object->fetchObjectLinked(); @@ -2610,7 +2610,7 @@ if ($action == 'create' && $usercancreate) { // TODO How record was recorded OrderMode (llx_c_input_method) // Incoterms - if (!empty($conf->incoterm->enabled)) { + if (isModEnabled('incoterm')) { print ''; $editenable = $usercancreate; print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); @@ -2697,7 +2697,7 @@ if ($action == 'create' && $usercancreate) { print ''; // Margin Infos - if (!empty($conf->margin->enabled)) { + if (isModEnabled('margin')) { $formmargin->displayMarginInfos($object); } @@ -2809,7 +2809,7 @@ if ($action == 'create' && $usercancreate) { print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=modif&token='.newToken().'&id='.$object->id, ''); } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) + /*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 @@ -2937,7 +2937,7 @@ if ($action == 'create' && $usercancreate) { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) { $useonlinepayment = 0; } From e6e058a71360e3ceda7de873bbaeeaefd8d9c17b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 15:30:16 +0200 Subject: [PATCH 3/6] Use isModEnabled --- htdocs/core/class/html.form.class.php | 36 +++++++++---------- htdocs/ecm/index_auto.php | 32 ++++++++--------- htdocs/ecm/search.php | 24 ++++++------- htdocs/expedition/class/expedition.class.php | 4 +-- .../class/fournisseur.commande.class.php | 2 +- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7913c1d1ef7..50ce856dec2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1105,7 +1105,7 @@ class Form // If product & services are enabled or both disabled. if ($forceall == 1 || (empty($forceall) && isModEnabled("product") && isModEnabled("service")) - || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) { + || (empty($forceall) && !isModEnabled('product') && !isModEnabled('service'))) { if (empty($hidetext)) { print $langs->trans("Type").': '; } @@ -1134,11 +1134,11 @@ class Form print ajax_combobox('select_'.$htmlname); //if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); } - if ((empty($forceall) && empty($conf->product->enabled) && isModEnabled("service")) || $forceall == 3) { + if ((empty($forceall) && !isModEnabled('product') && isModEnabled("service")) || $forceall == 3) { print $langs->trans("Service"); print ''; } - if ((empty($forceall) && isModEnabled("product") && empty($conf->service->enabled)) || $forceall == 2) { + if ((empty($forceall) && isModEnabled("product") && !isModEnabled('service')) || $forceall == 2) { print $langs->trans("Product"); print ''; } @@ -2280,9 +2280,9 @@ class Form } if (strval($filtertype) === '' && (isModEnabled("product") || isModEnabled("service"))) { - if (isModEnabled("product") && empty($conf->service->enabled)) { + if (isModEnabled("product") && !isModEnabled('service')) { $filtertype = '0'; - } elseif (empty($conf->product->enabled) && isModEnabled("service")) { + } elseif (!isModEnabled('product') && isModEnabled("service")) { $filtertype = '1'; } } @@ -2299,9 +2299,9 @@ class Form } // handle case where product or service module is disabled + no filter specified if ($filtertype == '') { - if (empty($conf->product->enabled)) { // when product module is disabled, show services only + if (!isModEnabled('product')) { // when product module is disabled, show services only $filtertype = 1; - } elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only + } elseif (!isModEnabled('service')) { // when service module is disabled, show products only $filtertype = 0; } } @@ -2647,9 +2647,9 @@ class Form // Filter by product type if (strval($filtertype) != '') { $sql .= " AND p.fk_product_type = ".((int) $filtertype); - } elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only + } elseif (!isModEnabled('product')) { // when product module is disabled, show services only $sql .= " AND p.fk_product_type = 1"; - } elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only + } elseif (!isModEnabled('service')) { // when service module is disabled, show products only $sql .= " AND p.fk_product_type = 0"; } // Add where from hooks @@ -2795,7 +2795,7 @@ class Form } } } else { - if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) { + if (isModEnabled('dynamicprices') && !empty($objp->fk_price_expression)) { $price_product = new Product($this->db); $price_product->fetch($objp->rowid, '', '', 1); $priceparser = new PriceParser($this->db); @@ -3424,7 +3424,7 @@ class Form if (!empty($objp->idprodfournprice)) { $outqty = $objp->quantity; $outdiscount = $objp->remise_percent; - if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) { + if (isModEnabled('dynamicprices') && !empty($objp->fk_supplier_price_expression)) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $objp->idprodfournprice; $prod_supplier->id = $objp->fk_product; @@ -3649,7 +3649,7 @@ class Form } $opt .= '>'.$objp->name.' - '.$objp->ref_fourn.' - '; - if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) { + if (isModEnabled('dynamicprices') && !empty($objp->fk_supplier_price_expression)) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $objp->idprodfournprice; $prod_supplier->id = $productid; @@ -8590,26 +8590,26 @@ class Form } } elseif ($objecttype == 'propal') { $tplpath = 'comm/'.$element; - if (empty($conf->propal->enabled)) { + if (!isModEnabled('propal')) { continue; // Do not show if module disabled } } elseif ($objecttype == 'supplier_proposal') { - if (empty($conf->supplier_proposal->enabled)) { + if (!isModEnabled('supplier_proposal')) { continue; // Do not show if module disabled } } elseif ($objecttype == 'shipping' || $objecttype == 'shipment' || $objecttype == 'expedition') { $tplpath = 'expedition'; - if (empty($conf->expedition->enabled)) { + if (!isModEnabled('expedition')) { continue; // Do not show if module disabled } } elseif ($objecttype == 'reception') { $tplpath = 'reception'; - if (empty($conf->reception->enabled)) { + if (!isModEnabled('reception')) { continue; // Do not show if module disabled } } elseif ($objecttype == 'delivery') { $tplpath = 'delivery'; - if (empty($conf->expedition->enabled)) { + if (!isModEnabled('expedition')) { continue; // Do not show if module disabled } } elseif ($objecttype == 'ficheinter') { @@ -8631,7 +8631,7 @@ class Form $tplpath = 'eventorganization'; } elseif ($objecttype == 'mo') { $tplpath = 'mrp'; - if (empty($conf->mrp->enabled)) { + if (!isModEnabled('mrp')) { continue; // Do not show if module disabled } } diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 27fa6925e21..9d9ff5a463f 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -318,20 +318,20 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { $rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (isModEnabled("propal")) { - $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (isModEnabled('contrat')) { - $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (isModEnabled('commande')) { - $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (isModEnabled('facture')) { - $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (isModEnabled('supplier_proposal')) { $langs->load("supplier_proposal"); - $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")) { $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); @@ -341,12 +341,12 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { } if (isModEnabled('tax')) { $langs->load("compta"); - $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); - $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); + $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); } if (!empty($conf->salaries->enabled)) { $langs->load("compta"); - $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>$conf->salaries->enabled, 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); + $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>isModEnabled('salaries'), 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); } if (isModEnabled('project')) { $rowspan++; $sectionauto[] = array('position'=>130, 'level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); @@ -354,28 +354,28 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { } if (isModEnabled('ficheinter')) { $langs->load("interventions"); - $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); + $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (isModEnabled('expensereport')) { $langs->load("trips"); - $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (isModEnabled('holiday')) { $langs->load("holiday"); - $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (isModEnabled("banque")) { $langs->load("banks"); - $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); - $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); + $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); } - if (!empty($conf->mrp->enabled)) { + if (isModEnabled('mrp')) { $langs->load("mrp"); - $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (isModEnabled('recruitment')) { $langs->load("recruitment"); - $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } $rowspan++; $sectionauto[] = array('position'=>220, 'level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 1aa91371cee..e92a888f21b 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -121,19 +121,19 @@ if (isModEnabled("societe")) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (isModEnabled("propal")) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (isModEnabled('contrat')) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (isModEnabled('commande')) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (isModEnabled('facture')) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (isModEnabled('supplier_proposal')) { - $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); @@ -142,28 +142,28 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (isModEnabled('tax')) { - $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); } if (isModEnabled('project')) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); } if (isModEnabled('ficheinter')) { - $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); + $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (isModEnabled('expensereport')) { - $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (isModEnabled('holiday')) { - $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (isModEnabled("banque")) { - $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); } if (!empty($conf->mrp->enabled)) { - $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (isModEnabled('recruitment')) { - $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4fcb145d62a..0790b54daa3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1210,7 +1210,7 @@ class Expedition extends CommonObject } // Stock control - if (!$error && $conf->stock->enabled && + if (!$error && isModEnabled('stock') && (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; @@ -1401,7 +1401,7 @@ class Expedition extends CommonObject } // Stock control - if (!$error && $conf->stock->enabled && + if (!$error && isModEnabled('stock') && (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f5be521dd3b..fa39dab1928 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2382,7 +2382,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::Livraison"); $usercanreceive = 0; - if (empty($conf->reception->enabled)) { + if (!isModEnabled('reception')) { $usercanreceive = $user->rights->fournisseur->commande->receptionner; } else { $usercanreceive = $user->rights->reception->creer; From 6c848333e6cc22e5a7c9fa88e65b6f56eccf1c3d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 15:30:40 +0200 Subject: [PATCH 4/6] Use isModEnabled --- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- htdocs/fourn/facture/list.php | 2 +- htdocs/hrm/admin/admin_establishment.php | 2 +- htdocs/hrm/admin/admin_hrm.php | 2 +- htdocs/hrm/establishment/card.php | 2 +- htdocs/hrm/establishment/info.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 5524783e275..16bc43474d8 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -738,7 +738,7 @@ class ProductFournisseur extends Product $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; } - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { + if (isModEnabled('dynamicprices') && !empty($prodfourn->fk_supplier_price_expression)) { $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProductSupplier($prodfourn); if ($price_result >= 0) { @@ -844,7 +844,7 @@ class ProductFournisseur extends Product $fourn_unitprice = $record["unitprice"]; $fourn_unitprice_with_discount = $record["unitprice"] * (1 - $record["remise_percent"] / 100); - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { + if (isModEnabled('dynamicprices') && !empty($record["fk_supplier_price_expression"])) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; $prod_supplier->id = $prodid; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 413c2c3f853..6e006704a83 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -839,7 +839,7 @@ if ($resql) { //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); - if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) { + if (isModEnabled('paymentbybanktransfer') && !empty($user->rights->paymentbybanktransfer->create)) { $langs->load('withdrawals'); $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder"); } diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 00722526e9d..99212988488 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -40,7 +40,7 @@ $permissiontoadd = $user->admin; //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); -if (empty($conf->hrm->enabled)) accessforbidden(); +if (!isModEnabled('hrm')) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); $sortorder = GETPOST('sortorder', 'aZ09comma'); diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index dc8d20403a3..ece067ce072 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -46,7 +46,7 @@ $permissiontoadd = $user->admin; //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); -if (empty($conf->hrm->enabled)) accessforbidden(); +if (!isModEnabled('hrm')) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 14ae1364494..f1bddce44e4 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -61,7 +61,7 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); -if (empty($conf->hrm->enabled)) accessforbidden(); +if (!isModEnabled('hrm')) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index d5f7f8a6b36..641c53e0f70 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -86,7 +86,7 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->hrm->enabled)) accessforbidden(); +if (!isModEnabled('hrm')) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); From 1dfcf8eceb4dd5a67c31f04e63a34f438e69f986 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 15:31:07 +0200 Subject: [PATCH 5/6] Use isModEnabled --- htdocs/main.inc.php | 4 ++-- htdocs/mrp/mo_agenda.php | 2 +- htdocs/mrp/mo_card.php | 4 ++-- htdocs/mrp/mo_document.php | 2 +- htdocs/mrp/mo_movements.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 16e3f006d3d..6865e4b8bf4 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2603,7 +2603,7 @@ function top_menu_bookmark() $html = ''; // Define $bookmarks - if (empty($conf->bookmark->enabled) || empty($user->rights->bookmark->lire)) { + if (!isModEnabled('bookmark') || empty($user->rights->bookmark->lire)) { return $html; } @@ -3304,7 +3304,7 @@ if (!function_exists("llxFooter")) { } // Wrapper to add log when clicking on download or preview - if (!empty($conf->blockedlog->enabled) && is_object($object) && !empty($object->id) && $object->id > 0 && $object->statut > 0) { + if (isModEnabled('blockedlog') && is_object($object) && !empty($object->id) && $object->id > 0 && $object->statut > 0) { if (in_array($object->element, array('facture'))) { // Restrict for the moment to element 'facture' print "\n\n"; ?> diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index d91735c592f..ac944acc066 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -153,7 +153,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) { diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index e52c0860aa2..373dd7b6410 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -436,7 +436,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }*/ $formquestion = array(); - if (!empty($conf->mrp->enabled)) { + if (isModEnabled('mrp')) { $langs->load("mrp"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -487,7 +487,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= $langs->trans('ThirdParty').' '; $morehtmlref .= ': '.(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/mrp/mo_document.php b/htdocs/mrp/mo_document.php index e19e0b391a2..4e8808012e1 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -131,7 +131,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/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 303f5516d72..761a17f016d 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -327,7 +327,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // 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) { @@ -605,7 +605,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($arrayfields['m.datem']['checked'])) { print ''; print ''; - if (empty($conf->productbatch->enabled)) { + if (!isModEnabled('productbatch')) { print ' '; } //else print '
'; From 6abca50afe1296b4d56f8b88e84f1f7015f2c7ce Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 15:31:29 +0200 Subject: [PATCH 6/6] Use isModEnabled --- htdocs/mrp/mo_note.php | 2 +- htdocs/mrp/mo_production.php | 4 ++-- htdocs/product/fournisseurs.php | 8 ++++---- htdocs/product/list.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index c32751b28d4..031018d0daa 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -107,7 +107,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) { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 25c43e46920..24b3516684e 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -482,7 +482,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }*/ $formquestion = array(); - if (!empty($conf->mrp->enabled)) { + if (isModEnabled('mrp')) { $langs->load("mrp"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -525,7 +525,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // 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/product/fournisseurs.php b/htdocs/product/fournisseurs.php index d28eca5252a..ca71ed3030b 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -313,7 +313,7 @@ if (empty($reshook)) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { - if (!empty($conf->dynamicprices->enabled) && $price_expression !== '') { + if (isModEnabled('dynamicprices') && $price_expression !== '') { //Check the expression validity by parsing it $priceparser = new PriceParser($db); $object->fk_supplier_price_expression = $price_expression; @@ -323,7 +323,7 @@ if (empty($reshook)) { setEventMessages($priceparser->translatedError(), null, 'errors'); } } - if (!$error && !empty($conf->dynamicprices->enabled)) { + if (!$error && isModEnabled('dynamicprices')) { //Set the price expression for this supplier price $ret = $object->setSupplierPriceExpression($price_expression); if ($ret < 0) { @@ -635,7 +635,7 @@ if ($id > 0 || $ref) { print ''; print ''; - if (!empty($conf->dynamicprices->enabled)) { //Only show price mode and expression selector if module is enabled + if (isModEnabled('dynamicprices')) { //Only show price mode and expression selector if module is enabled // Price mode selector print ''.$langs->trans("PriceMode").''; $price_expression = new PriceExpression($db); @@ -803,7 +803,7 @@ END; // Option to define a transport cost on supplier price if (!empty($conf->global->PRODUCT_CHARGES)) { - if (!empty($conf->margin->enabled)) { + if (isModEnabled('margin')) { print ''; print ''.$langs->trans("Charges").''; print ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 2eb281e734c..3561388709d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -165,7 +165,7 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) - || !empty($conf->mrp->enabled)) { + || isModEnabled('mrp')) { $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. }