qual: avoid double negations by introducing getDolGlobalBool() (#30618)

* Update index.php

* Update api.class.php

* Update pdf_eratosthene.modules.php

* Update pdf_sponge.modules.php

* Update pdf_cyan.modules.php

* Update partnershiputils.class.php

* Update paypalfunctions.lib.php

* Update societe.class.php

* Update functions.lib.php - create getDolGlobalBool()

* Update index.php

* Update api.class.php

* Update pdf_eratosthene.modules.php

* Update pdf_sponge.modules.php

* Update pdf_cyan.modules.php

* Update partnershiputils.class.php

* Update paypalfunctions.lib.php

* Update societe.class.php

* Update functions.lib.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
thibdrev 2024-08-13 22:50:31 +02:00 committed by GitHub
parent 803c3c2f30
commit e5c0150be4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 31 additions and 17 deletions

View File

@ -117,7 +117,7 @@ print "</tr>";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ApiProductionMode").'</td>';
$production_mode = !(!getDolGlobalString('API_PRODUCTION_MODE'));
$production_mode = getDolGlobalBool('API_PRODUCTION_MODE');
if ($production_mode) {
print '<td><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&token='.newToken().'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
@ -132,7 +132,7 @@ print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("API_DISABLE_COMPRESSION").'</td>';
$disable_compression = !(!getDolGlobalString('API_DISABLE_COMPRESSION'));
$disable_compression = getDolGlobalBool('API_DISABLE_COMPRESSION');
if ($disable_compression) {
print '<td><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablecompression&token='.newToken().'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on');

View File

@ -55,7 +55,7 @@ class DolibarrApi
Defaults::$cacheDirectory = $cachedir;
$this->db = $db;
$production_mode = !(!getDolGlobalString('API_PRODUCTION_MODE'));
$production_mode = getDolGlobalBool('API_PRODUCTION_MODE');
$this->r = new Restler($production_mode, $refreshCache);
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));

View File

@ -205,7 +205,7 @@ function getMultidirVersion($object, $module = '', $forobject = 0)
/**
* Return dolibarr global constant string value
* Return a Dolibarr global constant string value
*
* @param string $key Key to return value, return $default if not set
* @param string|int|float $default Value to return if not defined
@ -222,9 +222,9 @@ function getDolGlobalString($key, $default = '')
* Return a Dolibarr global constant int value.
* The constants $conf->global->xxx are loaded by the script master.inc.php included at begin of any PHP page.
*
* @param string $key key to return value, return 0 if not set
* @param int $default value to return
* @return int
* @param string $key Key to return value, return $default if not set
* @param int $default Value to return if not defined
* @return int Value returned
* @see getDolUserInt()
*/
function getDolGlobalInt($key, $default = 0)
@ -233,6 +233,20 @@ function getDolGlobalInt($key, $default = 0)
return (int) (isset($conf->global->$key) ? $conf->global->$key : $default);
}
/**
* Return a Dolibarr global constant boolean value.
* The constants $conf->global->xxx are loaded by the script master.inc.php included at begin of any PHP page.
*
* @param string $key Key to return value, return $default if not set
* @param bool $default Value to return if not defined
* @return bool Value returned
*/
function getDolGlobalBool($key, $default = false)
{
global $conf;
return (bool) ($conf->global->$key ?? $default);
}
/**
* Return Dolibarr user constant string value
*

View File

@ -1926,7 +1926,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->cols['totalincltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => !(!getDolGlobalString('PDF_ORDER_SHOW_PRICE_INCL_TAX')),
'status' => getDolGlobalBool('PDF_ORDER_SHOW_PRICE_INCL_TAX'),
'title' => array(
'textkey' => 'TotalTTCShort'
),

View File

@ -2708,7 +2708,7 @@ class pdf_sponge extends ModelePDFFactures
$this->cols['totalincltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => !(!getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')),
'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'),
'title' => array(
'textkey' => 'TotalTTCShort'
),

View File

@ -2050,7 +2050,7 @@ class pdf_cyan extends ModelePDFPropales
$this->cols['totalincltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => !(!getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')),
'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'),
'title' => array(
'textkey' => 'TotalTTCShort'
),

View File

@ -79,4 +79,4 @@ $PROXY_HOST = getDolGlobalString('MAIN_PROXY_HOST');
$PROXY_PORT = getDolGlobalString('MAIN_PROXY_PORT');
$PROXY_USER = getDolGlobalString('MAIN_PROXY_USER');
$PROXY_PASS = getDolGlobalString('MAIN_PROXY_PASS');
$USE_PROXY = !(!getDolGlobalString('MAIN_PROXY_USE'));
$USE_PROXY = getDolGlobalBool('MAIN_PROXY_USE');

View File

@ -3778,22 +3778,22 @@ class Societe extends CommonObject
switch ($idprof) {
case 1:
$ret = !(!getDolGlobalString('SOCIETE_IDPROF1_UNIQUE'));
$ret = getDolGlobalBool('SOCIETE_IDPROF1_UNIQUE');
break;
case 2:
$ret = !(!getDolGlobalString('SOCIETE_IDPROF2_UNIQUE'));
$ret = getDolGlobalBool('SOCIETE_IDPROF2_UNIQUE');
break;
case 3:
$ret = !(!getDolGlobalString('SOCIETE_IDPROF3_UNIQUE'));
$ret = getDolGlobalBool('SOCIETE_IDPROF3_UNIQUE');
break;
case 4:
$ret = !(!getDolGlobalString('SOCIETE_IDPROF4_UNIQUE'));
$ret = getDolGlobalBool('SOCIETE_IDPROF4_UNIQUE');
break;
case 5:
$ret = !(!getDolGlobalString('SOCIETE_IDPROF5_UNIQUE'));
$ret = getDolGlobalBool('SOCIETE_IDPROF5_UNIQUE');
break;
case 6:
$ret = !(!getDolGlobalString('SOCIETE_IDPROF6_UNIQUE'));
$ret = getDolGlobalBool('SOCIETE_IDPROF6_UNIQUE');
break;
default:
$ret = false;