Qual: Enable Phan Simplify rule and fix notices (#30537)

* Qual: Phan - Enable Simplyfy expression

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Qual: Simplify expression (phan notice)

* Update functions2.lib.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
MDW
2024-08-07 03:05:02 +02:00
committed by GitHub
parent 227bca1867
commit 45ed4caeb2
85 changed files with 188 additions and 174 deletions

View File

@@ -386,7 +386,7 @@ return [
'UnknownElementTypePlugin',
'WhitespacePlugin',
//'RemoveDebugStatementPlugin', // Reports echo, print, ...
//'SimplifyExpressionPlugin',
'SimplifyExpressionPlugin',
//'StrictComparisonPlugin', // Expects ===
'SuspiciousParamOrderPlugin',
'UnsafeCodePlugin',

View File

@@ -11,6 +11,7 @@
* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
* Copyright (C) 2020 Guillaume Alexandre <guillaume@tag-info.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -179,7 +180,7 @@ class AccountancyImport
}
// at least one record value has changed, so we search for the next piece number from database or increment it
if ($atLeastOneLastRecordChanged === true) {
if ($atLeastOneLastRecordChanged) {
$lastPieceNum = 0;
if (empty($conf->cache['accounting']['nextPieceNum'])) {
// get last piece number from database

View File

@@ -302,7 +302,7 @@ foreach ($arrayofmodules as $file => $modCodeMember) {
print img_picto($langs->trans("Activated"), 'switch_on');
print "</td>\n";
} else {
$disabled = (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
$disabled = isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity));
print '<td class="center">';
if (!$disabled) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodemember&token='.newToken().'&value='.urlencode($file).'">';

View File

@@ -5,6 +5,7 @@
* Copyright (C) 2012-2107 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021-2022 Anthony Berton <bertonanthony@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -266,7 +267,7 @@ print dol_get_fiche_head($head, 'general', '', -1, '');
print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n";
print "<br>\n";
$noCountryCode = (empty($mysoc->country_code) ? true : false);
$noCountryCode = empty($mysoc->country_code);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';

View File

@@ -4,6 +4,7 @@
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -116,7 +117,7 @@ print "</tr>";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ApiProductionMode").'</td>';
$production_mode = (!getDolGlobalString('API_PRODUCTION_MODE') ? false : true);
$production_mode = !(!getDolGlobalString('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');
@@ -131,7 +132,7 @@ print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("API_DISABLE_COMPRESSION").'</td>';
$disable_compression = (!getDolGlobalString('API_DISABLE_COMPRESSION') ? false : true);
$disable_compression = !(!getDolGlobalString('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') ? false : true);
$production_mode = !(!getDolGlobalString('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

@@ -1542,7 +1542,7 @@ class Asset extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -866,7 +866,7 @@ class BOM extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -969,7 +969,7 @@ class Availabilities extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -960,7 +960,7 @@ class Calendar extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -1783,7 +1783,7 @@ while ($i < $imaxinloop) {
}
$marginInfo = array();
if ($with_margin_info === true) {
if ($with_margin_info) {
$objectstatic->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($objectstatic);
$total_ht += $obj->total_ht;

View File

@@ -443,7 +443,7 @@ class Commande extends CommonOrder
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -2149,7 +2149,7 @@ while ($i < $imaxinloop) {
$projectstatic->title = $obj->project_label;
$marginInfo = array();
if ($with_margin_info === true) {
if ($with_margin_info) {
$generic_commande->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($generic_commande);
$total_ht += $obj->total_ht;

View File

@@ -1547,7 +1547,7 @@ if ($resql) {
$projectstatic->title = $obj->project_label;
$marginInfo = array();
if ($with_margin_info === true) {
if ($with_margin_info) {
$generic_commande->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($generic_commande);
$total_ht += $obj->total_ht;

View File

@@ -119,7 +119,7 @@ if ($currentInvId) { // Here to breakdown
$toJsonArray['amount_'.$currentInvId] = price2num($currentAmount); // Param will exist only if an img has been clicked
}
$toJsonArray['makeRed'] = ($totalRemaining < price2num($result) || price2num($result) < 0) ? true : false;
$toJsonArray['makeRed'] = ($totalRemaining < price2num($result) || price2num($result) < 0);
$toJsonArray['result'] = price($result); // Return value to user format
$toJsonArray['resultnum'] = price2num($result); // Return value to numeric format

View File

@@ -2031,7 +2031,7 @@ if ($num > 0) {
$facturestatic->totalpaid = $paiement;
$marginInfo = array();
if ($with_margin_info === true) {
if ($with_margin_info) {
$facturestatic->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($facturestatic);
$total_ht += $obj->total_ht;

View File

@@ -5,6 +5,7 @@
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -212,7 +213,7 @@ if (!empty($selected_type)) {
if (!empty($typent_id)) {
$tableparams['typent_id'] = $typent_id;
}
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
$tableparams['subcat'] = $subcat ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);

View File

@@ -7,6 +7,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -190,7 +191,7 @@ $tableparams['search_societe'] = $search_societe;
$tableparams['search_zip'] = $search_zip;
$tableparams['search_town'] = $search_town;
$tableparams['search_country'] = $search_country;
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
$tableparams['subcat'] = $subcat ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);

View File

@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -182,7 +183,7 @@ if (!empty($selected_soc)) {
if (!empty($selected_type)) {
$tableparams['search_type'] = $selected_type;
}
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
$tableparams['subcat'] = $subcat ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
* Copyright (C) 2023 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -161,7 +162,7 @@ $tableparams['search_societe'] = $search_societe;
$tableparams['search_zip'] = $search_zip;
$tableparams['search_town'] = $search_town;
$tableparams['search_country'] = $search_country;
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
$tableparams['subcat'] = $subcat ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);

View File

@@ -47,7 +47,7 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.clas
// Load translation files required by the page
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
$refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTISSET('invoice_type')) ? true : false;
$refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTISSET('invoice_type'));
$invoice_type = GETPOSTISSET('invoice_type') ? GETPOST('invoice_type', 'alpha') : '';
$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'alphanohtml') : -1;

View File

@@ -1356,7 +1356,7 @@ class ExtraFields
}
}
if ($filter_categorie === false) {
if (!$filter_categorie) {
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$keyList .= ', ';
@@ -1526,7 +1526,7 @@ class ExtraFields
}
}
if ($filter_categorie === false) {
if (!$filter_categorie) {
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$keyList .= ', ';
@@ -1913,7 +1913,7 @@ class ExtraFields
dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($filter_categorie === false) {
if (!$filter_categorie) {
$value = ''; // value was used, so now we reset it to use it to build final output
$obj = $this->db->fetch_object($resql);
@@ -2023,7 +2023,7 @@ class ExtraFields
dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($filter_categorie === false) {
if (!$filter_categorie) {
$value = ''; // value was used, so now we reset it to use it to build final output
$toprint = array();
while ($obj = $this->db->fetch_object($resql)) {
@@ -2205,7 +2205,7 @@ class ExtraFields
$expand_display = false;
if (is_array($extrafield_param_list) && count($extrafield_param_list) > 0) {
$extrafield_collapse_display_value = intval($extrafield_param_list[0]);
$expand_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOSTINT('ignorecollapsesetup')) ? (empty($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) ? false : true) : ($extrafield_collapse_display_value == 2 ? false : true));
$expand_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOSTINT('ignorecollapsesetup')) ? (!empty($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key])) : !($extrafield_collapse_display_value == 2));
}
$disabledcookiewrite = 0;
if ($mode == 'create') {
@@ -2239,7 +2239,7 @@ class ExtraFields
$out .= '<script nonce="'.getNonce().'" type="text/javascript">'."\n";
$out .= 'jQuery(document).ready(function(){'."\n";
if (empty($disabledcookiewrite)) {
if ($expand_display === false) {
if (!$expand_display) {
$out .= ' console.log("Inject js for the collapsing of extrafield '.$key.' - hide");'."\n";
$out .= ' jQuery(".trextrafields_collapse'.$collapse_group.'").hide();'."\n";
} else {

View File

@@ -398,7 +398,7 @@ class FormFile
$printer = 0;
// The direct print feature is implemented only for such elements
if (in_array($modulepart, array('contract', 'facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) {
$printer = ($user->hasRight('printing', 'read') && !empty($conf->printing->enabled)) ? true : false;
$printer = ($user->hasRight('printing', 'read') && !empty($conf->printing->enabled));
}
$hookmanager->initHooks(array('formfile'));

View File

@@ -322,7 +322,7 @@ class Ldap
$this->error = '';
$this->connectedServer = '';
$ldapdebug = ((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false") ? false : true);
$ldapdebug = !((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false"));
if ($ldapdebug) {
dol_syslog(get_class($this)."::connectBind");

View File

@@ -946,7 +946,7 @@ class TimeSpent extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -343,7 +343,7 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '')
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
//var_dump($sFileName); var_dump(image_format_supported($sFileName));exit;
$imgsupported = image_format_supported($sFileName);
$isImageValid = ($imgsupported >= 0 ? true : false);
$isImageValid = ($imgsupported >= 0);
if (!$isImageValid) {
$sErrorNumber = '202';
}

View File

@@ -38,7 +38,7 @@
*/
function is_empty($var, $allow_false = false, $allow_ws = false)
{
if (is_null($var) || !isset($var) || ($allow_ws == false && trim($var) == "" && !is_bool($var)) || ($allow_false === false && is_bool($var) && $var === false) || (is_array($var) && empty($var))) {
if (is_null($var) || !isset($var) || ($allow_ws == false && trim($var) == "" && !is_bool($var)) || ($allow_false === false && $var === false) || (is_array($var) && empty($var))) {
return true;
}
return false;

View File

@@ -1898,7 +1898,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
}
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
if ($force_filter_contact === false) {
if (!$force_filter_contact) {
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) {
$sql .= " AND a.fk_soc = ".((int) $filterobj->id);
} elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {

View File

@@ -2051,13 +2051,13 @@ function getSoapParams()
global $conf;
$params = array();
$proxyuse = (!getDolGlobalString('MAIN_PROXY_USE') ? false : true);
$proxyhost = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_HOST);
$proxyport = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_PORT);
$proxyuser = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_USER);
$proxypass = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_PASS);
$timeout = (!getDolGlobalString('MAIN_USE_CONNECT_TIMEOUT') ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout
$response_timeout = (!getDolGlobalString('MAIN_USE_RESPONSE_TIMEOUT') ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout
$proxyuse = getDolGlobalString('MAIN_PROXY_USE');
$proxyhost = (!$proxyuse ? false : $conf->global->MAIN_PROXY_HOST);
$proxyport = (!$proxyuse ? false : $conf->global->MAIN_PROXY_PORT);
$proxyuser = (!$proxyuse ? false : $conf->global->MAIN_PROXY_USER);
$proxypass = (!$proxyuse ? false : $conf->global->MAIN_PROXY_PASS);
$timeout = getDolGlobalInt('MAIN_USE_CONNECT_TIMEOUT', 10); // Connection timeout
$response_timeout = getDolGlobalInt('MAIN_USE_RESPONSE_TIMEOUT', 30); // Response timeout
//print extension_loaded('soap');
if ($proxyuse) {
$params = array('connection_timeout' => $timeout,

View File

@@ -196,21 +196,21 @@ if (!function_exists('dol_loginfunction')) {
if (getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
if (session_status() != PHP_SESSION_ACTIVE) {
if (PHP_VERSION_ID < 70300) {
session_set_cookie_params(0, '/', null, ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
session_set_cookie_params(0, '/', null, !(empty($dolibarr_main_force_https) && isHTTPS() === false), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
} else {
// Only available for php >= 7.3
$sessioncookieparams = array(
'lifetime' => 0,
'path' => '/',
//'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains
'secure' => ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true),
'secure' => !(empty($dolibarr_main_force_https) && isHTTPS() === false),
'httponly' => true,
'samesite' => 'Lax' // None || Lax || Strict
);
session_set_cookie_params($sessioncookieparams);
}
setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', (empty($dolibarr_main_force_https) ? false : true), true);
setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', !empty($dolibarr_main_force_https), true);
}
}

View File

@@ -77,7 +77,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
$ldapdn = $dolibarr_main_auth_ldap_dn;
$ldapadminlogin = $dolibarr_main_auth_ldap_admin_login;
$ldapadminpass = $dolibarr_main_auth_ldap_admin_pass;
$ldapdebug = ((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false") ? false : true);
$ldapdebug = !(empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false");
if ($ldapdebug) {
print "DEBUG: Logging LDAP steps<br>\n";

View File

@@ -920,7 +920,7 @@ class pdf_einstein extends ModelePDFCommandes
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {

View File

@@ -1127,7 +1127,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {
@@ -1783,7 +1783,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->cols['position'] = array(
'rank' => $rank,
'width' => 10,
'status' => getDolGlobalInt('PDF_ERATOSHTENE_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
'status' => getDolGlobalInt('PDF_ERATOSHTENE_ADD_POSITION') ? true : ((bool) getDolGlobalInt('PDF_ADD_POSITION')),
'title' => array(
'textkey' => '#', // use lang key is useful in somme case with module
'align' => 'C',
@@ -1915,7 +1915,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => !getDolGlobalString('PDF_ORDER_HIDE_PRICE_EXCL_TAX') ? true : false,
'status' => !getDolGlobalString('PDF_ORDER_HIDE_PRICE_EXCL_TAX'),
'title' => array(
'textkey' => 'TotalHTShort'
),
@@ -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') ? false : true,
'status' => !(!getDolGlobalString('PDF_ORDER_SHOW_PRICE_INCL_TAX')),
'title' => array(
'textkey' => 'TotalTTCShort'
),

View File

@@ -1397,7 +1397,7 @@ class pdf_crabe extends ModelePDFFactures
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {

View File

@@ -1609,7 +1609,7 @@ class pdf_octopus extends ModelePDFFactures
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {

View File

@@ -1684,7 +1684,7 @@ class pdf_sponge extends ModelePDFFactures
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {
@@ -2697,7 +2697,7 @@ class pdf_sponge extends ModelePDFFactures
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX') ? true : false,
'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX'),
'title' => array(
'textkey' => 'TotalHTShort'
),
@@ -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') ? false : true,
'status' => !(!getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')),
'title' => array(
'textkey' => 'TotalTTCShort'
),

View File

@@ -1105,7 +1105,7 @@ class pdf_azur extends ModelePDFPropales
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {

View File

@@ -1209,7 +1209,7 @@ class pdf_cyan extends ModelePDFPropales
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {
@@ -2039,7 +2039,7 @@ class pdf_cyan extends ModelePDFPropales
$this->cols['totalexcltax'] = array(
'rank' => $rank,
'width' => 26, // in mm
'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX') ? true : false,
'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX'),
'title' => array(
'textkey' => 'TotalHTShort'
),
@@ -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') ? false : true,
'status' => !(!getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')),
'title' => array(
'textkey' => 'TotalTTCShort'
),

View File

@@ -909,7 +909,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$this->atleastoneratenotnull = 0;
if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
$tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']));
if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
// Nothing to do
} else {

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -25,10 +26,10 @@ if (empty($blocname)) {
$hide = true; // Hide by default
if (isset($parameters['showblocbydefault'])) {
$hide = (empty($parameters['showblocbydefault']) ? true : false);
$hide = empty($parameters['showblocbydefault']);
}
if (isset($object->extraparams[$blocname]['showhide'])) {
$hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false);
$hide = empty($object->extraparams[$blocname]['showhide']);
}
?>

View File

@@ -3541,7 +3541,7 @@ class EmailCollector extends CommonObject
if (empty($mode) && empty($error)) {
$res = imap_mail_move($connection, $imapemail, $targetdir, CP_UID);
if ($res == false) {
if (!$res) {
// $errorforemail++; // Not in loop, not needed, not initialised
$this->error = imap_last_error();
$this->errors[] = $this->error;

View File

@@ -989,7 +989,7 @@ class ConferenceOrBoothAttendee extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -1026,7 +1026,7 @@ class Fichinter extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -1119,7 +1119,7 @@ class CommandeFournisseur extends CommonOrder
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -784,12 +784,12 @@ class PaiementFourn extends Paiement
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool = (include_once $dir.$file) || $mybool;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
}
// For compatibility
if ($mybool === false) {
if (!$mybool) {
$file = getDolGlobalString('SUPPLIER_PAYMENT_ADDON') . ".php";
$classname = "mod_supplier_payment_" . getDolGlobalString('SUPPLIER_PAYMENT_ADDON');
$classname = preg_replace('/\-.*$/', '', $classname);
@@ -799,12 +799,12 @@ class PaiementFourn extends Paiement
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool = (include_once $dir.$file) || $mybool;
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
}
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -231,7 +231,7 @@ class Holiday extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -946,7 +946,7 @@ class Evaluation extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -926,7 +926,7 @@ class EvaluationLine extends CommonObjectLine
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -955,7 +955,7 @@ class Job extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -995,7 +995,7 @@ class Position extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file " . $file);
return '';
}

View File

@@ -995,7 +995,7 @@ class Skill extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -894,7 +894,7 @@ class Skilldet extends CommonObjectLine
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -959,7 +959,7 @@ class SkillRank extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -1015,7 +1015,7 @@ class KnowledgeRecord extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -378,14 +378,14 @@ if (GETPOST("DOL_AUTOSET_COOKIE")) {
$cookievalue = json_encode($cookiearrayvalue);
//var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue);
if (PHP_VERSION_ID < 70300) {
setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', '', ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // keep cookie 1 year and add tag httponly
setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', '', !(empty($dolibarr_main_force_https) && isHTTPS() === false), true); // keep cookie 1 year and add tag httponly
} else {
// Only available for php >= 7.3
$cookieparams = array(
'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)),
'path' => '/',
//'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains
'secure' => ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true),
'secure' => !(empty($dolibarr_main_force_https) && isHTTPS() === false),
'httponly' => true,
'samesite' => 'Lax' // None || Lax || Strict
);
@@ -416,14 +416,14 @@ if (!empty($_COOKIE[$sessiontimeout])) {
// We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished.
if (!defined('NOSESSION')) {
if (PHP_VERSION_ID < 70300) {
session_set_cookie_params(0, '/', null, ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
session_set_cookie_params(0, '/', null, !(empty($dolibarr_main_force_https) && isHTTPS() === false), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
} else {
// Only available for php >= 7.3
$sessioncookieparams = array(
'lifetime' => 0,
'path' => '/',
//'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains
'secure' => ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true),
'secure' => !(empty($dolibarr_main_force_https) && isHTTPS() === false),
'httponly' => true,
'samesite' => 'Lax' // None || Lax || Strict
);
@@ -835,7 +835,7 @@ if (!defined('NOLOGIN')) {
// Verification security graphic code
if ($test && GETPOST("username", "alpha", 2) && getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') && !isset($_SESSION['dol_bypass_antispam'])) {
$sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
$ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
// Check code
if (!$ok) {
@@ -1023,7 +1023,7 @@ if (!defined('NOLOGIN')) {
if ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) {
dol_syslog('User not found or not valid, connection refused');
session_destroy();
session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie
session_set_cookie_params(0, '/', null, !empty($dolibarr_main_force_https), true); // Add tag secure and httponly on session cookie
session_name($sessionname);
dol_session_start();
@@ -1110,7 +1110,7 @@ if (!defined('NOLOGIN')) {
dol_syslog("The user login has a validity between [".$user->datestartvalidity." and ".$user->dateendvalidity."], current date is ".dol_now());
}
session_destroy();
session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie
session_set_cookie_params(0, '/', null, !empty($dolibarr_main_force_https), true); // Add tag secure and httponly on session cookie
session_name($sessionname);
dol_session_start();

View File

@@ -1021,7 +1021,7 @@ class Mo extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}
@@ -1386,7 +1386,7 @@ class Mo extends CommonObject
global $langs;
$langs->loadLangs(['mrp', 'products']);
$nofetch = isset($params['nofetch']) ? true : false;
$nofetch = isset($params['nofetch']);
$datas = [];

View File

@@ -185,7 +185,7 @@ function issetAndNoEmpty($name, $tableau = null)
$tableau = $_POST;
}
return (isset($tableau[$name]) === true && empty($tableau[$name]) === false);
return (isset($tableau[$name]) && !empty($tableau[$name]));
}

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -728,7 +729,7 @@ if ($object->format == "D") {
for ($i = 0; $i < $nbofsujet; $i++) {
$cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
if (isset($toutsujet[$i + 1]) === false) {
if (!isset($toutsujet[$i + 1])) {
$next = false;
} else {
$next = intval($toutsujet[$i + 1]);
@@ -756,7 +757,7 @@ if ($object->format == "D") {
$colspan = 1;
for ($i = 0; $i < $nbofsujet; $i++) {
$cur = intval($toutsujet[$i]);
if (isset($toutsujet[$i + 1]) === false) {
if (!isset($toutsujet[$i + 1])) {
$next = false;
} else {
$next = intval($toutsujet[$i + 1]);
@@ -1129,7 +1130,7 @@ $toutsujet = explode(",", $object->sujet); // With old versions, this field was
$compteursujet = 0;
$meilleursujet = '';
for ($i = 0; $i < $nbcolonnes; $i++) {
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) {
if (isset($sumfor[$i]) && isset($meilleurecolonne) && ($sumfor[$i] == $meilleurecolonne)) {
$meilleursujet .= ($meilleursujet ? ", " : "");
if ($object->format == "D") {

View File

@@ -129,7 +129,7 @@ print '<table>'."\n";
//affichage des cases texte de formulaire
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) {
$j = $i + 1;
if (isset($_SESSION["choix$i"]) === false) {
if (!isset($_SESSION["choix$i"])) {
$_SESSION["choix$i"] = '';
}
print '<tr><td>'.$langs->trans("TitleChoice").' '.$j.': </td><td><input type="text" name="choix[]" size="40" maxlength="40" value="'.dol_escape_htmltag($_SESSION["choix$i"]).'" id="choix'.$i.'">';

View File

@@ -525,7 +525,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
}
// If no red button, we show green or grey button with number of day
if (isset($dejafait) === false || $dejafait != $numerojour) {
if (!isset($dejafait) || $dejafait != $numerojour) {
// green button
if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) {
print '<td class="center libre"><input type="submit" class="bouton ON centpercent nomarginleft buttonwebsite" name="choixjourajout[]" value="'.$numerojour.'"></td>'."\n";

View File

@@ -1224,7 +1224,7 @@ class Partnership extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -543,7 +543,7 @@ class PartnershipUtils
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
$url = filter_var($url, FILTER_SANITIZE_URL);
if (!filter_var($url, FILTER_VALIDATE_URL) === false) {
if (!(!filter_var($url, FILTER_VALIDATE_URL))) {
$webcontent .= $url;
}
}

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -78,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') ? false : true;
$USE_PROXY = !(!getDolGlobalString('MAIN_PROXY_USE'));

View File

@@ -343,7 +343,7 @@ foreach ($dirproduct as $dirroot) {
print "</td>\n";
} else {
$disabled = false;
if (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true) {
if (!(isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] == $conf->entity)))) {
}
print '<td class="center">';
if (!$disabled) {

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015-2017 Francis Appels <francis.appels@yahoo.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -873,7 +874,7 @@ class FormProduct
if (count($productIdArray) && count($this->cache_lot)) {
// check cache already loaded for product id's
foreach ($productIdArray as $productId) {
$cacheLoaded = !empty($this->cache_lot[$productId]) ? true : false;
$cacheLoaded = !empty($this->cache_lot[$productId]);
}
}
if ($cacheLoaded) {

View File

@@ -819,7 +819,7 @@ class ProductFournisseurPrice extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -305,13 +305,13 @@ class Productlot extends CommonObject
}
}
if ($checkSellByMandatory === true) {
if ($checkSellByMandatory) {
if (!isset($sellBy) || dol_strlen($sellBy) == 0) {
// error : sell by is mandatory
$errorMsgArr[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('SellByDate'));
}
}
if ($checkEatByMandatory === true) {
if ($checkEatByMandatory) {
if (!isset($eatBy) || dol_strlen($eatBy) == 0) {
// error : eat by is mandatory
$errorMsgArr[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('EatByDate'));

View File

@@ -1005,7 +1005,7 @@ class StockTransfer extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -912,7 +912,7 @@ class StockTransferLine extends CommonObjectLine
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -1515,7 +1515,7 @@ class Task extends CommonObjectLine
}
}
if ($ret == true) {
if ($ret) {
$this->db->commit();
} else {
$this->db->rollback();

View File

@@ -204,7 +204,7 @@ if (empty($reshook) && $action == 'add') {
// Check Captcha code if is enabled
if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) {
$sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
$ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
if (!$ok) {
$error++;
$errmsg .= $langs->trans("ErrorBadValueForCode") . "<br>\n";

View File

@@ -264,7 +264,7 @@ if (empty($reshook) && $action == 'add') {
// Check Captcha code if is enabled
if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) {
$sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
$ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
if (!$ok) {
$error++;
$errmsg .= $langs->trans("ErrorBadValueForCode")."<br>\n";

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -405,7 +406,7 @@ if ($object->format == "D") {
for ($i = 0; $i < $nbofsujet; $i++) {
$cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
if (isset($toutsujet[$i + 1]) === false) {
if (!isset($toutsujet[$i + 1])) {
$next = false;
} else {
$next = intval($toutsujet[$i + 1]);
@@ -427,7 +428,7 @@ if ($object->format == "D") {
$colspan = 1;
for ($i = 0; $i < $nbofsujet; $i++) {
$cur = intval($toutsujet[$i]);
if (isset($toutsujet[$i + 1]) === false) {
if (!isset($toutsujet[$i + 1])) {
$next = false;
} else {
$next = intval($toutsujet[$i + 1]);

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -231,7 +232,7 @@ if (empty($reshook)) {
// Check Captcha code if is enabled
if (getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET')) {
$sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
$ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
if (!$ok) {
$error++;
array_push($object->errors, $langs->trans("ErrorBadValueForCode"));

View File

@@ -179,7 +179,7 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access
if (empty($webportal_logged_thirdparty_account_id)) {
// Set cookie for timeout management
if (getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', (empty($dolibarr_main_force_https) ? false : true), true);
setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', !empty($dolibarr_main_force_https), true);
}
$context->controller = 'login';
@@ -199,7 +199,7 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access
// Account has been removed after login
dol_syslog("Can't load third-party account (ID: $webportal_logged_thirdparty_account_id) even if session logged.", LOG_WARNING);
session_destroy();
session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie
session_set_cookie_params(0, '/', null, !empty($dolibarr_main_force_https), true); // Add tag secure and httponly on session cookie
session_name($sessionname);
session_start();

View File

@@ -945,7 +945,7 @@ class RecruitmentCandidature extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -1016,7 +1016,7 @@ class RecruitmentJobPosition extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -438,7 +438,7 @@ foreach ($arrayofmodules as $file => $modCodeTiers) {
print img_picto($langs->trans("Activated"), 'switch_on');
print "</td>\n";
} else {
$disabled = (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
$disabled = (isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] != $conf->entity)));
print '<td class="center">';
if (!$disabled) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&token='.newToken().'&value='.urlencode($file).'">';
@@ -717,9 +717,9 @@ foreach ($profid as $key => $val) {
$idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
$idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
$verif = (empty($conf->global->$idprof_unique) ? false : true);
$mandatory = (empty($conf->global->$idprof_mandatory) ? false : true);
$invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ? false : true);
$verif = !empty($conf->global->$idprof_unique);
$mandatory = !empty($conf->global->$idprof_mandatory);
$invoice_mandatory = !empty($conf->global->$idprof_invoice_mandatory);
if ($verif) {
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';

View File

@@ -3778,22 +3778,22 @@ class Societe extends CommonObject
switch ($idprof) {
case 1:
$ret = (!getDolGlobalString('SOCIETE_IDPROF1_UNIQUE') ? false : true);
$ret = !(!getDolGlobalString('SOCIETE_IDPROF1_UNIQUE'));
break;
case 2:
$ret = (!getDolGlobalString('SOCIETE_IDPROF2_UNIQUE') ? false : true);
$ret = !(!getDolGlobalString('SOCIETE_IDPROF2_UNIQUE'));
break;
case 3:
$ret = (!getDolGlobalString('SOCIETE_IDPROF3_UNIQUE') ? false : true);
$ret = !(!getDolGlobalString('SOCIETE_IDPROF3_UNIQUE'));
break;
case 4:
$ret = (!getDolGlobalString('SOCIETE_IDPROF4_UNIQUE') ? false : true);
$ret = !(!getDolGlobalString('SOCIETE_IDPROF4_UNIQUE'));
break;
case 5:
$ret = (!getDolGlobalString('SOCIETE_IDPROF5_UNIQUE') ? false : true);
$ret = !(!getDolGlobalString('SOCIETE_IDPROF5_UNIQUE'));
break;
case 6:
$ret = (!getDolGlobalString('SOCIETE_IDPROF6_UNIQUE') ? false : true);
$ret = !(!getDolGlobalString('SOCIETE_IDPROF6_UNIQUE'));
break;
default:
$ret = false;
@@ -4591,7 +4591,7 @@ class Societe extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
return (($obj->nb > 0) ? true : false);
return ($obj->nb > 0);
} else {
$this->error = $this->db->lasterror();
return false;

View File

@@ -66,7 +66,7 @@ if (empty($_SESSION["takeposterminal"])) {
if ($setterminal > 0) {
$_SESSION["takeposterminal"] = $setterminal;
setcookie("takeposterminal", (string) $setterminal, (time() + (86400 * 354)), '/', '', (empty($dolibarr_main_force_https) ? false : true), true); // Permanent takeposterminal var in a cookie
setcookie("takeposterminal", (string) $setterminal, (time() + (86400 * 354)), '/', '', !empty($dolibarr_main_force_https), true); // Permanent takeposterminal var in a cookie
}
if ($setcurrency != "") {

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -119,7 +120,7 @@ if (empty($reshook)) {
// Action to set a temporary password and send email for reset
if ($action == 'buildnewpassword' && $username) {
$sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
$ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
// Verify code
if (!$ok) {

View File

@@ -923,7 +923,7 @@ class Target extends CommonObject
$mybool = ((bool) @include_once $dir.$file) || $mybool;
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}

View File

@@ -617,7 +617,7 @@ class FormCardWebPortal
$cardRight = true;
}
}
if ($cardRight === true) {
if ($cardRight) {
$html .= '</div>';
$html .= '<div class="card-right">';
}

View File

@@ -830,7 +830,7 @@ class FormWebPortal extends Form
}
}
if ($filter_categorie === false) {
if (!$filter_categorie) {
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$keyList .= ', ';
@@ -1163,7 +1163,7 @@ class FormWebPortal extends Form
dol_syslog(__METHOD__ . ' type=sellist', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($filter_categorie === false) {
if (!$filter_categorie) {
$value = ''; // value was used, so now we reset it to use it to build final output
$numrows = $this->db->num_rows($resql);
if ($numrows) {
@@ -1266,7 +1266,7 @@ class FormWebPortal extends Form
dol_syslog(__METHOD__ . ' type=chkbxlst', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($filter_categorie === false) {
if (!$filter_categorie) {
$value = ''; // value was used, so now we reset it to use it to build final output
$toprint = array();
while ($obj = $this->db->fetch_object($resql)) {

View File

@@ -880,7 +880,7 @@ class Workstation extends CommonObject
}
}
if ($mybool === false) {
if (!$mybool) {
dol_print_error(null, "Failed to include file ".$file);
return '';
}