QUAL All $conf->global->module->enabled are replaced with isModEnabled()

This commit is contained in:
Laurent Destailleur 2024-10-07 14:40:29 +02:00
parent 9b378d74af
commit 58cc96cd33
18 changed files with 36 additions and 25 deletions

View File

@ -201,7 +201,7 @@ class BlockedLog
/*
// Salary
if (!empty($conf->salary->enabled)) {
if (isModEnabled('salary')) {
$this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate';
$this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate';
$this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate';

View File

@ -146,7 +146,7 @@ if ($object->id > 0) {
$help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bookcal page-card_availabilities_agenda');
if (!empty($conf->notification->enabled)) {
if (isModEnabled('notification')) {
$langs->load("mails");
}
$head = availabilitiesPrepareHead($object);

View File

@ -1421,7 +1421,7 @@ class Commande extends CommonOrder
$this->origin_id = $object->id;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($conf->multicurrency->enabled)) {
if (isModEnabled('multicurrency')) {
if (!empty($object->multicurrency_code)) {
$this->multicurrency_code = $object->multicurrency_code;
}

View File

@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
if (!empty($conf->project->enabled)) {
if (isModEnabled('project')) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
@ -127,7 +127,7 @@ if ($object->id > 0) {
$allow_delete = 1;
// Bank account
if (!empty($conf->banque->enabled)) {
if (isModEnabled('bank')) {
if ($object->fk_account) {
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);

View File

@ -1749,7 +1749,7 @@ abstract class CommonObject
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
$modulename = 'fournisseur';
}
if (!empty($conf->{$modulename}->enabled)) {
if (isModEnabled($modulename)) {
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
$tmpelement = $obj->element;
$transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code;

View File

@ -180,7 +180,7 @@ class InfoBox
$tmpenabled = 0; // $tmpenabled is used for the '|' test (OR)
foreach ($arrayelem as $module) {
$tmpmodule = preg_replace('/@[^@]+/', '', $module);
if (!empty($conf->$tmpmodule->enabled)) {
if (isModEnabled($tmpmodule)) {
$tmpenabled = 1;
}
//print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';

View File

@ -4520,7 +4520,7 @@ function dolGetCountryCodeFromIp($ip)
$countrycode = '';
if (!empty($conf->geoipmaxmind->enabled)) {
if (isModEnabled('geoipmaxmind')) {
$datafile = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE');
//$ip='24.24.24.24';
//$datafile='/usr/share/GeoIP/GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages)
@ -4546,7 +4546,7 @@ function dol_user_country()
//$ret=$user->xxx;
$ret = '';
if (!empty($conf->geoipmaxmind->enabled)) {
if (isModEnabled('geoipmaxmind')) {
$ip = getUserRemoteIP();
$datafile = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE');
//$ip='24.24.24.24';

View File

@ -285,7 +285,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
print '<td>'.$langs->trans("Warehouse").'</td>';
}
/*TODO Add link to expeditiondet_batch
if (!empty($conf->productbatch->enabled))
if (isModEnabled('productbatch'))
{
print '<td>';
print '</td>';
@ -411,7 +411,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
// Batch number management
/*TODO Add link to expeditiondet_batch
if (!empty($conf->productbatch->enabled))
if (isModEnabled('productbatch'))
{
//var_dump($objp->edrowid);
$lines[$i]->detail_batch

View File

@ -136,7 +136,7 @@ class modProductBatch extends DolibarrModules
$sql = array();
if (!empty($conf->cashdesk->enabled)) {
if (isModEnabled('cashdesk')) {
if (!getDolGlobalString('CASHDESK_NO_DECREASE_STOCK')) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);

View File

@ -45,7 +45,7 @@ if (isModEnabled('member')) {
if (isModEnabled('category')) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
if (!empty($conf->accounting->enabled)) {
if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
}

View File

@ -1993,7 +1993,7 @@ if ($action == 'create') {
'morecss' => 'minwidth300'
)
);
if (!empty($conf->notification->enabled)) {
if (isModEnabled('notification')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
$notify = new Notify($db);
$text .= '<br>';
@ -2005,7 +2005,7 @@ if ($action == 'create') {
// Confirmation de l'envoi de la commande
if ($action == 'commande') {
$date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
if (!empty($conf->notification->enabled)) {
if (isModEnabled('notification')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
$notify = new Notify($db);
$text .= '<br>';

View File

@ -1473,7 +1473,7 @@ if (($action == 'edit_price' || $action == 'edit_level_price') && $object->getRi
print '</tr>';
// Only show price mode and expression selector if module is enabled
if (!empty($conf->dynamicprices->enabled)) {
if (isModEnabled('dynamicprices')) {
// Price mode selector
print '<!-- Show price mode of dynamicprices editor -->'."\n";
print '<tr><td>'.$langs->trans("PriceMode").'</td><td>';
@ -2345,7 +2345,7 @@ if ((!getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || $action == 'showlog_defau
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
print '<td class="right">'.$langs->trans("INCT").'</td>';
}
if (!empty($conf->dynamicprices->enabled)) {
if (isModEnabled('dynamicprices')) {
print '<td class="right">'.$langs->trans("PriceExpressionSelected").'</td>';
}
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
@ -2460,7 +2460,7 @@ if ((!getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || $action == 'showlog_defau
print $resultarray[2];
print '</td>';
}
if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled
if (isModEnabled('dynamicprices')) { // Only if module is enabled
print '<td class="right"></td>';
}
}

View File

@ -338,7 +338,7 @@ if (getDolGlobalString('MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN')) {
if (getDolGlobalString('MAIN_USE_TOP_MENU_SEARCH_DROPDOWN')) {
$maxwidthloginblock += 55;
}
if (!empty($conf->bookmark->enabled)) {
if (isModEnabled('bookmark')) {
$maxwidthloginblock += 55;
}

View File

@ -322,7 +322,7 @@ if ($action == 'create') {
print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
if (!empty($conf->mutlicompany->enabled)) {
if (isModEnabled('multicompany')) {
print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
print '<td class="valeur">'.dol_escape_htmltag($object->name);
if (empty($object->entity)) {

View File

@ -111,7 +111,7 @@ print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
if (!empty($conf->mutlicompany->enabled)) {
if (isModEnabled('multicompany')) {
print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
print '<td class="valeur">'.$object->name;
if (!$object->entity) {

View File

@ -221,7 +221,7 @@ if ($object->id > 0) {
print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
if (!empty($conf->mutlicompany->enabled)) {
if (isModEnabled('multicompany')) {
print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
print '<td class="valeur">'.dol_escape_htmltag($object->name);
if (empty($object->entity)) {

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 JF FERRY <jfefe@aternatik.fr>
* Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -613,7 +613,7 @@ function createProductOrService($authentication, $product)
if (!$error) {
// Update stock if stock count is provided and differs from database after creation or update
if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) {
if (isset($product['stock_real']) && $product['stock_real'] != '' && isModEnabled('stock')) {
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$savstockreal = $newobject->stock_reel;
@ -766,7 +766,7 @@ function updateProductOrService($authentication, $product)
$error++;
} else {
// Update stock if stock count is provided and differs from database after creation or update
if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) {
if (isset($product['stock_real']) && $product['stock_real'] != '' && isModEnabled('stock')) {
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$savstockreal = $newobject->stock_reel;

View File

@ -137,6 +137,17 @@ class CodingPhpTest extends CommonClassTest
$this->verifyIsModuleEnabledOk($filecontent, $report_filepath);
// Check we do not use the syntax conf->global->enabled->...
$ok = true;
$matches = array();
preg_match_all('/->global->(.*)->enabled/', $filecontent, $matches, PREG_SET_ORDER);
foreach ($matches as $key => $val) {
$ok = false;
break;
}
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
$this->assertTrue($ok, 'Found a ->global->...->enabled instead of isModEnabled("...") in file '.$file['relativename']);
if (preg_match('/\.class\.php/', $file['relativename'])
|| preg_match('/boxes\/box_/', $file['relativename'])
|| preg_match('/modules\/.*\/doc\/(doc|pdf)_/', $file['relativename'])