From 7785ae93a13c4cfd4f105eb970c9983d5f6255dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Nov 2023 11:41:05 +0100 Subject: [PATCH] Fix php8.2 warnings --- htdocs/admin/modules.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/core/tpl/contacts.tpl.php | 2 +- htdocs/core/tpl/login.tpl.php | 4 +- htdocs/core/tpl/objectline_create.tpl.php | 8 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- htdocs/core/tpl/passwordreset.tpl.php | 2 +- htdocs/datapolicy/admin/setup.php | 2 +- .../class/actions_datapolicy.class.php | 2 +- htdocs/datapolicy/lib/datapolicy.lib.php | 2 +- htdocs/dav/fileserver.php | 10 +- .../class/DataCollector/DolibarrCollector.php | 2 +- htdocs/delivery/card.php | 12 +- htdocs/delivery/class/delivery.class.php | 14 +- htdocs/delivery/tpl/linkedobjectblock.tpl.php | 2 +- htdocs/don/card.php | 18 +-- htdocs/don/class/don.class.php | 2 +- htdocs/don/index.php | 2 +- htdocs/don/list.php | 6 +- htdocs/don/payment/payment.php | 2 +- htdocs/don/stats/index.php | 2 +- htdocs/ecm/class/ecmfiles.class.php | 2 +- htdocs/ecm/dir_card.php | 2 +- htdocs/ecm/index.php | 4 +- htdocs/ecm/index_auto.php | 10 +- htdocs/ecm/index_medias.php | 2 +- .../class/emailcollector.class.php | 52 +++--- .../class/emailcollectoraction.class.php | 4 +- .../class/emailcollectorfilter.class.php | 4 +- .../class/conferenceorbooth.class.php | 6 +- .../class/conferenceorboothattendee.class.php | 12 +- .../conferenceorbooth_card.php | 10 +- .../conferenceorbooth_contact.php | 10 +- .../conferenceorbooth_document.php | 10 +- .../conferenceorbooth_list.php | 10 +- .../conferenceorboothattendee_card.php | 10 +- .../conferenceorboothattendee_list.php | 12 +- .../core/actions_massactions_mail.inc.php | 6 +- ...ventorganization_conferenceorbooth.lib.php | 2 +- htdocs/expedition/card.php | 94 +++++------ htdocs/expedition/class/expedition.class.php | 34 ++-- htdocs/expedition/dispatch.php | 44 +++--- htdocs/expedition/list.php | 6 +- htdocs/expedition/shipment.php | 16 +- htdocs/expedition/stats/index.php | 2 +- htdocs/expensereport/card.php | 102 ++++++------ .../class/expensereport.class.php | 12 +- htdocs/expensereport/index.php | 6 +- htdocs/expensereport/list.php | 2 +- htdocs/expensereport/payment/list.php | 6 +- htdocs/expensereport/payment/payment.php | 2 +- htdocs/expensereport/stats/index.php | 2 +- .../tpl/expensereport_addfile.tpl.php | 4 +- .../tpl/expensereport_linktofile.tpl.php | 8 +- htdocs/exports/class/export.class.php | 4 +- htdocs/exports/export.php | 4 +- htdocs/externalsite/admin/index.php | 4 +- htdocs/externalsite/frames.php | 4 +- htdocs/fichinter/card-rec.php | 4 +- htdocs/fichinter/card.php | 108 ++++++------- htdocs/fichinter/class/fichinter.class.php | 6 +- htdocs/fichinter/contact.php | 4 +- htdocs/fichinter/index.php | 2 +- htdocs/fichinter/list.php | 18 +-- htdocs/fichinter/stats/index.php | 4 +- htdocs/fourn/ajax/getSupplierPrices.php | 4 +- htdocs/fourn/card.php | 16 +- .../class/fournisseur.commande.class.php | 44 +++--- .../fourn/class/fournisseur.facture.class.php | 20 +-- .../fourn/class/fournisseur.product.class.php | 14 +- htdocs/fourn/class/paiementfourn.class.php | 10 +- htdocs/fourn/commande/card.php | 120 +++++++------- htdocs/fourn/commande/contact.php | 2 +- htdocs/fourn/commande/dispatch.php | 74 ++++----- htdocs/fourn/commande/document.php | 2 +- htdocs/fourn/commande/index.php | 4 +- htdocs/fourn/commande/info.php | 6 +- htdocs/fourn/commande/list.php | 8 +- htdocs/fourn/commande/note.php | 2 +- htdocs/fourn/contact.php | 2 +- htdocs/fourn/facture/card-rec.php | 26 +-- htdocs/fourn/facture/card.php | 148 +++++++++--------- htdocs/fourn/facture/contact.php | 4 +- htdocs/fourn/facture/document.php | 4 +- htdocs/fourn/facture/index.php | 4 +- htdocs/fourn/facture/info.php | 4 +- htdocs/fourn/facture/list.php | 6 +- htdocs/fourn/facture/note.php | 4 +- htdocs/fourn/facture/paiement.php | 2 +- htdocs/fourn/index.php | 4 +- htdocs/fourn/paiement/card.php | 16 +- htdocs/fourn/paiement/list.php | 10 +- htdocs/fourn/recap-fourn.php | 2 +- htdocs/ftp/admin/ftpclient.php | 2 +- htdocs/ftp/index.php | 2 +- 95 files changed, 668 insertions(+), 668 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ef0c2b74009..168e6367fcc 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1157,7 +1157,7 @@ if ($mode == 'marketplace') { - - -"; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index d5e5892ac74..838fe0fc1c0 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -117,7 +117,7 @@ if (getDolGlobalString('ADD_UNSPLASH_LOGIN_BACKGROUND')) { // For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random' ?> - > @@ -249,7 +249,7 @@ if (!empty($captcha)) { -element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines ?> trans('SupplierRef'); ?> - trans('VAT'); ?> @@ -846,13 +846,13 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { ?> console.log("Countries are both IN and states are same, so we revert I into CS in default_vat_code="+default_vat_code); new_default_vat_code = default_vat_code.replace(/^I\-/, 'C+S-'); -country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code != $object->thirdparty->state_code) { // We are in India and states differs, we revert the vat code "CS-x" into "I-x" ?> console.log("Countries are both IN and states differs, so we revert CS into I in default_vat_code="+default_vat_code); new_default_vat_code = default_vat_code.replace(/^C\+S\-/, 'I-'); - if (new_default_vat_code != default_vat_code && jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val()) { @@ -1200,7 +1200,7 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { setforpredef(); - + }); /* Function to set fields visibility after selecting a free product */ diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 702ce8a732a..6371f10ab16 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -179,7 +179,7 @@ if (!empty($captcha)) { - -array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')), 'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'supplier', 'class="pictofixedwidth"')), ); -if (!empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) { +if (getDolGlobalString('DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT')) { $arrayofparameters['Contact'] = array( 'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')), 'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')), diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index e54ec55a94b..960a1013bdf 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -171,7 +171,7 @@ class ActionsDatapolicy extends CommonHookActions global $conf, $langs; $langs->load('datapolicy@datapolicy'); - if (!empty($conf->global->DATAPOLICY_ENABLE_EMAILS)) { + if (getDolGlobalString('DATAPOLICY_ENABLE_EMAILS')) { $dialog = '"; diff --git a/htdocs/datapolicy/lib/datapolicy.lib.php b/htdocs/datapolicy/lib/datapolicy.lib.php index 2f195bfc3ab..548f5805635 100644 --- a/htdocs/datapolicy/lib/datapolicy.lib.php +++ b/htdocs/datapolicy/lib/datapolicy.lib.php @@ -41,7 +41,7 @@ function datapolicyAdminPrepareHead() $head[$h][2] = 'settings'; $h++; - if (!empty($conf->global->DATAPOLICY_ENABLE_EMAILS) || getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if (getDolGlobalString('DATAPOLICY_ENABLE_EMAILS') || getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $head[$h][0] = DOL_URL_ROOT."/datapolicy/admin/setupmail.php"; $head[$h][1] = $langs->trans("DATAPOLICYMail"); $head[$h][2] = 'emailing'; diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index f7338863ea8..8c896d276d2 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -67,7 +67,7 @@ if (empty($conf->dav->enabled)) { } // Restrict API to some IPs -if (!empty($conf->global->DAV_RESTRICT_ON_IP)) { +if (getDolGlobalString('DAV_RESTRICT_ON_IP')) { $allowedip = explode(' ', $conf->global->DAV_RESTRICT_ON_IP); $ipremote = getUserRemoteIP(); if (!in_array($ipremote, $allowedip)) { @@ -171,13 +171,13 @@ $nodes = array(); // Enable directories and features according to DAV setup // Public dir -if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) { +if (getDolGlobalString('DAV_ALLOW_PUBLIC_DIR')) { $nodes[] = new \Sabre\DAV\FS\Directory($publicDir); } // Private dir $nodes[] = new \Sabre\DAV\FS\Directory($privateDir); // ECM dir -if (isModEnabled('ecm') && !empty($conf->global->DAV_ALLOW_ECM_DIR)) { +if (isModEnabled('ecm') && getDolGlobalString('DAV_ALLOW_ECM_DIR')) { $nodes[] = new \Sabre\DAV\FS\Directory($ecmDir); } @@ -207,7 +207,7 @@ if (isset($baseUri)) { } // Add authentication function -if ((empty($conf->global->DAV_ALLOW_PUBLIC_DIR) +if ((!getDolGlobalString('DAV_ALLOW_PUBLIC_DIR') || !preg_match('/'.preg_quote(DOL_URL_ROOT.'/dav/fileserver.php/public', '/').'/', $_SERVER["PHP_SELF"])) && !preg_match('/^sabreAction=asset&assetName=[a-zA-Z0-9%\-\/]+\.(png|css|woff|ico|ttf)$/', $_SERVER["QUERY_STRING"]) // URL for Sabre browser resources ) { @@ -220,7 +220,7 @@ $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend); $server->addPlugin($lockPlugin); // Support for the html browser -if (empty($conf->global->DAV_DISABLE_BROWSER)) { +if (!getDolGlobalString('DAV_DISABLE_BROWSER')) { $browser = new \Sabre\DAV\Browser\Plugin(); $server->addPlugin($browser); } diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php index 35b4e8eed29..98cb42b0834 100644 --- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php @@ -113,7 +113,7 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid $info .= $langs->trans('ID').': '.getDolGlobalString("MAIN_MAIL_SMTPS_IDT").'
'; $info .= $langs->trans('Pwd').': '.preg_replace('/./', '*', getDolGlobalString("MAIN_MAIL_SMTPS_PW")).'
'; $info .= $langs->trans('TLS/STARTTLS').': '.getDolGlobalString("MAIN_MAIL_EMAIL_TLS").' / '.getDolGlobalString("MAIN_MAIL_EMAIL_STARTTLS").'
'; - $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.(empty($conf->global->MAIN_DISABLE_ALL_MAILS) ? $langs->trans('No') : $langs->trans('Yes')).'
'; + $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.(!getDolGlobalString('MAIN_DISABLE_ALL_MAILS') ? $langs->trans('No') : $langs->trans('Yes')).'
'; $info .= 'dolibarr_mailing_limit_sendbyweb = '.$dolibarr_mailing_limit_sendbyweb.'
'; $info .= 'dolibarr_mailing_limit_sendbycli = '.$dolibarr_mailing_limit_sendbycli.'
'; $info .= 'dolibarr_mailing_limit_sendbyday = '.$dolibarr_mailing_limit_sendbyday.'
'; diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index bd49839fc02..b597c9bd332 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -135,13 +135,13 @@ if ($action == 'add') { $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('expedition', 'delivery', 'creer')) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('expedition', 'delivery_advance', 'validate'))) + ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery', 'creer')) + || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery_advance', 'validate'))) ) { $result = $object->valid($user); // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -537,7 +537,7 @@ if ($action == 'create') { $product->fetch($object->lines[$i]->fk_product); // Define output language - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -642,8 +642,8 @@ if ($action == 'create') { print '
'; if ($object->statut == 0 && $num_prod > 0) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('expedition', 'delivery', 'creer')) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('expedition', 'delivery_advance', 'validate'))) { + if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery', 'creer')) + || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery_advance', 'validate'))) { print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=valid&token='.newToken().'&id='.$object->id, ''); } } diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index b890746e2a4..b07e7f412d6 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -409,9 +409,9 @@ class Delivery extends CommonObject $error = 0; - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('expedition', 'delivery', 'creer')) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('expedition', 'delivery_advance', 'validate'))) { - if (!empty($conf->global->DELIVERY_ADDON_NUMBER)) { + if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery', 'creer')) + || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery_advance', 'validate'))) { + if (getDolGlobalString('DELIVERY_ADDON_NUMBER')) { // Setting the command numbering module name $modName = $conf->global->DELIVERY_ADDON_NUMBER; @@ -569,7 +569,7 @@ class Delivery extends CommonObject $line->description = $expedition->lines[$i]->description; $line->qty = $expedition->lines[$i]->qty_shipped; $line->fk_product = $expedition->lines[$i]->fk_product; - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) { // For avoid conflicts if trigger used + if (!getDolGlobalString('MAIN_EXTRAFIELDS_DISABLED') && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) { // For avoid conflicts if trigger used $line->array_options = $expedition->lines[$i]->array_options; } $this->lines[$i] = $line; @@ -606,7 +606,7 @@ class Delivery extends CommonObject global $conf; $error = 0; - if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used + if ($id > 0 && !$error && !getDolGlobalString('MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used $line = new DeliveryLine($this->db); $line->array_options = $array_options; $line->id = $id; @@ -643,7 +643,7 @@ class Delivery extends CommonObject $line->origin_id = $origin_id; $line->qty = $qty; - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used + if (!getDolGlobalString('MAIN_EXTRAFIELDS_DISABLED') && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used $line->array_options = $array_options; } $this->lines[$num] = $line; @@ -1125,7 +1125,7 @@ class Delivery extends CommonObject if ($this->model_pdf) { $modele = $this->model_pdf; - } elseif (!empty($conf->global->DELIVERY_ADDON_PDF)) { + } elseif (getDolGlobalString('DELIVERY_ADDON_PDF')) { $modele = $conf->global->DELIVERY_ADDON_PDF; } } diff --git a/htdocs/delivery/tpl/linkedobjectblock.tpl.php b/htdocs/delivery/tpl/linkedobjectblock.tpl.php index fae712658f7..3c7e12abe45 100644 --- a/htdocs/delivery/tpl/linkedobjectblock.tpl.php +++ b/htdocs/delivery/tpl/linkedobjectblock.tpl.php @@ -48,7 +48,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } echo ''; echo ''.$langs->trans("Delivery"); - if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { + if (!empty($showImportButton) && getDolGlobalString('MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES')) { print ' '; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index eb8c8069ed7..eaa8a1c3969 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -131,7 +131,7 @@ if (empty($reshook)) { $result = $object->reopen($user); if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; @@ -225,7 +225,7 @@ if (empty($reshook)) { $error = 0; - if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) { + if (isModEnabled("societe") && getDolGlobalString('DONATION_USE_THIRDPARTIES') && !(GETPOST("socid", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); $action = "create"; $error++; @@ -417,7 +417,7 @@ if ($action == 'create') { print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; // Company - if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (isModEnabled("societe") && getDolGlobalString('DONATION_USE_THIRDPARTIES')) { // Thirdparty if ($soc->id > 0) { print ''.$langs->trans('ThirdParty').''; @@ -443,7 +443,7 @@ if ($action == 'create') { $filter = '((s.client:IN:1,2,3) AND (status:=:1))'; print $form->select_company($soc->id, 'socid', $filter, 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input - if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { + if (getDolGlobalString('RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED')) { print '