From 820247dbd69b49d1704e7d93951e65c144cb75e3 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 21 Mar 2024 15:54:29 +0100 Subject: [PATCH 001/315] Fix condition in createDictionary for modulebuilder --- htdocs/core/lib/modulebuilder.lib.php | 6 ++---- htdocs/modulebuilder/index.php | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 0250110d229..200b3422d3a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -1288,7 +1288,7 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul } $columns = array( - 'rowid' => array('type' => 'integer', 'value' => 11, 'extra' => 'AUTO_INCREMENT PRIMARY KEY'), + 'rowid' => array('type' => 'integer', 'value' => 11, 'extra' => 'AUTO_INCREMENT'), 'code' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), 'label' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), 'position' => array('type' => 'integer', 'value' => 11, 'null'=>'NULL'), @@ -1310,9 +1310,7 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul } // check if tablename exist in Database and create it if not - // @FIXME We must use $db->DDLDescTable($table) to know if a table exists. - $query = "SHOW TABLES LIKE '" . $db->escape(MAIN_DB_PREFIX.strtolower($namedic)) . "'"; - $checkTable = $db->query($query); + $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($namedic)); if ($checkTable && $db->num_rows($checkTable) > 0) { setEventMessages($langs->trans("ErrorTableExist", $namedic), null, 'errors'); return; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 3c0d1e41776..d7148121d4b 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2102,8 +2102,7 @@ if (($dirins && $action == 'confirm_deletedictionary' && $dicname) || ($dirins & } //chercher la table dicname - $query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($newdicname) . "'"; - $checkTable = $db->query($query); + $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname)); if ($checkTable && $db->num_rows($checkTable) <= 0) { $error++; } From 522a012053eaf7390081fc7292683dc44fe544cf Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Mar 2024 16:13:54 +0100 Subject: [PATCH 002/315] FIX Accountancy export with file or not --- .../accountancy/class/accountancyexport.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index c515b7230b2..d986e5c0d56 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2023 Alexandre Spangaro + * Copyright (C) 2016-2024 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz @@ -385,11 +385,12 @@ class AccountancyExport // directory already created when module is enabled $outputDir .= '/export'; $outputDir .= '/'.dol_sanitizePathName($formatexportset); - if (!dol_is_dir($outputDir)) { - if (dol_mkdir($outputDir) < 0) { - $this->errors[] = $langs->trans('ErrorCanNotCreateDir', $outputDir); - return -1; - } + } + + if (!dol_is_dir($outputDir)) { + if (dol_mkdir($outputDir) < 0) { + $this->errors[] = $langs->trans('ErrorCanNotCreateDir', $outputDir); + return -1; } } From e1fc40d694c8622199ba6e3d43d48cb9b79ba673 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Mar 2024 19:36:15 +0100 Subject: [PATCH 003/315] FIX wrong shortcut key for macintosh --- htdocs/main.inc.php | 68 ++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 64652fd3dd1..f1e18f07178 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2575,17 +2575,24 @@ function top_menu_quickadd() { global $conf, $langs; + $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); + $ostype = $tmp['browseros']; + $html = ''; // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox // accesskey is for Mac: CTRL + key for all browsers $stringforfirstkey = $langs->trans("KeyboardShortcut"); - if ($conf->browser->name == 'chrome') { - $stringforfirstkey .= ' ALT +'; - } elseif ($conf->browser->name == 'firefox') { - $stringforfirstkey .= ' ALT + SHIFT +'; - } else { + if ($ostype === 'macintosh') { $stringforfirstkey .= ' CTL +'; + } else { + if ($conf->browser->name == 'chrome') { + $stringforfirstkey .= ' ALT +'; + } elseif ($conf->browser->name == 'firefox') { + $stringforfirstkey .= ' ALT + SHIFT +'; + } else { + $stringforfirstkey .= ' CTL +'; + } } $html .= ' @@ -2610,10 +2617,18 @@ function top_menu_quickadd() // Key map shortcut $(document).keydown(function(event){ - if ( event.which === 76 && event.ctrlKey && event.shiftKey ){ - console.log(\'control + shift + l : trigger open quick add dropdown\'); - openQuickAddDropDown(event); - } + var ostype = "'.$ostype.'"; + if (ostype === "macintosh") { + if ( event.which === 65 && event.ctrlKey ) { + console.log(\'control + a : trigger open quick add dropdown\'); + openQuickAddDropDown(event); + } else { + if ( event.which === 65 && event.ctrlKey && event.shiftKey ) { + console.log(\'control + shift + a : trigger open quick add dropdown\'); + openQuickAddDropDown(event); + } + } + } }); var openQuickAddDropDown = function(event) { @@ -2822,15 +2837,22 @@ function top_menu_bookmark() return $html; } + $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); + $ostype = $tmp['browseros']; + // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox // accesskey is for Mac: CTRL + key for all browsers $stringforfirstkey = $langs->trans("KeyboardShortcut"); - if ($conf->browser->name == 'chrome') { - $stringforfirstkey .= ' ALT +'; - } elseif ($conf->browser->name == 'firefox') { - $stringforfirstkey .= ' ALT + SHIFT +'; - } else { + if ($ostype === 'macintosh') { $stringforfirstkey .= ' CTL +'; + } else { + if ($conf->browser->name == 'chrome') { + $stringforfirstkey .= ' ALT +'; + } elseif ($conf->browser->name == 'firefox') { + $stringforfirstkey .= ' ALT + SHIFT +'; + } else { + $stringforfirstkey .= ' CTL +'; + } } if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) { // This may be set by some pages that use different jquery version to avoid errors @@ -2868,11 +2890,19 @@ function top_menu_bookmark() }); // Key map shortcut - jQuery(document).keydown(function(event){ - if( event.which === 77 && event.ctrlKey && event.shiftKey ){ - console.log("Click on control + shift + m : trigger open bookmark dropdown"); - openBookMarkDropDown(event); - } + jQuery(document).keydown(function(event) { + var ostype = "'.$ostype.'"; + if (ostype === "macintosh") { + if ( event.which === 66 && event.ctrlKey ) { + console.log("Click on control + b : trigger open bookmark dropdown"); + openBookMarkDropDown(event); + } + } else { + if ( event.which === 66 && event.ctrlKey && event.shiftKey ) { + console.log("Click on control + shift + b : trigger open bookmark dropdown"); + openBookMarkDropDown(event); + } + } }); var openBookMarkDropDown = function(event) { From 3b9be9779279eae7781c30cdf16e47f828c2ea71 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Mar 2024 19:40:14 +0100 Subject: [PATCH 004/315] FIX syntax error --- htdocs/main.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f1e18f07178..ab01142c1f9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2622,11 +2622,11 @@ function top_menu_quickadd() if ( event.which === 65 && event.ctrlKey ) { console.log(\'control + a : trigger open quick add dropdown\'); openQuickAddDropDown(event); - } else { - if ( event.which === 65 && event.ctrlKey && event.shiftKey ) { - console.log(\'control + shift + a : trigger open quick add dropdown\'); - openQuickAddDropDown(event); - } + } + } else { + if ( event.which === 65 && event.ctrlKey && event.shiftKey ) { + console.log(\'control + shift + a : trigger open quick add dropdown\'); + openQuickAddDropDown(event); } } }); From 48e85e6690da5b4f7b46b1b9ec8febf7082bdf51 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Mar 2024 20:15:21 +0100 Subject: [PATCH 005/315] FIX use $conf->browser->os instead --- htdocs/main.inc.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ab01142c1f9..9d95f466254 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2575,15 +2575,12 @@ function top_menu_quickadd() { global $conf, $langs; - $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); - $ostype = $tmp['browseros']; - $html = ''; // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox // accesskey is for Mac: CTRL + key for all browsers $stringforfirstkey = $langs->trans("KeyboardShortcut"); - if ($ostype === 'macintosh') { + if ($conf->browser->os === 'macintosh') { $stringforfirstkey .= ' CTL +'; } else { if ($conf->browser->name == 'chrome') { @@ -2617,7 +2614,7 @@ function top_menu_quickadd() // Key map shortcut $(document).keydown(function(event){ - var ostype = "'.$ostype.'"; + var ostype = "'.$conf->browser->os.'"; if (ostype === "macintosh") { if ( event.which === 65 && event.ctrlKey ) { console.log(\'control + a : trigger open quick add dropdown\'); @@ -2837,13 +2834,10 @@ function top_menu_bookmark() return $html; } - $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); - $ostype = $tmp['browseros']; - // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox // accesskey is for Mac: CTRL + key for all browsers $stringforfirstkey = $langs->trans("KeyboardShortcut"); - if ($ostype === 'macintosh') { + if ($conf->browser->os === 'macintosh') { $stringforfirstkey .= ' CTL +'; } else { if ($conf->browser->name == 'chrome') { @@ -2891,7 +2885,7 @@ function top_menu_bookmark() // Key map shortcut jQuery(document).keydown(function(event) { - var ostype = "'.$ostype.'"; + var ostype = "'.$conf->browser->os.'"; if (ostype === "macintosh") { if ( event.which === 66 && event.ctrlKey ) { console.log("Click on control + b : trigger open bookmark dropdown"); From 911eb9fc9e6e34b0c8d5bbc877002d6a45f4abfe Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Tue, 26 Mar 2024 21:31:54 +0100 Subject: [PATCH 006/315] FIX : MRP devide product not working https://www.dolibarr.fr/forum/t/probleme-division-ligne-consommation-produit-dans-module-mrp/45898 --- htdocs/mrp/js/lib_dispatch.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index 58c3abc68f5..01077ab77e5 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -160,7 +160,7 @@ function addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, in $.jnotify(errormsg, 'error', true); return -1; } else if (qtyDispatched >= qtyOrdered) { - let errormsg = 'trans('NoRemainQtyToDispatch')); ?>; + let errormsg = 'trans('NoRemainQtyToDispatch')); ?>'; $.jnotify(errormsg, 'error', true); return -1; } else if (qtyDispatched < qtyOrdered) { From 0a2481c702a8c69f8410d51212ac62112f4a8838 Mon Sep 17 00:00:00 2001 From: Yamil Esteban Garcia <120027058+developmentOYR@users.noreply.github.com> Date: Tue, 26 Mar 2024 22:14:19 +0100 Subject: [PATCH 007/315] Update fournisseur.facture.class.php IRPF reset when editing the label of a supplier invoice #29049 --- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8284c0cedf2..c300190799c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1168,8 +1168,8 @@ class FactureFournisseur extends CommonInvoice if (isset($this->localtax1)) { $this->localtax1 = trim($this->localtax1); } - if (isset($this->localtax2)) { - $this->localtax2 = trim($this->localtax2); + if (isset($this->total_localtax2)) { + $this->total_localtax2 = trim($this->total_localtax2); } if (empty($this->total_ht)) { $this->total_ht = 0; @@ -1243,7 +1243,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; $sql .= " localtax1=".(isset($this->localtax1) ? ((float) $this->localtax1) : "null").","; - $sql .= " localtax2=".(isset($this->localtax2) ? ((float) $this->localtax2) : "null").","; + $sql .= " localtax2=".(isset($this->total_localtax2) ? ((float) $this->total_localtax2) : "null").","; $sql .= " total_ht=".(isset($this->total_ht) ? ((float) $this->total_ht) : "null").","; $sql .= " total_tva=".(isset($this->total_tva) ? ((float) $this->total_tva) : "null").","; $sql .= " total_ttc=".(isset($this->total_ttc) ? ((float) $this->total_ttc) : "null").","; From be6b2b2470ed2910017633e299ffde9be77ed311 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 20:01:27 +0100 Subject: [PATCH 008/315] Force var type for phan --- htdocs/categories/viewcat.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a277b9b03c8..62edf5920eb 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2020 Josep Lluís Amador + * Copyright (C) 2024 MDW * * 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 @@ -506,6 +507,7 @@ if ($type == Categorie::TYPE_PRODUCT) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Product[] $prods */ + '@phan-var-force Product[] $prods'; // Form to add record into the category $showclassifyform = 1; if ($showclassifyform) { @@ -593,6 +595,7 @@ if ($type == Categorie::TYPE_CUSTOMER) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Societe[] $socs */ + '@phan-var-force Societe[] $socs'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -679,6 +682,7 @@ if ($type == Categorie::TYPE_SUPPLIER) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Fournisseur[] $socs */ + '@phan-var-force Fournisseur[] $socs'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -768,6 +772,7 @@ if ($type == Categorie::TYPE_MEMBER) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Adherent[] $members */ + '@phan-var-force Adherent[] $members'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -856,6 +861,7 @@ if ($type == Categorie::TYPE_CONTACT) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Contact[] $contacts */ + '@phan-var-force Contact[] $contacts'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -949,6 +955,7 @@ if ($type == Categorie::TYPE_ACCOUNT) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Account[] $accounts */ + '@phan-var-force Account[] $accounts'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -1038,6 +1045,7 @@ if ($type == Categorie::TYPE_PROJECT) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Project $object */ + '@phan-var-force Project $object'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -1125,6 +1133,7 @@ if ($type == Categorie::TYPE_USER) { dol_print_error($db, $object->error, $object->errors); } else { /** @var User[] $users */ + '@phan-var-force User[] $users'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { @@ -1211,6 +1220,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Entrepot[] $objects */ + '@phan-var-force Entrepot[] $objects'; print '
'; print ''; print ''; @@ -1278,6 +1288,7 @@ if ($type == Categorie::TYPE_TICKET) { dol_print_error($db, $object->error, $object->errors); } else { /** @var Ticket[] $tickets */ + '@phan-var-force Ticket[] $tickets'; // Form to add record into a category $showclassifyform = 1; if ($showclassifyform) { From 2cbd57654af0f3867aa4d047746956876e812588 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:01:03 +0100 Subject: [PATCH 009/315] Improve PHPdoc for getEntity/setEntity --- htdocs/core/lib/functions.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3ff1c19a100..531818db4a4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -336,10 +336,10 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', * 'email_template', 'event', 'donation' * 'c_paiement', 'c_payment_term', ... - * @param int $shared 0=Return id of current entity only, + * @param int<0,1> $shared 0=Return id of current entity only, * 1=Return id of current entity + shared entities (default) - * @param object $currentobject Current object if needed - * @return mixed Entity id(s) to use ( eg. entity IN ('.getEntity(elementname).')' ) + * @param ?CommonObject $currentobject Current object if needed + * @return string Entity id(s) to use ( eg. entity IN ('.getEntity(elementname).')' ) */ function getEntity($element, $shared = 1, $currentobject = null) { @@ -401,8 +401,8 @@ function getEntity($element, $shared = 1, $currentobject = null) /** * Set entity id to use when to create an object * - * @param object $currentobject Current object - * @return mixed Entity id to use ( eg. entity = '.setEntity($object) ) + * @param CommonObject $currentobject Current object + * @return int Entity id to use ( eg. entity = '.setEntity($object) ) */ function setEntity($currentobject) { From be1d54748b328af3a15f2dc1182d73df7b63fa73 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:04:19 +0100 Subject: [PATCH 010/315] Force dynamic class types --- htdocs/adherents/admin/member.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index d93ba0b2138..7d3fec544f1 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -10,6 +10,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2020-2021 Frédéric France * Copyright (C) 2023 Waël Almoman + * Copyright (C) 2024 MDW * * 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 @@ -286,6 +287,7 @@ foreach ($dirModMember as $dirroot) { } $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); +'@phan-var-force array $arrayofmodules'; foreach ($arrayofmodules as $file => $modCodeMember) { print ''."\n"; From 73af9d5b920f7d83936f3ba7a7c58198ce352db8 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:10:11 +0100 Subject: [PATCH 011/315] Ignore notice + phpdoc --- htdocs/admin/modules.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 435fb37e1f6..a551752ad06 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -864,6 +864,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { if (!empty($objMod->disabled)) { $codeenabledisable .= $langs->trans("Disabled"); } elseif (!empty($objMod->always_enabled) || ((isModEnabled('multicompany') && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) { + // @phan-suppress-next-line PhanUndeclaredMethodCall if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= $langs->trans("Used"); } else { @@ -874,6 +875,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $disableSetup++; } } else { + // @phan-suppress-next-line PhanUndeclaredMethodCall if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code]).'&value='.$modName.'&mode='.$mode.$param.'">'; $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on'); From 29b933b550ef15c5cb203b5330dfe7041ab95a54 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:12:37 +0100 Subject: [PATCH 012/315] Force ModeleBarCode type --- htdocs/barcode/printsheet.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 6ee4e9c9ac7..db52b5aaf19 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -179,6 +179,7 @@ if (empty($reshook)) { // Load barcode class for generating barcode image $classname = "mod".ucfirst($generator); $module = new $classname($db); + '@phan-var-force ModeleBarCode $module'; if ($generator != 'tcpdfbarcode') { // May be phpbarcode $template = 'standardlabel'; From 716a543af219c82ea03e048f1f5736e76e3eb771 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:17:02 +0100 Subject: [PATCH 013/315] Improve phpdoc typing --- htdocs/blockedlog/class/blockedlog.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 64f69ea390d..476e1b3d82f 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -371,13 +371,13 @@ class BlockedLog } /** - * Populate properties of log from object data + * Populate properties of log from object data * - * @param Object $object object to store - * @param string $action action - * @param string $amounts amounts - * @param User $fuser User object (forced) - * @return int >0 if OK, <0 if KO + * @param CommonObject $object object to store + * @param string $action action + * @param string $amounts amounts + * @param ?User $fuser User object (forced) + * @return int >0 if OK, <0 if KO */ public function setObjectData(&$object, $action, $amounts, $fuser = null) { From 92bdf2308c414f8ccf98172156f4327879f197f2 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:34:32 +0100 Subject: [PATCH 014/315] Add abstract method for improved typing check --- htdocs/core/modules/bank/modules_bank.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/modules/bank/modules_bank.php b/htdocs/core/modules/bank/modules_bank.php index 682c9fe4de9..5367ae52e8c 100644 --- a/htdocs/core/modules/bank/modules_bank.php +++ b/htdocs/core/modules/bank/modules_bank.php @@ -1,6 +1,7 @@ * Copyright (C) 2014 Marcos García + * Copyright (C) 2024 MDW * * 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 @@ -50,4 +51,15 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator return $list; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write the document to disk + * + * @param Account $object Object Account to generate + * @param Translate $outputlangs Lang output object + * @return int 1 if OK, <=0 if KO + */ + abstract public function write_file($object, $outputlangs); + // phpcs:enable } From b29f3a609dd1707d9252992e22e19d4a1033b22d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:28 +0100 Subject: [PATCH 015/315] Force typing (phan) for typing checks --- htdocs/adherents/class/adherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 999c275368d..e975de2f25a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -674,6 +674,7 @@ class Adherent extends CommonObject require_once $modfile; $modname = getDolGlobalString('MEMBER_CODEMEMBER_ADDON'); $modCodeMember = new $modname(); + '@phan-var-force ModeleNumRefMembers $modCodeMember'; $this->ref = $modCodeMember->getNextValue($mysoc, $this); } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); From 613a90be69cea2cce0d3f6b0429f3ded0230b007 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:30 +0100 Subject: [PATCH 016/315] Force typing (phan) for typing checks --- htdocs/admin/agenda_other.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index dcc7cdec446..62a63e4a13e 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -137,6 +137,7 @@ if ($action == 'set') { require_once $file; $module = new $classname($db, $commande); + '@phan-var-force pdf_standard_actions $module'; if ($module->write_file($commande, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); From b867e21c94180a9416590a0a3786c917fec5a4a4 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:33 +0100 Subject: [PATCH 017/315] Force typing (phan) for typing checks --- htdocs/admin/agenda_reminder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index cdc6a2b8647..c5d87de3a61 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -100,6 +100,7 @@ if ($action == 'set') { require_once $file; $module = new $classname($db, $commande); + '@phan-var-force pdf_standard_actions $module'; if ($module->write_file($commande, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); From 5ad7a9b7ae3be925df24db099845b06d275c85e3 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:36 +0100 Subject: [PATCH 018/315] Force typing (phan) for typing checks --- htdocs/admin/bank.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 865b54f5878..c972fa24468 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -145,6 +145,7 @@ if ($action == 'specimen') { require_once $file; $module = new $classname($db); + '@phan-var-force ModeleBankAccountDoc $module'; if ($module->write_file($object, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); From 8c9a48f4b14743b7a235096e7a81571b5fee77cd Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:39 +0100 Subject: [PATCH 019/315] Force typing (phan) for typing checks --- htdocs/admin/barcode.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 49f2dc3380c..b856a2cef3e 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent + * Copyright (C) 2024 MDW * * 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 @@ -189,7 +190,7 @@ foreach ($dirbarcode as $reldir) { } } } - +'@phan-var-force array $barcodelist'; // Select barcode numbering module @@ -224,6 +225,7 @@ if (isModEnabled('product')) { } $modBarCode = new $file(); + '@phan-var-force ModeleNumRefBarCode $modBarCode'; print ''; print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; From eb086eadb8332c44b9af112a4ac654968006873d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:42 +0100 Subject: [PATCH 020/315] Force typing (phan) for typing checks --- htdocs/admin/bom.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index ebfa4e6772a..2e7945930fd 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -90,6 +90,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force ModelePDFBom $module'; if ($module->write_file($bom, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf"); From 64d257973315fdedfa296c1772f917293be6f281 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:45 +0100 Subject: [PATCH 021/315] Force typing (phan) for typing checks --- htdocs/admin/chequereceipts.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index ec4bb7cf47d..15f1f8a10e9 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2024 MDW * * 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 @@ -151,6 +152,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.$filebis; $module = new $classname($db); + '@phan-var-force ModeleNumRefChequeReceipts $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From 384f2f210a711b668af2fbf016759e2ee23be636 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:48 +0100 Subject: [PATCH 022/315] Force typing (phan) for typing checks --- htdocs/admin/commande.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index af9db12a62b..0376d551144 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -100,6 +100,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force ModelePDFCommandes $module'; if ($module->write_file($commande, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); From 526fcee6689388e6ab8933ed00716b1c2ceff855 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:51 +0100 Subject: [PATCH 023/315] Force typing (phan) for typing checks --- htdocs/admin/contract.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 89e09907a6e..6136ce996f3 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -96,6 +96,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force ModelePDFContract $module'; if ($module->write_file($contract, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf"); From c5f5a378d1d1d679a8c78eedacff508797269101 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:55 +0100 Subject: [PATCH 024/315] Force typing (phan) for typing checks --- htdocs/admin/delivery.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index 2c66f284c7d..77396c41685 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -145,6 +145,7 @@ if ($action == 'specimen') { require_once $file; $module = new $classname($db); + '@phan-var-force ModelePDFDeliveryOrder $module'; if ($module->write_file($sending, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf"); From 521a039073515bc4754a0ab9e23c05a303f3834f Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:35:58 +0100 Subject: [PATCH 025/315] Force typing (phan) for typing checks --- htdocs/admin/expedition.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 082d2a39741..af07348db7e 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -116,6 +116,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force ModelePdfExpedition $module'; if ($module->write_file($exp, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf"); From f73f2664e5f5923893c02407187ec64dadec1359 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:01 +0100 Subject: [PATCH 026/315] Force typing (phan) for typing checks --- htdocs/admin/expensereport.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index d0fa6cfd98b..088c7dad8ae 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -97,6 +97,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force ModeleExpenseReport $module'; if ($module->write_file($expensespecimen, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expensereport&file=SPECIMEN.pdf"); From 5bde94de4f100c74c4efb4b1eeb34e2b34ed6aed Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:04 +0100 Subject: [PATCH 027/315] Force typing (phan) for typing checks --- htdocs/admin/fichinter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 250d4d9e2cd..bb5c6d41f5a 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -96,6 +96,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force ModelePDFFicheinter $module'; if ($module->write_file($inter, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf"); From 05f234b68a1f80f4f840c8961fa59b238209426c Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:07 +0100 Subject: [PATCH 028/315] Force typing (phan) for typing checks --- htdocs/admin/holiday.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 1a8a343ea69..21ae01b1f3f 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -96,6 +96,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($holiday, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); From 528af842e81fff284ed010dd838dec975f32ea0b Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:10 +0100 Subject: [PATCH 029/315] Force typing (phan) for typing checks --- htdocs/admin/hrm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index c55622f1a11..74d4bd26748 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -140,6 +140,7 @@ if ($action == 'update') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($tmpobject, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); From 31d7c5f0b4132515d144e9d95da1a5da6aaf5e8d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:13 +0100 Subject: [PATCH 030/315] Force typing (phan) for typing checks --- htdocs/admin/invoice.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/invoice.php b/htdocs/admin/invoice.php index fa0e810f33b..649ef89f142 100644 --- a/htdocs/admin/invoice.php +++ b/htdocs/admin/invoice.php @@ -113,6 +113,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($facture, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); From c2b4da27a417d4e92e7b26ad80658d03ee988a42 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:16 +0100 Subject: [PATCH 031/315] Force typing (phan) for typing checks --- htdocs/admin/knowledgemanagement.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index ef80a03cbcb..72a71d50949 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -123,6 +123,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $className($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($tmpobject, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); From 2a72f7fa4ada28dbc3f1955c5915d8dad1286582 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:18 +0100 Subject: [PATCH 032/315] Force typing (phan) for typing checks --- htdocs/admin/mrp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index f616df182c4..73470ecd219 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -91,6 +91,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($mo, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf"); From e8ca20d1fe6cbcf6d8120beb003e51320067b2da Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:22 +0100 Subject: [PATCH 033/315] Force typing (phan) for typing checks --- htdocs/admin/payment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 55dc6212a60..07ed45b2d10 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Maxime DEMAREST + * Copyright (C) 2024 MDW * * 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 @@ -154,6 +155,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.$filebis; $module = new $classname($db); + '@phan-var-force ModeleNumRefPayments $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From d409e4615c95ed61e5891a07e7a121ce88664495 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:25 +0100 Subject: [PATCH 034/315] Force typing (phan) for typing checks --- htdocs/admin/propal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 401db58d473..da671b176e4 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -96,6 +96,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($propal, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf"); From c564d434f5c264974caccb2ca4b32e255262ddb8 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:28 +0100 Subject: [PATCH 035/315] Force typing (phan) for typing checks --- htdocs/admin/reception_setup.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index b5f8e336b20..5d8c49b65fb 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -119,6 +119,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($exp, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=reception&file=SPECIMEN.pdf"); From 43a07645c314198544350e1d83fd7dc17d91cf39 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:30 +0100 Subject: [PATCH 036/315] Force typing (phan) for typing checks --- htdocs/admin/security.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index dd8278f19bf..e9bf40231d8 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -207,6 +207,7 @@ if (is_resource($handle)) { require_once $dir.'/'.$file; $obj = new $classname($db, $conf, $langs, $user); + '@phan-var-force ModeleGenPassword $obj'; $arrayhandler[$obj->id] = $obj; $i++; } From 78dbfdda59d4c66f31b41a55fed1e877d14ed92e Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:33 +0100 Subject: [PATCH 037/315] Force typing (phan) for typing checks --- htdocs/admin/stock.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 5ac9f8d5cf4..b840a027850 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -123,6 +123,7 @@ if ($action == 'specimen') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($object, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=stock&file=SPECIMEN.pdf"); @@ -585,6 +586,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force ModelePDFStock $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From e7b67c0aeaa11d8607f612f56125521a122fc0da Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:36 +0100 Subject: [PATCH 038/315] Force typing (phan) for typing checks --- htdocs/admin/stocktransfer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index dee8ebc3b14..b431b110fa4 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -105,6 +105,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($tmpobject, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); From db80e4501b17bfb4c7702de385a0f61c1a466c6e Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:39 +0100 Subject: [PATCH 039/315] Force typing (phan) for typing checks --- htdocs/admin/supplier_invoice.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 38db853af92..c92f87c1784 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -116,6 +116,7 @@ if ($action == 'specimen') { // For invoices require_once $file; $module = new $classname($db, $facture); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($facture, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); From ca980bcee493cc026f62fea330a1807f2698a2d6 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:42 +0100 Subject: [PATCH 040/315] Force typing (phan) for typing checks --- htdocs/admin/supplier_order.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index ecfc2a68b93..101f57e7161 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -106,6 +106,7 @@ if ($action == 'specimen') { // For orders require_once $file; $module = new $classname($db, $commande); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($commande, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); From 798087e7b3b523b0cbf695fd53d8d47b4c5cba0d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:45 +0100 Subject: [PATCH 041/315] Force typing (phan) for typing checks --- htdocs/admin/supplier_payment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index e420a914155..42adc8e7364 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -117,6 +117,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($paiementFourn, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); From 62e21ea5327c76dcb10d481e5149a97826504474 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:48 +0100 Subject: [PATCH 042/315] Force typing (phan) for typing checks --- htdocs/admin/supplier_proposal.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 94197b4bdad..f4563df6118 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -95,6 +95,7 @@ if ($action == 'specimen') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($supplier_proposal, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_proposal&file=SPECIMEN.pdf"); @@ -261,6 +262,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file.'.php'; $module = new $file(); + '@phan-var-force ModeleNumRefSupplierProposal $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -393,6 +395,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From 1db6ea33444f281004dad1068a967d9860d00d7d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:51 +0100 Subject: [PATCH 043/315] Force typing (phan) for typing checks --- htdocs/admin/syslog.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 5475e20d0d1..6503cc05ae6 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -4,6 +4,7 @@ * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -63,6 +64,7 @@ foreach ($dirsyslogs as $reldir) { require_once $newdir.$file.'.php'; $module = new $file(); + '@phan-var-force LogHandler $module'; // Show modules according to features level if ($module->getVersion() == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -96,6 +98,7 @@ if ($action == 'set') { foreach ($syslogModules as $syslogHandler) { if (in_array($syslogHandler, $syslogModules)) { $module = new $syslogHandler(); + '@phan-var-force LogHandler $module'; if (in_array($syslogHandler, $selectedModules)) { $newActiveModules[] = $syslogHandler; @@ -118,6 +121,7 @@ if ($action == 'set') { // Check configuration foreach ($activeModules as $modulename) { $module = new $modulename(); + '@phan-var-force LogHandler $module'; $res = $module->checkConfiguration(); if (!$res) { $error++; @@ -210,6 +214,7 @@ print "\n"; foreach ($syslogModules as $moduleName) { $module = new $moduleName(); + '@phan-var-force LogHandler $module'; $moduleactive = (int) $module->isActive(); //print $moduleName." = ".$moduleactive." - ".$module->getName()." ".($moduleactive == -1)."
\n"; From 2dfb92a55bceb6456b3ec92fe5c6b18d229f7462 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:54 +0100 Subject: [PATCH 044/315] Force typing (phan) for typing checks --- htdocs/admin/system/modules.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index ee4d525609e..71a10e7e7c0 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -115,6 +115,7 @@ foreach ($modulesdir as $dir) { if (class_exists($modName)) { try { $objMod = new $modName($db); + '@phan-var-force DolibarrModules $objMod'; $modules[$objMod->numero] = $objMod; $modules_files[$objMod->numero] = $file; @@ -132,6 +133,7 @@ foreach ($modulesdir as $dir) { closedir($handle); } } +'@phan-var-force array $modules'; // create pre-filtered list for modules foreach ($modules as $key => $module) { From ab707249f627e71a6c7f2763c17b5b7e3e8d9867 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:56 +0100 Subject: [PATCH 045/315] Force typing (phan) for typing checks --- htdocs/admin/ticket.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 60cc1ce67b5..f55ddd2d846 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -3,6 +3,7 @@ * Copyright (C) 2016 Christophe Battarel * Copyright (C) 2022-2023 Udo Tamm * Copyright (C) 2023 Alexandre Spangaro + * Copyright (C) 2024 MDW * * 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 @@ -289,6 +290,7 @@ foreach ($dirmodels as $reldir) { include_once $dir.'/'.$file.'.php'; $module = new $file(); + '@phan-var-force ModeleNumRefTicket $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -423,6 +425,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From 34180e2df415c92dcc6cdc6284fb9e57e556a6e8 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:36:59 +0100 Subject: [PATCH 046/315] Force typing (phan) for typing checks --- htdocs/admin/user.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 6cd21cd1567..4e52671dd61 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2020 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -246,6 +247,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From 19d38dabea5d1899f72463597176244bbc424583 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:02 +0100 Subject: [PATCH 047/315] Force typing (phan) for typing checks --- htdocs/admin/usergroup.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 598b8a687e8..fcd73691cde 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2024 MDW * * 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 @@ -169,6 +170,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From 6e77bd4a58ae2e7d59158f3cfe9d7cd475a55e73 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:05 +0100 Subject: [PATCH 048/315] Force typing (phan) for typing checks --- htdocs/admin/workstation.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 11d0b08e7f3..d7b350a9831 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -107,6 +107,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($tmpobject, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); @@ -260,6 +261,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { require_once $dir.'/'.$file.'.php'; $module = new $file($db); + '@phan-var-force CommonNumRefGenerator $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -399,6 +401,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From 1b66890b3021cde98314f6b88b18a18bee68af17 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:07 +0100 Subject: [PATCH 049/315] Force typing (phan) for typing checks --- htdocs/asset/admin/setup.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 0016c5e82e5..eea47281a3c 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -119,6 +119,7 @@ if ($action == 'updateMask') { require_once $file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; if ($module->write_file($tmpobject, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); @@ -232,6 +233,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { require_once $dir.'/'.$file.'.php'; $module = new $file($db); + '@phan-var-force CommonNumRefGenerator $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -371,6 +373,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { require_once $dir.'/'.$file; $module = new $classname($db); + '@phan-var-force CommonDocGenerator $module'; $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { From f78ad762288c134574c7907920504df0b68bcedb Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:10 +0100 Subject: [PATCH 050/315] Force typing (phan) for typing checks --- htdocs/barcode/codeinit.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 0852c9d6586..73c19e1f96b 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2024 MDW * * 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 @@ -86,6 +87,7 @@ if (getDolGlobalString('BARCODE_THIRDPARTY_ADDON_NUM')) { } $modBarCodeThirdparty = new $file(); + '@phan-var-force ModeleNumRefBarCode $module'; break; } } @@ -190,6 +192,7 @@ if (getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM')) { } $modBarCodeProduct = new $file(); + '@phan-var-force ModeleNumRefBarCode $module'; break; } } From 3d88f94dbe92f0cd579fc18bd5b18507f5002351 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:12 +0100 Subject: [PATCH 051/315] Force typing (phan) for typing checks --- htdocs/comm/mailing/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 8fee4a7935f..5b1b092fdd3 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2010 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2024 MDW * * 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 @@ -101,6 +102,7 @@ if (is_resource($handle)) { $classname = "mailing_".$modulename; require_once $file; $mailmodule = new $classname($db); + '@phan-var-force MailingTargets $mailmodule'; $qualified = 1; foreach ($mailmodule->require_module as $key) { From bf659fee44ccf993b75d3b6f69d368ef402f278e Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:14 +0100 Subject: [PATCH 052/315] Force typing (phan) for typing checks --- htdocs/compta/facture/class/facture.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8f5c63a86f0..12d9172b249 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4635,6 +4635,7 @@ class Facture extends CommonInvoice } $obj = new $classname(); + '@phan-var-force CommonNumRefGenerator $obj'; $numref = $obj->getNextValue($soc, $this, $mode); From 58c676a7e1145f95f90379d5b1940468ad311019 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:16 +0100 Subject: [PATCH 053/315] Force typing (phan) for typing checks --- htdocs/compta/paiement/cheque/class/remisecheque.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 71496b46c6f..70274fd13c3 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -450,6 +450,7 @@ class RemiseCheque extends CommonObject } $obj = new $classname(); + '@phan-var-force CommonNumRefGenerator $obj'; $numref = ""; $numref = $obj->getNextValue($mysoc, $this); @@ -590,6 +591,7 @@ class RemiseCheque extends CommonObject $classname = 'BordereauCheque'.ucfirst($model); $docmodel = new $classname($this->db); + '@phan-var-force CommonDocGenerator $module'; $sql = "SELECT b.banque, b.emetteur, b.amount, b.num_chq"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; From d0631e60bf044dcac4bf2a44e32d298c9a6cd00d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:18 +0100 Subject: [PATCH 054/315] Force typing (phan) for typing checks --- htdocs/contrat/class/contrat.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2f5fe9a8aea..889eab0f993 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -346,6 +346,7 @@ class Contrat extends CommonObject } $obj = new $classname(); + '@phan-var-force CommonNumRefGenerator $obj'; $numref = $obj->getNextValue($soc, $this); if ($numref != "") { @@ -1064,6 +1065,7 @@ class Contrat extends CommonObject $result = dol_include_once('/core/modules/contract/'.$module.'.php'); if ($result > 0) { $modCodeContract = new $module(); + '@phan-var-force CommonNumRefGenerator $modCodeContrat'; if (!empty($modCodeContract->code_auto)) { // Force the ref to a draft value if numbering module is an automatic numbering @@ -2686,6 +2688,7 @@ class Contrat extends CommonObject require_once DOL_DOCUMENT_ROOT."/core/modules/contract/" . getDolGlobalString('CONTRACT_ADDON').'.php'; $obj = getDolGlobalString('CONTRACT_ADDON'); $modContract = new $obj(); + '@phan-var-force CommonNumRefGenerator $modContrat'; $clonedObj->ref = $modContract->getNextValue($objsoc, $clonedObj); // get extrafields so they will be clone From 23e302082db412f8d4f58265cc29164066ab1b77 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:20 +0100 Subject: [PATCH 055/315] Force typing (phan) for typing checks --- htdocs/core/actions_printing.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 496e23c99b3..f96c57ad6a9 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -1,6 +1,7 @@ * Copyright (C) 2014-2018 Frederic France + * Copyright (C) 2024 MDW * * 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 @@ -47,6 +48,7 @@ if ($action == 'print_file' && $user->hasRight('printing', 'read')) { require_once $classfile; $classname = 'printing_'.$driver; $printer = new $classname($db); + '@phan-var-force PrintingDriver $printer'; $langs->load($printer::LANGFILE); //print '
'.print_r($printer, true).'
'; From 6f0340e8ce07c9097f0a4cb46691ce0a890e67e4 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:37:26 +0100 Subject: [PATCH 056/315] Force typing (phan) for typing checks --- htdocs/public/payment/paymentko.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 8e60a9adea9..4e1b3825ca2 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -46,6 +46,8 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +'@phan-var-force CommonObject $object'; + // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; From 8c2b046ca06f91b0a8d9843e07c9ef8b32d80982 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 21:45:51 +0100 Subject: [PATCH 057/315] Suppress PhanUndeclaredMethod notification --- htdocs/core/boxes/box_dolibarr_state_board.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 9785396a49a..73631c07bc9 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2024 Frederic France + * Copyright (C) 2024 MDW * * 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 @@ -69,7 +70,7 @@ class box_dolibarr_state_board extends ModeleBoxes $hookmanager->initHooks(array('index')); $object = new stdClass(); $action = ''; - $parameters =array(); + $parameters = array(); $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); $boxstatItems = array(); $boxstatFromHook = ''; @@ -254,6 +255,7 @@ class box_dolibarr_state_board extends ModeleBoxes $board = new $class($this->db); if (method_exists($board, 'load_state_board')) { + // @phan-suppress-next-line PhanUndeclaredMethod (Legacy, not present in core). $board->load_state_board(); } elseif (method_exists($board, 'loadStateBoard')) { $board->loadStateBoard(); From aba83e9e4278a035ab2757d619b36f8ded295599 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 20:59:34 +0100 Subject: [PATCH 058/315] Add function definitions to stub --- dev/tools/phan/stubs/multicompany.php | 79 ++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/dev/tools/phan/stubs/multicompany.php b/dev/tools/phan/stubs/multicompany.php index db62b11c722..0f2ba3b4e74 100644 --- a/dev/tools/phan/stubs/multicompany.php +++ b/dev/tools/phan/stubs/multicompany.php @@ -1,5 +1,7 @@ + * + * Note: in this context Entity == Company. */ class ActionsMulticompany { @@ -9,12 +11,83 @@ class ActionsMulticompany public function __construct($db) { } - /** @ver string */ + /** @var string */ public $id; - /** @ver string */ + /** @var string */ public $label; /** @var array{stock:string[],referent:string} */ public $sharings; - /** @ver DoliDB */ + /** @var DoliDB */ public $db; + + /** + * @param string $login + * @param bool $bool1 + * @param bool $bool2 + * @return array + */ + public function getEntitiesList($login = '', $bool1 = false, $bool2 = false) + { + } + + /** + * @param string $entity + * @return void + */ + public function getInfo($entity) + { + } + + /** + * @param int $id + * @param string $key + * @param string $param_str + * @param bool $bool1 + * @param bool $bool2 + * @param bool $bool3 + * @param bool $bool4 + * @param bool $bool5 + * @return string */ + public function select_entities($id, $key = '', $param_str = '', $bool1 = false, $bool2 = false, $bool3 = false, $bool4 = false, $bool5 = false) + { + } + + /** + * @param Conf $conf + * @return void + */ + public function setValues($conf) + { + } + /** + * @param string $element + * @param int<0,1> $shared + * @param ?CommonObject $currentobject + * @return string + */ + public function getEntity($element, $shared = 1, $currentobject = 0) + { + } + /** + * @param CommonObject $currentobject + * @return int + */ + public function setEntity($currentobject) + { + } + /** + * @param int $entityid + * @return int<-1,0> + */ + public function switchEntity($entityid) + { + } + /** + * @param int $id + * @param string $entitytotest + * @return int + */ + public function checkRight($id, $entitytotest) + { + } } From 30f15eb77659d2e41e42fc6a8b2d57bac45123d7 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 22:09:29 +0100 Subject: [PATCH 059/315] Force typing (phan) for typing check --- htdocs/product/class/product.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3a09766af48..d8e35f9d572 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -777,6 +777,7 @@ class Product extends CommonObject } dol_include_once('/core/modules/product/'.$module.'.php'); $modCodeProduct = new $module(); + '@phan-var-force ModeleProductCode $modCodeProduct'; if (!empty($modCodeProduct->code_auto)) { $this->ref = $modCodeProduct->getNextValue($this, $this->type); } @@ -1048,6 +1049,7 @@ class Product extends CommonObject } $mod = new $module(); + '@phan-var-force ModeleNumRefBarCode $mod'; dol_syslog(get_class($this)."::check_barcode value=".$valuetotest." type=".$typefortest." module=".$module); $result = $mod->verif($this->db, $valuetotest, $this, 0, $typefortest); @@ -6358,6 +6360,7 @@ class Product extends CommonObject } $var = getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM'); $mod = new $var(); + '@phan-var-force ModeleNumRefBarCode $module'; $result = $mod->getNextValue($object, $type); From 28521f7dcd43157d297981bd5693f9e8a30ae49d Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 22:23:53 +0100 Subject: [PATCH 060/315] Adjust write_file signature --- htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 5cc2c4602db..dc836b18651 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Josep Lluís Amador + * Copyright (C) 2024 MDW * * 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 @@ -115,7 +116,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc /** * Function to create pdf of company bank account sepa mandate * - * @param CompanyBankAccount $object Object bank account to generate document for + * @param Account $object CompanyBankAccount bank account to generate document for * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details (not used for this template) @@ -129,6 +130,11 @@ class pdf_sepamandate extends ModeleBankAccountDoc // phpcs:enable global $conf, $hookmanager, $langs, $user, $mysoc; + if (!$object instanceof CompanyBankAccount) { + dol_syslog(get_class($this)."::write_file object is of type ".get_class($object)." which is not expected", LOG_ERR); + return -1; + } + if (!is_object($outputlangs)) { $outputlangs = $langs; } From 9a65d5fabc9f2d28bc1867753d3c62d0f02c8df5 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 24 Mar 2024 22:32:20 +0100 Subject: [PATCH 061/315] Force LANGFILE constant in subclass --- htdocs/core/modules/printing/modules_printing.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 6eb74a2e93d..95d07d90323 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 MDW * * 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 @@ -31,6 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; */ class PrintingDriver { + /** Force subclass to implement LANGFILE */ + const LANGFILE = self::LANGFILE; + /** * @var DoliDB Database handler. */ @@ -70,8 +74,8 @@ class PrintingDriver * Return list of printing driver * * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of drivers + * @param int $maxfilenamelength Max length of value to show + * @return array List of drivers */ public static function listDrivers($db, $maxfilenamelength = 0) { From fc43b5a252938799fb827be6bb671d33d6949c11 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 10:54:06 +0100 Subject: [PATCH 062/315] Ignore PhanParamTooMany for adherents/admin/member.php # Ignore PhanParamTooMany for adherents/admin/member.php Ignore PhanParamTooMany for adherents/admin/member.php for passing CI; The problem pre-exists and can be fixed later. --- dev/tools/phan/baseline.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 52c70f4f641..46d02c0404f 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -24,6 +24,7 @@ return [ // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ + 'htdocs/adherents/admin/member.php' => ['PhanParamTooMany'], 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], From b06823a811efc054c92aa5ec3446588d1732e814 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 10:13:28 +0100 Subject: [PATCH 063/315] PHPdoc $user argument to fetch is nullable --- htdocs/contact/class/contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 080cc4d5f95..ac7c96194cb 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -975,7 +975,7 @@ class Contact extends CommonObject * Load object contact. * * @param int $id Id of contact - * @param User $user Load also alerts of this user (subscribing to alerts) that want alerts about this contact + * @param ?User $user Load also alerts of this user (subscribing to alerts) that want alerts about this contact * @param string $ref_ext External reference, not given by Dolibarr * @param string $email Email * @param int $loadalsoroles Load also roles. Try to always 0 here and load roles with a separate call of fetchRoles(). From c76baf1e102263181ff74cda42399717757a5b64 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 10:41:11 +0100 Subject: [PATCH 064/315] Fix typing, inits, ignore some phan's, fix caching reuse --- htdocs/core/lib/functions.lib.php | 54 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 531818db4a4..b01c5eec55e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -54,6 +54,7 @@ if (!function_exists('utf8_encode')) { * * @param mixed $elements PHP Object to json encode * @return string Json encoded string + * @phan-suppress PhanRedefineFunctionInternal */ function utf8_encode($elements) { @@ -67,6 +68,7 @@ if (!function_exists('utf8_decode')) { * * @param mixed $elements PHP Object to json encode * @return string Json encoded string + * @phan-suppress PhanRedefineFunctionInternal */ function utf8_decode($elements) { @@ -80,6 +82,7 @@ if (!function_exists('str_starts_with')) { * @param string $haystack haystack * @param string $needle needle * @return boolean + * @phan-suppress PhanRedefineFunctionInternal */ function str_starts_with($haystack, $needle) { @@ -93,6 +96,7 @@ if (!function_exists('str_ends_with')) { * @param string $haystack haystack * @param string $needle needle * @return boolean + * @phan-suppress PhanRedefineFunctionInternal */ function str_ends_with($haystack, $needle) { @@ -106,6 +110,7 @@ if (!function_exists('str_contains')) { * @param string $haystack haystack * @param string $needle needle * @return boolean + * @phan-suppress PhanRedefineFunctionInternal */ function str_contains($haystack, $needle) { @@ -456,7 +461,7 @@ function num2Alpha($n) * ) * * @param string $user_agent Content of $_SERVER["HTTP_USER_AGENT"] variable - * @return array Check function documentation + * @return array{browsername:string,browserversion:string,browseros:string,browserua:string,layout:string,phone:string,tablet:bool} Check function documentation */ function getBrowserInfo($user_agent) { @@ -12117,7 +12122,7 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u * 'action', 'facture', 'project', 'project_task' or * 'myobject@mymodule' or * 'myobject_mysubobject' (where mymodule = myobject, like 'project_task') - * @return array array('module'=>, 'classpath'=>, 'element'=>, 'subelement'=>, 'classfile'=>, 'classname'=>, 'dir_output'=>) + * @return array{module:string,element:string,table_element:string,subelement:string,classpath:string,classfile:string,classname:string,dir_output:string} array('module'=>, 'classpath'=>, 'element'=>, 'subelement'=>, 'classfile'=>, 'classname'=>, 'dir_output'=>) * @see fetchObjectByElement(), getMultiDirOutput() */ function getElementProperties($elementType) @@ -12479,6 +12484,7 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '', $us if (class_exists($element_prop['classname'])) { $className = $element_prop['classname']; $objecttmp = new $className($db); + '@phan-var-force CommonObject $objecttmp'; if ($element_id > 0 || !empty($element_ref)) { $ret = $objecttmp->fetch($element_id, $element_ref); @@ -12869,7 +12875,7 @@ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand = * This is used to output the search criteria in an UFS (Universal Filter Syntax) input component. * * @param string $sqlfilters Universal SQL filter string. Must have been trimmed before. - * @return array Array of AND + * @return string[] Array of AND */ function dolForgeExplodeAnd($sqlfilters) { @@ -12995,7 +13001,7 @@ function dolCheckFilters($sqlfilters, &$error = '', &$parenthesislevel = 0) * Function to forge a SQL criteria from a Dolibarr filter syntax string. * This method is called by forgeSQLFromUniversalSearchCriteria() * - * @param array $matches Array of found string by regex search. Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.nature:is:NULL" + * @param string[] $matches Array of found string by regex search. Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.nature:is:NULL" * @return string Forged criteria. Example: "" or "()" */ function dolForgeDummyCriteriaCallback($matches) @@ -13016,7 +13022,7 @@ function dolForgeDummyCriteriaCallback($matches) * Function to forge a SQL criteria from a Dolibarr filter syntax string. * This method is called by forgeSQLFromUniversalSearchCriteria() * - * @param array $matches Array of found string by regex search. + * @param string[] $matches Array of found string by regex search. * Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.date_creation:<:'2016-01-01 12:30:00'" or "t.nature:is:NULL" * @return string Forged criteria. Example: "t.field LIKE 'abc%'" */ @@ -13097,7 +13103,7 @@ function dolForgeCriteriaCallback($matches) * Get timeline icon * * @param ActionComm $actionstatic actioncomm - * @param array $histo histo + * @param array $histo histo * @param int $key key * @return string String with timeline icon * @deprecated Use actioncomm->getPictoType() instead @@ -13164,7 +13170,7 @@ function getTimelineIcon($actionstatic, &$histo, $key) * getActionCommEcmList * * @param ActionComm $object Object ActionComm - * @return array Array of documents in index table + * @return array Array of documents in index table */ function getActionCommEcmList($object) { @@ -13191,23 +13197,22 @@ function getActionCommEcmList($object) } - /** - * Show html area with actions in messaging format. - * Note: Global parameter $param must be defined. + * Show html area with actions in messaging format. + * Note: Global parameter $param must be defined. * - * @param Conf $conf Object conf - * @param Translate $langs Object langs - * @param DoliDB $db Object db - * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object - * @param Contact|null $objcon Filter on object contact to filter events on a contact - * @param int $noprint Return string but does not output it - * @param string $actioncode Filter on actioncode - * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). - * @param array $filters Filter on other fields - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @return string|void Return html part or void if noprint is 1 + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param DoliDB $db Object db + * @param ?CommonObject $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object + * @param ?Contact $objcon Filter on object contact to filter events on a contact + * @param int $noprint Return string but does not output it + * @param string $actioncode Filter on actioncode + * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). + * @param array $filters Filter on other fields + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @return string|void Return html part or void if noprint is 1 */ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC') { @@ -13237,6 +13242,9 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, } $sortfield_new = implode(',', $sortfield_new_list); + $sql = null; + $sql2 = null; + if (isModEnabled('agenda')) { // Search histo on actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -13433,7 +13441,6 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); - '@phan-var-force array{apicto:string,contact_id:string,dp:string,dp2:string,firstname:string,label:string,message:string,msg_from:string,ref:string,type:string,user_lastname:string} $obj'; if ($obj->type == 'action') { $contactaction = new ActionComm($db); $contactaction->id = $obj->id; @@ -13839,6 +13846,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $conf->cache['contact'][$histo[$key]['contact_id']] = $contact; } else { $contact = $conf->cache['contact'][$histo[$key]['contact_id']]; + $result = ($contact instanceof Contact) ? $contact->id : 0; } if ($result > 0) { From e400e03cfa1f2c235d1955cd74e013e6d0b88a24 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 11:07:23 +0100 Subject: [PATCH 065/315] Fix User arg from 0 to null --- htdocs/webservices/server_contact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 0089b625dfe..4e33e88521c 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -291,7 +291,7 @@ function getContact($authentication, $id, $ref_ext) $fuser->getrights(); $contact = new Contact($db); - $result = $contact->fetch($id, 0, $ref_ext); + $result = $contact->fetch($id, null, $ref_ext); if ($result > 0) { // Only internal user who have contact read permission // Or for external user who have contact read permission, with restrict on socid @@ -655,7 +655,7 @@ function updateContact($authentication, $contact) include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $object = new Contact($db); - $result = $object->fetch($contact['id'], 0, $contact['ref_ext']); + $result = $object->fetch($contact['id'], null, $contact['ref_ext']); if (!empty($object->id)) { $objectfound = true; From 974ecf82fe2f037c5cfcbed27ce07b4d3c702b2e Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 11:09:40 +0100 Subject: [PATCH 066/315] Fix get_class on potential null --- htdocs/core/lib/functions.lib.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b01c5eec55e..4e1a060151a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13280,11 +13280,8 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - if (get_class($filterobj) !== 'User') { - $force_filter_contact = false; - } else { - $force_filter_contact = true; - } + $force_filter_contact = $filterobj instanceof User; + if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; From ba702cf25f364d03f116177362dba783dc95d179 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 13:03:46 +0100 Subject: [PATCH 067/315] PHPdoc for $css, $theme, $modules, $module_parts, $cache --- htdocs/core/class/conf.class.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ca1817e27a3..37677a086b0 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Jean Heimburger + * Copyright (C) 2024 MDW * * 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 @@ -70,19 +71,32 @@ class Conf extends stdClass //! Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol: $langs->getCurrencySymbol($this->currency) public $currency; - //! Used to store current css (from theme) + /** + * @var string + */ public $theme; // Contains current theme ("eldy", "auguria", ...) + //! Used to store current css (from theme) + /** + * @var string + */ public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) public $email_from; //! Used to store current menu handler public $standard_menu; - // List of activated modules + /** + * @var array List of activated modules + */ public $modules; + /** + * @var array> List of activated modules + */ public $modules_parts; - // An array to store cache results ->cache['nameofcache']=... + /** + * @var array An array to store cache results ->cache['nameofcache']=... + */ public $cache; /** From 7c660d33927aaa7532bed40df7e0b648b4de3123 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 13:25:51 +0100 Subject: [PATCH 068/315] PHPdoc improvement: dol_print_error_email, price --- htdocs/core/lib/functions.lib.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4e1a060151a..36f44d7a502 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5696,11 +5696,11 @@ function dol_print_error($db = null, $error = '', $errors = null) /** * Show a public email and error code to contact if technical error * - * @param string $prefixcode Prefix of public error code - * @param string $errormessage Complete error message - * @param array $errormessages Array of error messages - * @param string $morecss More css - * @param string $email Email + * @param string $prefixcode Prefix of public error code + * @param string $errormessage Complete error message + * @param string[] $errormessages Array of error messages + * @param string $morecss More css + * @param string $email Email * @return void */ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = array(), $morecss = 'error', $email = '') @@ -6270,7 +6270,7 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0, * * @param string|float $amount Amount value to format * @param int<0,1> $form Type of formatting: 1=HTML, 0=no formatting (no by default) - * @param Translate|string $outlangs Object langs for output. '' use default lang. 'none' use international separators. + * @param Translate|string|null $outlangs Object langs for output. '' use default lang. 'none' use international separators. * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accuracy) before being inserted into database or after a computation, so this parameter should be useless. * @param int $rounding MINIMUM number of decimal to show: 0=no change, -1=we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) * @param int|string $forcerounding MAXIMUM number of decimal to forcerounding decimal: -1=no change, 'MU' or 'MT' or a numeric to round to MU or MT or to a given number of decimal @@ -6303,7 +6303,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ $thousand = ' '; // If $outlangs not forced, we use use language - if (!is_object($outlangs)) { + if (!($outlangs instanceof Translate)) { $outlangs = $langs; } @@ -6543,17 +6543,17 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; if (($forceunitoutput == 'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) { - $dimension = $dimension * 1000000; + $dimension *= 1000000; $unit = $unit - 6; } elseif (($forceunitoutput == 'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) { - $dimension = $dimension * 1000; - $unit = $unit - 3; + $dimension *= 1000; + $unit -= 3; } elseif (($forceunitoutput == 'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) { - $dimension = $dimension / 1000000; - $unit = $unit + 6; + $dimension /= 1000000; + $unit += 6; } elseif (($forceunitoutput == 'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) { - $dimension = $dimension / 1000; - $unit = $unit + 3; + $dimension /= 1000; + $unit += 3; } // Special case when we want output unit into pound or ounce /* TODO From cfe66e2f603f67341b56ae095af7d7ad31d6583c Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 17:44:12 +0100 Subject: [PATCH 069/315] Improve typing, init var, suppress notification --- htdocs/core/lib/functions.lib.php | 36 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 36f44d7a502..7b5bed8423f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -688,8 +688,8 @@ function GETPOSTISARRAY($paramname, $method = 0) * 'restricthtml'=check html content is restricted to some tags only * 'custom'= custom filter specify $filter and $options) * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get) - * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) - * @param mixed $options Options to pass to filter_var when $check is set to 'custom' + * @param ?int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) + * @param mixed $options Options to pass to filter_var when $check is set to 'custom' * @param int $noreplace Force disable of replacement of __xxx__ strings. * @return string|array Value found (string or array), or '' if check fails */ @@ -718,6 +718,8 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null return 'BadThirdParameterForGETPOST'; } + $relativepathstring = ''; // For static analysis - looks possibly undefined if not set. + if (empty($method) || $method == 3 || $method == 4) { $relativepathstring = (empty($_SERVER["PHP_SELF"]) ? '' : $_SERVER["PHP_SELF"]); // Clean $relativepathstring @@ -759,6 +761,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null if (!empty($_GET['action']) && $_GET['action'] == 'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Search default value from $object->field global $object; + '@phan-var-force CommonObject $object'; // Suppose it's a CommonObject for analysis, but other objects have the $fields field as well if (is_object($object) && isset($object->fields[$paramname]['default'])) { $out = $object->fields[$paramname]['default']; } @@ -1191,6 +1194,7 @@ if (!function_exists('dol_getprefix')) { * * @param string $mode '' (prefix for session name) or 'email' (prefix for email id) * @return string A calculated prefix + * @phan-suppress PhanRedefineFunction - Also defined in webportal.main.inc.php */ function dol_getprefix($mode = '') { @@ -1967,13 +1971,14 @@ function dol_ucwords($string, $encoding = "UTF-8") * * @param string $message Line to log. ''=Show nothing * @param int $level Log level - * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr + * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 if define_syslog_variables ou PHP 5.3+, 7 if dolibarr * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_NOTICE=5, LOG_INFO=6, LOG_DEBUG=7 * @param int $ident 1=Increase ident of 1 (after log), -1=Decrease ident of 1 (before log) * @param string $suffixinfilename When output is a file, append this suffix into default log filename. Example '_stripe', '_mail' * @param string $restricttologhandler Force output of log only to this log handler * @param array|null $logcontext If defined, an array with extra information (can be used by some log handlers) * @return void + * @phan-suppress PhanPluginUnknownArrayFunctionParamType $logcontext is not defined in detail */ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '', $logcontext = null) { @@ -2194,7 +2199,7 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di /** * Show tab header of a card * - * @param array $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. + * @param array,string>> $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. * @param string $active Active tab name (document', 'info', 'ldap', ....) * @param string $title Title * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no sepaaration under tab (to start a tab just after), -3=Add tab header but no footer separation @@ -2215,7 +2220,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 /** * Show tabs of a record * - * @param array $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. + * @param array,string>> $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. * @param string $active Active tab name * @param string $title Title * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no separation under tab (to start a tab just after), -3=-2+'noborderbottom' @@ -2467,6 +2472,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $maxvisiblephotos = 1; $showimage = 1; $entity = (empty($object->entity) ? $conf->entity : $object->entity); + // @phan-suppress-next-line PhanUndeclaredMethod $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1); if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('barcode', 'lire_advance')) { $showbarcode = 0; @@ -2497,6 +2503,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if ($object->element == 'product') { /** @var Product $object */ + '@phan-var-force Product $object'; $width = 80; $cssclass = 'photowithmargin photoref'; $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); @@ -2505,7 +2512,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $maxvisiblephotos = 1; } if ($showimage) { - $morehtmlleft .= '
'.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, 0, $width, 0, '').'
'; + $morehtmlleft .= '
'.$object->show_photos('product', $conf->product->multidir_output[$entity], 1, $maxvisiblephotos, 0, 0, 0, 0, $width, 0, '').'
'; } else { if (getDolGlobalString('PRODUCT_NODISPLAYIFNOPHOTO')) { $nophoto = ''; @@ -2517,6 +2524,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } elseif ($object->element == 'category') { /** @var Categorie $object */ + '@phan-var-force Categorie $object'; $width = 80; $cssclass = 'photowithmargin photoref'; $showimage = $object->isAnyPhotoAvailable($conf->categorie->multidir_output[$entity]); @@ -2537,6 +2545,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } elseif ($object->element == 'bom') { /** @var Bom $object */ + '@phan-var-force Bom $object'; $width = 80; $cssclass = 'photowithmargin photoref'; $showimage = $object->is_photo_available($conf->bom->multidir_output[$entity]); @@ -2559,6 +2568,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $width = 80; $cssclass = 'photoref'; /** @var Ticket $object */ + '@phan-var-force Ticket $object'; $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->ref); $maxvisiblephotos = getDolGlobalInt('TICKET_MAX_VISIBLE_PHOTO', 2); if ($conf->browser->layout == 'phone') { @@ -3218,7 +3228,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = * @param int $timestamp Timestamp * @param boolean $fast Fast mode. deprecated. * @param string $forcetimezone '' to use the PHP server timezone. Or use a form like 'gmt', 'Europe/Paris' or '+0200' to force timezone. - * @return array Array of information + * @return array{seconds:int<0,59>,minutes:int<0,59>,hours:int<0,23>,mday:int<1,31>,wday:int<0,6>,mon:int<1,12>,year:int<0,9999>,yday:int<0,366>,0:int} Array of information * 'seconds' => $secs, * 'minutes' => $min, * 'hours' => $hour, @@ -7345,7 +7355,7 @@ function yn($yesno, $case = 1, $color = 0) * @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future) * @param int $alpha 0=Keep number only to forge path, 1=Use alpha part after the - (By default, use 0). (deprecated, global option will be used in future) * @param int $withoutslash 0=With slash at end (except if '/', we return ''), 1=without slash at end - * @param Object $object Object to use to get ref to forge the path. + * @param ?CommonObject $object Object to use to get ref to forge the path. * @param string $modulepart Type of object ('invoice_supplier, 'donation', 'invoice', ...'). Use '' for autodetect from $object. * @return string Dir to use ending. Example '' or '1/' or '1/2/' * @see getMultiDirOuput() @@ -13103,7 +13113,7 @@ function dolForgeCriteriaCallback($matches) * Get timeline icon * * @param ActionComm $actionstatic actioncomm - * @param array $histo histo + * @param array $histo histo * @param int $key key * @return string String with timeline icon * @deprecated Use actioncomm->getPictoType() instead @@ -13603,20 +13613,20 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, if ($donetodo) { $tmp = ''; - if (get_class($filterobj) == 'Societe') { + if ($filterobj instanceof Societe) { $tmp .= '
'; } - if (get_class($filterobj) == 'User') { + if ($filterobj instanceof User) { $tmp .= ''; } $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); - if (get_class($filterobj) == 'Societe') { + if ($filterobj instanceof Societe) { $tmp .= ''; } - if (get_class($filterobj) == 'User') { + if ($filterobj instanceof User) { $tmp .= ''; } $out .= getTitleFieldOfList($tmp); From 3b80d100ff49cd0501b5b20e965159e90ae6fd77 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 21:23:38 +0100 Subject: [PATCH 070/315] Cast return from DolEditor::Create(1) for static analysis --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 56fad852290..8e5befafd0a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1102,7 +1102,7 @@ class ExtraFields if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1); + $out = (string) $doleditor->Create(1); } else { $out = ''; } @@ -1110,7 +1110,7 @@ class ExtraFields if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, isModEnabled('fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out = $doleditor->Create(1); + $out = (string) $doleditor->Create(1); } else { $out = ''; } From 41644c03f1ea6a28b51c8a9335d073b0e888f34f Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 21:35:31 +0100 Subject: [PATCH 071/315] Accept null for formquestion in formconfirm() --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e7c86ed271a..edeec79facf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5224,7 +5224,7 @@ class Form * @param string $title Title * @param string $question Question * @param string $action Action - * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) + * @param array|string|null $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', * 'other', 'onecolumn' or 'hidden'... * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 From 61bc1986f3161e94642d5b45c10039918e56bbe2 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 21:46:27 +0100 Subject: [PATCH 072/315] Adjust sprintf to real type --- htdocs/core/datepicker.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 4c7c9a0ccc6..788289de2e3 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2024 MDW * * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. @@ -267,7 +268,7 @@ function displayBox($selectedDate, $month, $year) echo "trans("FormatDateShortJavaInput")."')\""; - echo ">".sprintf("%02s", $mydate["mday"]).""; + echo ">".sprintf("%02d", $mydate["mday"]).""; $cols++; if (($mydate["wday"] + 1) % 7 == $startday) { @@ -298,7 +299,7 @@ function displayBox($selectedDate, $month, $year) if ($selDate) { $tempDate = dol_getdate($selDate); print $langs->trans("Month".$selectMonth)." "; - print sprintf("%02s", $tempDate["mday"]); + print sprintf("%02d", $tempDate["mday"]); print ", ".$selectYear; } else { print "Click a Date"; From 88c2d7e34e7a1981c12a897212f2980a798df060 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:07:59 +0100 Subject: [PATCH 073/315] Add spelling for shippin --- dev/tools/codespell/codespell-dict.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tools/codespell/codespell-dict.txt b/dev/tools/codespell/codespell-dict.txt index ad8c0ecf617..1cd7ec6bfb2 100644 --- a/dev/tools/codespell/codespell-dict.txt +++ b/dev/tools/codespell/codespell-dict.txt @@ -21,6 +21,7 @@ thoose->those mot de passe->password not de passe->password nothtml->nohtml +shippin->shipping tableau de bord->state board tagret->target thridparty->thirdparty From a02b44923485172ec058eb0209789fc8edc11ec3 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:08:37 +0100 Subject: [PATCH 074/315] Adapt to real typings --- htdocs/accountancy/bookkeeping/export.php | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 72aee30478d..c2206e9d3a9 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -6,6 +6,7 @@ * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2022 Progiseize + * Copyright (C) 2024 MDW * * 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 @@ -165,7 +166,7 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; $res = $db->query($query); - if ($res->num_rows > 0) { + if ($db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); $search_date_end = strtotime($fiscalYear->date_end); @@ -321,17 +322,17 @@ if (empty($reshook)) { if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; $tmp = dol_getdate($search_date_start); - $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); + $param .= '&search_date_startmonth='.((int) $tmp['mon']).'&search_date_startday='.((int) $tmp['mday']).'&search_date_startyear='.((int) $tmp['year']); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; $tmp = dol_getdate($search_date_end); - $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); + $param .= '&search_date_endmonth='.((int) $tmp['mon']).'&search_date_endday='.((int) $tmp['mday']).'&search_date_endyear='.((int) $tmp['year']); } if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; $tmp = dol_getdate($search_doc_date); - $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); + $param .= '&doc_datemonth='.((int) $tmp['mon']).'&doc_dateday='.((int) $tmp['mday']).'&doc_dateyear='.((int) $tmp['year']); } if (!empty($search_doc_type)) { $filter['t.doc_type'] = $search_doc_type; @@ -400,42 +401,42 @@ if (empty($reshook)) { if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; $tmp = dol_getdate($search_date_creation_start); - $param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']); + $param .= '&search_date_creation_startmonth='.((int) $tmp['mon']).'&search_date_creation_startday='.((int) $tmp['mday']).'&search_date_creation_startyear='.((int) $tmp['year']); } if (!empty($search_date_creation_end)) { $filter['t.date_creation<='] = $search_date_creation_end; $tmp = dol_getdate($search_date_creation_end); - $param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']); + $param .= '&search_date_creation_endmonth='.((int) $tmp['mon']).'&search_date_creation_endday='.((int) $tmp['mday']).'&search_date_creation_endyear='.((int) $tmp['year']); } if (!empty($search_date_modification_start)) { $filter['t.tms>='] = $search_date_modification_start; $tmp = dol_getdate($search_date_modification_start); - $param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']); + $param .= '&search_date_modification_startmonth='.((int) $tmp['mon']).'&search_date_modification_startday='.((int) $tmp['mday']).'&search_date_modification_startyear='.((int) $tmp['year']); } if (!empty($search_date_modification_end)) { $filter['t.tms<='] = $search_date_modification_end; $tmp = dol_getdate($search_date_modification_end); - $param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']); + $param .= '&search_date_modification_endmonth='.((int) $tmp['mon']).'&search_date_modification_endday='.((int) $tmp['mday']).'&search_date_modification_endyear='.((int) $tmp['year']); } if (!empty($search_date_export_start)) { $filter['t.date_export>='] = $search_date_export_start; $tmp = dol_getdate($search_date_export_start); - $param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']); + $param .= '&search_date_export_startmonth='.((int) $tmp['mon']).'&search_date_export_startday='.((int) $tmp['mday']).'&search_date_export_startyear='.((int) $tmp['year']); } if (!empty($search_date_export_end)) { $filter['t.date_export<='] = $search_date_export_end; $tmp = dol_getdate($search_date_export_end); - $param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']); + $param .= '&search_date_export_endmonth='.((int) $tmp['mon']).'&search_date_export_endday='.((int) $tmp['mday']).'&search_date_export_endyear='.((int) $tmp['year']); } if (!empty($search_date_validation_start)) { $filter['t.date_validated>='] = $search_date_validation_start; $tmp = dol_getdate($search_date_validation_start); - $param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']); + $param .= '&search_date_validation_startmonth='.((int) $tmp['mon']).'&search_date_validation_startday='.((int) $tmp['mday']).'&search_date_validation_startyear='.((int) $tmp['year']); } if (!empty($search_date_validation_end)) { $filter['t.date_validated<='] = $search_date_validation_end; $tmp = dol_getdate($search_date_validation_end); - $param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']); + $param .= '&search_date_validation_endmonth='.((int) $tmp['mon']).'&search_date_validation_endday='.((int) $tmp['mday']).'&search_date_validation_endyear='.((int) $tmp['year']); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; @@ -1263,6 +1264,7 @@ while ($i < min($num, $limit)) { // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { $documentlink = ''; + $objectstatic = null; if ($line->doc_type == 'customer_invoice') { $langs->loadLangs(array('bills')); @@ -1273,7 +1275,7 @@ while ($i < min($num, $limit)) { if ($objectstatic->id > 0) { $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->invoice->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); } @@ -1315,7 +1317,7 @@ while ($i < min($num, $limit)) { $labeltoshow = ''; $labeltoshowalt = ''; - if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { + if (($objectstatic instanceof CommonObject) && in_array($line->doc_type, array('customer_invoice', 'supplier_invoice', 'expense_report'))) { if ($objectstatic->id > 0) { $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); $labeltoshow .= $documentlink; From 68209d83430aa1afbebe2b5662b12b587afcc8b5 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:08:49 +0100 Subject: [PATCH 075/315] Adapt to real typings --- htdocs/accountancy/bookkeeping/list.php | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index a9931ab2ccb..cd2d8eec015 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2022 Progiseize + * Copyright (C) 2024 MDW * * 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 @@ -160,7 +161,7 @@ if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('beg $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; $res = $db->query($query); - if ($res->num_rows > 0) { + if ($db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); $search_date_end = strtotime($fiscalYear->date_end); @@ -309,17 +310,17 @@ if (empty($reshook)) { if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; $tmp = dol_getdate($search_date_start); - $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); + $param .= '&search_date_startmonth='.((int) $tmp['mon']).'&search_date_startday='.((int) $tmp['mday']).'&search_date_startyear='.((int) $tmp['year']); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; $tmp = dol_getdate($search_date_end); - $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); + $param .= '&search_date_endmonth='.((int) $tmp['mon']).'&search_date_endday='.((int) $tmp['mday']).'&search_date_endyear='.((int) $tmp['year']); } if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; $tmp = dol_getdate($search_doc_date); - $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); + $param .= '&doc_datemonth='.((int) $tmp['mon']).'&doc_dateday='.((int) $tmp['mday']).'&doc_dateyear='.((int) $tmp['year']); } if (!empty($search_doc_type)) { $filter['t.doc_type'] = $search_doc_type; @@ -388,42 +389,42 @@ if (empty($reshook)) { if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; $tmp = dol_getdate($search_date_creation_start); - $param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']); + $param .= '&search_date_creation_startmonth='.((int) $tmp['mon']).'&search_date_creation_startday='.((int) $tmp['mday']).'&search_date_creation_startyear='.((int) $tmp['year']); } if (!empty($search_date_creation_end)) { $filter['t.date_creation<='] = $search_date_creation_end; $tmp = dol_getdate($search_date_creation_end); - $param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']); + $param .= '&search_date_creation_endmonth='.((int) $tmp['mon']).'&search_date_creation_endday='.((int) $tmp['mday']).'&search_date_creation_endyear='.((int) $tmp['year']); } if (!empty($search_date_modification_start)) { $filter['t.tms>='] = $search_date_modification_start; $tmp = dol_getdate($search_date_modification_start); - $param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']); + $param .= '&search_date_modification_startmonth='.((int) $tmp['mon']).'&search_date_modification_startday='.((int) $tmp['mday']).'&search_date_modification_startyear='.((int) $tmp['year']); } if (!empty($search_date_modification_end)) { $filter['t.tms<='] = $search_date_modification_end; $tmp = dol_getdate($search_date_modification_end); - $param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']); + $param .= '&search_date_modification_endmonth='.((int) $tmp['mon']).'&search_date_modification_endday='.((int) $tmp['mday']).'&search_date_modification_endyear='.((int) $tmp['year']); } if (!empty($search_date_export_start)) { $filter['t.date_export>='] = $search_date_export_start; $tmp = dol_getdate($search_date_export_start); - $param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']); + $param .= '&search_date_export_startmonth='.((int) $tmp['mon']).'&search_date_export_startday='.((int) $tmp['mday']).'&search_date_export_startyear='.((int) $tmp['year']); } if (!empty($search_date_export_end)) { $filter['t.date_export<='] = $search_date_export_end; $tmp = dol_getdate($search_date_export_end); - $param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']); + $param .= '&search_date_export_endmonth='.((int) $tmp['mon']).'&search_date_export_endday='.((int) $tmp['mday']).'&search_date_export_endyear='.((int) $tmp['year']); } if (!empty($search_date_validation_start)) { $filter['t.date_validated>='] = $search_date_validation_start; $tmp = dol_getdate($search_date_validation_start); - $param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']); + $param .= '&search_date_validation_startmonth='.((int) $tmp['mon']).'&search_date_validation_startday='.((int) $tmp['mday']).'&search_date_validation_startyear='.((int) $tmp['year']); } if (!empty($search_date_validation_end)) { $filter['t.date_validated<='] = $search_date_validation_end; $tmp = dol_getdate($search_date_validation_end); - $param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']); + $param .= '&search_date_validation_endmonth='.((int) $tmp['mon']).'&search_date_validation_endday='.((int) $tmp['mday']).'&search_date_validation_endyear='.((int) $tmp['year']); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; @@ -468,6 +469,7 @@ if (empty($reshook)) { } $nbok = 0; + $result = 0; if (!$error) { foreach ($toselect as $toselectid) { $result = $object->fetch($toselectid); From 6798c5ccffb2521cec0668183b526f96f8260b7d Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:09:17 +0100 Subject: [PATCH 076/315] Ignore PhanRedefineFunctionInternal --- htdocs/admin/receiptprinter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 6b7c5f686ed..7f7fd08ed2e 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -64,6 +64,7 @@ if (!function_exists('gzdecode')) { * * @param string $data data to deflate * @return string data deflated + * @phan-suppress PhanRedefineFunctionInternal */ function gzdecode($data) { From bbc185f6d1400383527a8ff57b2ec0b5894316eb Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:09:50 +0100 Subject: [PATCH 077/315] Adapt to real typings --- htdocs/admin/tools/listevents.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 902239fca39..5b2d106e295 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -299,22 +300,22 @@ if ($result) { $param .= '&search_prefix_session='.urlencode($search_prefix_session); } if ($date_startmonth) { - $param .= "&date_startmonth=".urlencode($date_startmonth); + $param .= "&date_startmonth=".((int) $date_startmonth); } if ($date_startday) { - $param .= "&date_startday=".urlencode($date_startday); + $param .= "&date_startday=".((int) $date_startday); } if ($date_startyear) { - $param .= "&date_startyear=".urlencode($date_startyear); + $param .= "&date_startyear=".((int) $date_startyear); } if ($date_endmonth) { - $param .= "&date_endmonth=".urlencode($date_endmonth); + $param .= "&date_endmonth=".((int) $date_endmonth); } if ($date_endday) { - $param .= "&date_endday=".urlencode($date_endday); + $param .= "&date_endday=".((int) $date_endday); } if ($date_endyear) { - $param .= "&date_endyear=".urlencode($date_endyear); + $param .= "&date_endyear=".((int) $date_endyear); } $center = ''; From 1404b9c290810d252149913b0297bdec2bda2f26 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:10:07 +0100 Subject: [PATCH 078/315] Adapt to real typings --- htdocs/blockedlog/admin/blockedlog_list.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 2604e35f362..b321745f90d 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2018 Laurent Destailleur * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -349,25 +350,25 @@ if ($search_fk_user > 0) { $param .= '&search_fk_user='.urlencode($search_fk_user); } if ($search_startyear > 0) { - $param .= '&search_startyear='.urlencode($search_startyear); + $param .= '&search_startyear='.((int) $search_startyear); } if ($search_startmonth > 0) { - $param .= '&search_startmonth='.urlencode($search_startmonth); + $param .= '&search_startmonth='.((int) $search_startmonth); } if ($search_startday > 0) { - $param .= '&search_startday='.urlencode($search_startday); + $param .= '&search_startday='.((int) $search_startday); } if ($search_endyear > 0) { - $param .= '&search_endyear='.urlencode((string) ($search_endyear)); + $param .= '&search_endyear='.((int) $search_endyear); } if ($search_endmonth > 0) { - $param .= '&search_endmonth='.urlencode((string) ($search_endmonth)); + $param .= '&search_endmonth='.((int) $search_endmonth); } if ($search_endday > 0) { - $param .= '&search_endday='.urlencode((string) ($search_endday)); + $param .= '&search_endday='.((int) $search_endday); } if ($search_showonlyerrors > 0) { - $param .= '&search_showonlyerrors='.urlencode((string) ($search_showonlyerrors)); + $param .= '&search_showonlyerrors='.((int) $search_showonlyerrors); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); From 79b5add75a0327dc548a6cce97732431d118959a Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:10:37 +0100 Subject: [PATCH 079/315] Improve PHPdoc for array return value --- htdocs/blockedlog/class/blockedlog.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 476e1b3d82f..79f267f32ac 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1096,7 +1096,7 @@ class BlockedLog * @param string $search_ref search ref * @param string $search_amount search amount * @param string $search_code search code - * @return array|int Array of object log or <0 if error + * @return BlockedLog[]|int<-2,-1> Array of object log or <0 if error */ public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref = '', $search_amount = '', $search_code = '') { From 30f1701c6f2293fa6295a61c6844552daa54bf46 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:11:13 +0100 Subject: [PATCH 080/315] Improve typings, adapt --- htdocs/comm/action/peruser.php | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 97098383652..3daeca53c6e 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -99,10 +99,10 @@ if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // $mode = 'show_peruser'; $resourceid = GETPOSTINT("search_resourceid") ? GETPOSTINT("search_resourceid") : GETPOSTINT("resourceid"); -$year = GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"); -$month = GETPOSTINT("month") ? GETPOSTINT("month") : date("m"); -$week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W"); -$day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); +$year = GETPOSTINT("year") ? GETPOSTINT("year") : idate("Y"); +$month = GETPOSTINT("month") ? GETPOSTINT("month") : idate("m"); +$week = GETPOSTINT("week") ? GETPOSTINT("week") : idate("W"); +$day = GETPOSTINT("day") ? GETPOSTINT("day") : idate("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); @@ -170,12 +170,12 @@ if (GETPOST('viewcal', 'alpha') && $mode != 'show_day' && $mode != 'show_week' & } // View by month if (GETPOST('viewweek', 'alpha') || $mode == 'show_week') { $mode = 'show_week'; - $week = ($week ? $week : date("W")); - $day = ($day ? $day : date("d")); + $week = ($week ? $week : idate("W")); + $day = ($day ? $day : idate("d")); } // View by week if (GETPOST('viewday', 'alpha') || $mode == 'show_day') { $mode = 'show_day'; - $day = ($day ? $day : date("d")); + $day = ($day ? $day : idate("d")); } // View by day $object = new ActionComm($db); @@ -257,7 +257,7 @@ $next_year = $next['year']; $next_month = $next['month']; $next_day = $next['day']; -$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); +$max_day_in_month = idate("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; @@ -313,16 +313,16 @@ if ($mode != 'show_peruser') { $param .= '&mode='.urlencode($mode); } if ($begin_h != '') { - $param .= '&begin_h='.urlencode($begin_h); + $param .= '&begin_h='.((int) $begin_h); } if ($end_h != '') { - $param .= '&end_h='.urlencode($end_h); + $param .= '&end_h='.((int) $end_h); } if ($begin_d != '') { - $param .= '&begin_d='.urlencode($begin_d); + $param .= '&begin_d='.((int) $begin_d); } if ($end_d != '') { - $param .= '&end_d='.urlencode($end_d); + $param .= '&end_d='.((int) $end_d); } if ($search_categ_cus != 0) { $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus)); @@ -358,7 +358,7 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); //print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); //print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); -$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); +$max_day_in_month = idate("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); $tmpday = $first_day; $picto = 'calendarweek'; @@ -482,18 +482,18 @@ $newcardbutton = ''; if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); - $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); + $newparam .= '&month='.urlencode(str_pad((string) $month, 2, "0", STR_PAD_LEFT)).'&year='.((int) $tmpforcreatebutton['year']); if ($begin_h !== '') { - $newparam .= '&begin_h='.urlencode($begin_h); + $newparam .= '&begin_h='.((int) $begin_h); } if ($end_h !== '') { - $newparam .= '&end_h='.urlencode($end_h); + $newparam .= '&end_h='.((int) $end_h); } if ($begin_d !== '') { - $newparam .= '&begin_d='.urlencode($begin_d); + $newparam .= '&begin_d='.((int) $begin_d); } if ($end_d !== '') { - $newparam .= '&end_d='.urlencode($end_d); + $newparam .= '&end_d='.((int) $end_d); } $urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create'; From d17c010e59e631259be0d3271ca583cc20b1999c Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:11:43 +0100 Subject: [PATCH 081/315] Improve PHPdoc typings --- htdocs/core/class/conf.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 37677a086b0..25361f71368 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -110,13 +110,17 @@ class Conf extends stdClass public $logbuffer = array(); /** - * @var LogHandlerInterface[] + * @var LogHandler[] */ public $loghandlers = array(); - //! Used to store running instance for multi-company (default 1) + /** + * @var int Used to store running instance for multi-company (default 1) + */ public $entity = 1; - //! Used to store list of entities to use for each element + /** + * @var int[] Used to store list of entities to use for each element + */ public $entities = array(); public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url From 767eeb605df1306bc8e41568139fb9b555b759c1 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:14:31 +0100 Subject: [PATCH 082/315] Style (phpcbf not agreeing with php-cs-fixer) --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index edeec79facf..e14b020b144 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5225,8 +5225,8 @@ class Form * @param string $question Question * @param string $action Action * @param array|string|null $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) - * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', - * 'other', 'onecolumn' or 'hidden'... + * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', + * 'other', 'onecolumn' or 'hidden'... * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 * @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx * @param int|string $height Force height of box (0 = auto) From 37515f11541b924f13fe4a7152ade3ab2043a395 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:15:43 +0100 Subject: [PATCH 083/315] Adjust to real typings --- htdocs/core/lib/admin.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index cfc9045aae1..3e50cda3947 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -396,7 +396,7 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler $sql = preg_replace('/__DATABASE__/i', $db->escape($database), $sql); } - $newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql); + $newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : (string) $conf->entity), $sql); // Add log of request if (!$silent) { From e2b02953084f302e6e46126880da47f6f1d4f787 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:15:57 +0100 Subject: [PATCH 084/315] Adjust to real typings --- htdocs/core/lib/date.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 8b7ea390b71..b3d71145ab2 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -688,8 +688,8 @@ function dol_get_first_day_week($day, $month, $year, $gm = false) //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'
'; //Get first day of week - $tmpdaytms = (int) date($tmparray[0]) - $seconds; // $tmparray[0] is day of parameters - $tmpday = (int) date("d", $tmpdaytms); + $tmpdaytms = (int) date((string) $tmparray['0']) - $seconds; // $tmparray[0] is day of parameters + $tmpday = idate("d", $tmpdaytms); //Check first day of week is in same month than current day or not if ($tmpday > $day) { From 1ee639bb8124ab0ad144d78a22f7aa124af972da Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:16:25 +0100 Subject: [PATCH 085/315] Adjust to real typings --- htdocs/core/modules/DolibarrModules.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 6aabd6443ef..801cbe72869 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -500,7 +500,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $ignoreerror = $val['ignoreerror']; } // Add current entity id - $sql = str_replace('__ENTITY__', $conf->entity, $sql); + $sql = str_replace('__ENTITY__', (string) $conf->entity, $sql); dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror, LOG_DEBUG); $result = $this->db->query($sql, $ignoreerror); From 006a8c34e6edd14cc1234ee45ceb8fdc831fe7aa Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:16:44 +0100 Subject: [PATCH 086/315] Adjust to real typings --- htdocs/core/multicompany_page.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php index 9286e3efaaa..a047ef74968 100644 --- a/htdocs/core/multicompany_page.php +++ b/htdocs/core/multicompany_page.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. @@ -91,9 +92,8 @@ print ''."\n"; print '
'; //print '
'; -if (!isset($bookmarkList)) { - $bookmarkList = ''; -} + +$bookmarkList = ''; if (!isModEnabled('multicompany')) { $langs->load("admin"); $bookmarkList .= '
'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("MultiCompany")).''; @@ -109,6 +109,8 @@ if (!isModEnabled('multicompany')) { if (is_object($mc)) { $listofentities = $mc->getEntitiesList($user->login, false, true); + } else { + $listofentities = array(); } $multicompanyList .= '
    '; From fd66fd6a38cfc4dc35320eb37641c50ae64ee610 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 25 Mar 2024 22:49:18 +0100 Subject: [PATCH 087/315] Adjust to real typing --- htdocs/ticket/list.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 2b1a28cbdb0..b6433a6eac8 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -681,39 +681,39 @@ if ($contractid > 0) { } if ($search_date_start) { $tmparray = dol_getdate($search_date_start); - $param .= '&search_date_startday='.urlencode($tmparray['mday']); - $param .= '&search_date_startmonth='.urlencode($tmparray['mon']); - $param .= '&search_date_startyear='.urlencode($tmparray['year']); + $param .= '&search_date_startday='.((int) $tmparray['mday']); + $param .= '&search_date_startmonth='.((int) $tmparray['mon']); + $param .= '&search_date_startyear='.((int) $tmparray['year']); } if ($search_date_end) { $tmparray = dol_getdate($search_date_end); - $param .= '&search_date_endday='.urlencode($tmparray['mday']); - $param .= '&search_date_endmonth='.urlencode($tmparray['mon']); - $param .= '&search_date_endyear='.urlencode($tmparray['year']); + $param .= '&search_date_endday='.((int) $tmparray['mday']); + $param .= '&search_date_endmonth='.((int) $tmparray['mon']); + $param .= '&search_date_endyear='.((int) $tmparray['year']); } if ($search_dateread_start) { $tmparray = dol_getdate($search_dateread_start); - $param .= '&search_dateread_startday='.urlencode($tmparray['mday']); - $param .= '&search_dateread_startmonth='.urlencode($tmparray['mon']); - $param .= '&search_dateread_startyear='.urlencode($tmparray['year']); + $param .= '&search_dateread_startday='.((int) $tmparray['mday']); + $param .= '&search_dateread_startmonth='.((int) $tmparray['mon']); + $param .= '&search_dateread_startyear='.((int) $tmparray['year']); } if ($search_dateread_end) { $tmparray = dol_getdate($search_dateread_end); - $param .= '&search_dateread_endday='.urlencode($tmparray['mday']); - $param .= '&search_dateread_endmonth='.urlencode($tmparray['mon']); - $param .= '&search_dateread_endyear='.urlencode($tmparray['year']); + $param .= '&search_dateread_endday='.((int) $tmparray['mday']); + $param .= '&search_dateread_endmonth='.((int) $tmparray['mon']); + $param .= '&search_dateread_endyear='.((int) $tmparray['year']); } if ($search_dateclose_start) { $tmparray = dol_getdate($search_dateclose_start); - $param .= '&search_dateclose_startday='.urlencode($tmparray['mday']); - $param .= '&search_dateclose_startmonth='.urlencode($tmparray['mon']); - $param .= '&search_dateclose_startyear='.urlencode($tmparray['year']); + $param .= '&search_dateclose_startday='.((int) $tmparray['mday']); + $param .= '&search_dateclose_startmonth='.((int) $tmparray['mon']); + $param .= '&search_dateclose_startyear='.((int) $tmparray['year']); } if ($search_dateclose_end) { $tmparray = dol_getdate($search_dateclose_end); - $param .= '&search_date_endday='.urlencode($tmparray['mday']); - $param .= '&search_date_endmonth='.urlencode($tmparray['mon']); - $param .= '&search_date_endyear='.urlencode($tmparray['year']); + $param .= '&search_date_endday='.((int) $tmparray['mday']); + $param .= '&search_date_endmonth='.((int) $tmparray['mon']); + $param .= '&search_date_endyear='.((int) $tmparray['year']); } // List of mass actions available $arrayofmassactions = array( From d765e847a7417cca69b07ab24b6fa7f7e295dc07 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 00:40:41 +0100 Subject: [PATCH 088/315] Allow empty array for dol_print_date() return --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b5bed8423f..b258dc47d5d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3228,7 +3228,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = * @param int $timestamp Timestamp * @param boolean $fast Fast mode. deprecated. * @param string $forcetimezone '' to use the PHP server timezone. Or use a form like 'gmt', 'Europe/Paris' or '+0200' to force timezone. - * @return array{seconds:int<0,59>,minutes:int<0,59>,hours:int<0,23>,mday:int<1,31>,wday:int<0,6>,mon:int<1,12>,year:int<0,9999>,yday:int<0,366>,0:int} Array of information + * @return array{}|array{seconds:int<0,59>,minutes:int<0,59>,hours:int<0,23>,mday:int<1,31>,wday:int<0,6>,mon:int<1,12>,year:int<0,9999>,yday:int<0,366>,0:int} Array of information * 'seconds' => $secs, * 'minutes' => $min, * 'hours' => $hour, From a703ea1092ee0dd456b066483de825a0efa1c0bd Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 00:57:32 +0100 Subject: [PATCH 089/315] Add checks on dol_(mktime|now|print_date) + avoid duplicate phan conf --- dev/tools/phan/config.php | 3 + dev/tools/phan/config_extended.php | 376 +---------------------------- dev/tools/phan/config_fixer.php | 239 ++---------------- 3 files changed, 27 insertions(+), 591 deletions(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 38dcbb2bff1..c70f6dd5058 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -351,6 +351,9 @@ return [ '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], '/^sanitizeVal$/' => [1, $sanitizeRegex,"UnknownSanitizeType"], '/^\\\\ExtraFields::addExtraField$/' => [2, $extraFieldTypeRegex,"UnknownExtrafieldTypeBack"], + '/^dol_now$/' => [0, '{^(?:auto|gmt|tz(?:server|ref|user(?:rel)?))$}',"InvalidDolNowArgument"], // '', 0, 1 match bool and int values + '/^dol_mktime$/' => [6, '{^(?:|0|1|auto|gmt|tz(?:server|ref|user(?:rel)?|,[+a-zA-Z-/]+))$}',"InvalidDolMktimeArgument"], // '', 0, 1 match bool and int values + '/^dol_print_date$/' => [2, '{^(?:|0|1|auto|gmt|tz(?:server|user(?:rel)?))$}',"InvalidDolMktimeArgument"], ], 'plugins' => [ __DIR__.'/plugins/NoVarDumpPlugin.php', diff --git a/dev/tools/phan/config_extended.php b/dev/tools/phan/config_extended.php index 535f52f70b2..991ba4d3668 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -1,324 +1,12 @@ */ -define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); -define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); -define('PHAN_DIR', __DIR__); -$sanitizeRegex - = '/^(array:)?(?:'.implode( - '|', - array( - // Documented: - 'none', - 'array', - 'int', - 'intcomma', - 'alpha', - 'alphawithlgt', - 'alphanohtml', - 'MS', - 'aZ', - 'aZ09', - 'aZ09arobase', - 'aZ09comma', - 'san_alpha', - 'restricthtml', - 'nohtml', - 'custom', - // Not documented: - 'email', - 'restricthtmlallowclass', - 'restricthtmlallowunvalid', - 'restricthtmlnolink', - //'ascii', - //'categ_id', - //'chaine', - //'html', - //'boolean', - //'double', - //'float', - //'string', - ) - ).')*$/'; +// Load default configuration (with many exclusions) +// +$config = include __DIR__.DIRECTORY_SEPARATOR."config.php"; -/** - * Map deprecated module names to new module names - */ -$DEPRECATED_MODULE_MAPPING = array( - 'actioncomm' => 'agenda', - 'adherent' => 'member', - 'adherent_type' => 'member_type', - 'banque' => 'bank', - 'categorie' => 'category', - 'commande' => 'order', - 'contrat' => 'contract', - 'entrepot' => 'stock', - 'expedition' => 'shipping', - 'facture' => 'invoice', - 'ficheinter' => 'intervention', - 'product_fournisseur_price' => 'productsupplierprice', - 'product_price' => 'productprice', - 'projet' => 'project', - 'propale' => 'propal', - 'socpeople' => 'contact', -); - -/** - * Map module names to the 'class' name (the class is: mod) - * Value is null when the module is not internal to the default - * Dolibarr setup. - */ -$VALID_MODULE_MAPPING = array( - 'accounting' => 'Accounting', - 'agenda' => 'Agenda', - 'ai' => 'Ai', - 'anothermodule' => null, - 'api' => 'Api', - 'asset' => 'Asset', - 'bank' => 'Banque', - 'barcode' => 'Barcode', - 'blockedlog' => 'BlockedLog', - 'bom' => 'Bom', - 'bookcal' => 'BookCal', - 'bookmark' => 'Bookmark', - 'cashdesk' => null, // TODO: fill in proper class - 'category' => 'Categorie', - 'clicktodial' => 'ClickToDial', - 'collab' => 'Collab', - 'comptabilite' => 'Comptabilite', - 'contact' => null, // TODO: fill in proper class - 'contract' => 'Contrat', - 'cron' => 'Cron', - 'datapolicy' => 'DataPolicy', - 'dav' => 'Dav', - 'debugbar' => 'DebugBar', - 'shipping' => 'Expedition', - 'deplacement' => 'Deplacement', - "documentgeneration" => 'DocumentGeneration', - 'don' => 'Don', - 'dynamicprices' => 'DynamicPrices', - 'ecm' => 'ECM', - 'ecotax' => null, // TODO: External module ? - 'emailcollector' => 'EmailCollector', - 'eventorganization' => 'EventOrganization', - 'expensereport' => 'ExpenseReport', - 'export' => 'Export', - 'externalrss' => 'ExternalRss', - 'externalsite' => 'ExternalSite', - 'fckeditor' => 'Fckeditor', - 'fournisseur' => 'Fournisseur', - 'ftp' => 'FTP', - 'geoipmaxmind' => 'GeoIPMaxmind', - 'google' => null, // External ? - 'gravatar' => 'Gravatar', - 'holiday' => 'Holiday', - 'hrm' => 'HRM', - 'import' => 'Import', - 'incoterm' => 'Incoterm', - 'intervention' => 'Ficheinter', - 'intracommreport' => 'Intracommreport', - 'invoice' => 'Facture', - 'knowledgemanagement' => 'KnowledgeManagement', - 'label' => 'Label', - 'ldap' => 'Ldap', - 'loan' => 'Loan', - 'mailing' => 'Mailing', - 'mailman' => null, // Same module as mailmanspip -> MailmanSpip ?? - 'mailmanspip' => 'MailmanSpip', - 'margin' => 'Margin', - 'member' => 'Adherent', - 'memcached' => null, // TODO: External module? - 'modulebuilder' => 'ModuleBuilder', - 'mrp' => 'Mrp', - 'multicompany' => null, // Not provided by default, no module tests - 'multicurrency' => 'MultiCurrency', - 'mymodule' => null, // modMyModule - Name used in module builder (avoid false positives) - 'notification' => 'Notification', - 'numberwords' => null, // Not provided by default, no module tests - 'oauth' => 'Oauth', - 'openstreetmap' => null, // External module? - 'opensurvey' => 'OpenSurvey', - 'order' => 'Commande', - 'partnership' => 'Partnership', - 'paybox' => 'Paybox', - 'paymentbybanktransfer' => 'PaymentByBankTransfer', - 'paypal' => 'Paypal', - 'paypalplus' => null, - 'prelevement' => 'Prelevement', - 'printing' => 'Printing', - 'product' => 'Product', - 'productbatch' => 'ProductBatch', - 'productprice' => null, - 'productsupplierprice' => null, - 'project' => 'Projet', - 'propal' => 'Propale', - 'receiptprinter' => 'ReceiptPrinter', - 'reception' => 'Reception', - 'recruitment' => 'Recruitment', - 'resource' => 'Resource', - 'salaries' => 'Salaries', - 'service' => 'Service', - 'socialnetworks' => 'SocialNetworks', - 'societe' => 'Societe', - 'stock' => 'Stock', - 'stocktransfer' => 'StockTransfer', - 'stripe' => 'Stripe', - 'supplier_invoice' => null, // Special case, uses invoice - 'supplier_order' => null, // Special case, uses invoice - 'supplier_proposal' => 'SupplierProposal', - 'syslog' => 'Syslog', - 'takepos' => 'TakePos', - 'tax' => 'Tax', - 'theme_datacolor' => 'array{0:array{0:int,1:int,2:int},1:array{0:int,1:int,2:int},2:array{0:int,1:int,2:int},3:array{0:int,1:int,2:int}}', - 'ticket' => 'Ticket', - 'user' => 'User', - 'variants' => 'Variants', - 'webhook' => 'Webhook', - 'webportal' => 'WebPortal', - 'webservices' => 'WebServices', - 'webservicesclient' => 'WebServicesClient', - 'website' => 'Website', - 'workflow' => 'Workflow', - 'workstation' => 'Workstation', - 'zapier' => 'Zapier', -); - -$moduleNameRegex = '/^(?:'.implode('|', array_merge(array_keys($DEPRECATED_MODULE_MAPPING), array_keys($VALID_MODULE_MAPPING))).')$/'; - -$deprecatedModuleNameRegex = '/^(?!(?:'.implode('|', array_keys($DEPRECATED_MODULE_MAPPING)).')$).*/'; - -/** - * This configuration will be read and overlaid on top of the - * default configuration. Command line arguments will be applied - * after this file is read. - */ -return [ - // 'processes' => 6, - 'backward_compatibility_checks' => false, - 'simplify_ast' => true, - 'analyzed_file_extensions' => ['php','inc'], - 'globals_type_map' => [ - 'action' => 'string', - 'actioncode' => 'string', - 'badgeStatus0' => 'string', - 'badgeStatus1' => 'string', - 'badgeStatus11' => 'string', - 'badgeStatus3' => 'string', - 'badgeStatus4' => 'string', - 'badgeStatus6' => 'string', - 'badgeStatus8' => 'string', - 'badgeStatus9' => 'string', - 'classname' => 'string', - 'conf' => '\Conf', - 'conffile' => 'string', - 'conffiletoshow' => 'string', - 'conffiletoshowshort' => 'string', - 'db' => '\DoliDB', - 'disableedit' => 'int<0,1>', - 'disablemove' => 'int<0,1>', - 'disableremove' => 'int<0,1>', - 'dolibarr_main_authentication' => 'string', - 'dolibarr_main_data_root' => 'string', - 'dolibarr_main_data_root' => 'string', - 'dolibarr_main_db_encrypted_pass' => 'string', - 'dolibarr_main_db_host' => 'string', - 'dolibarr_main_db_pass' => 'string', - 'dolibarr_main_demo' => 'string', - 'dolibarr_main_document_root' => 'string', - 'dolibarr_main_url_root' => 'string', - 'errormsg' => 'string', - 'extrafields' => '\ExtraFields', - 'filter' => 'string', - 'filtert' => 'int', - 'forceall' => 'int<0,1>', - 'form' => '\Form', - 'hookmanager' => '\HookManager', - 'inputalsopricewithtax' => 'int<0,1>', - 'langs' => '\Translate', - 'leftmenu' => 'string', - 'mainmenu' => 'string', - 'menumanager' => '\MenuManager', - 'mysoc' => '\Societe', - 'nblines' => '\int', - 'obj' => '\CommonObject', // Deprecated - 'object_rights' => 'int|stdClass', - 'objectoffield' => '\CommonObject', - 'senderissupplier' => 'int<0,2>', - 'user' => '\User', - 'website' => 'string', // See discussion https://github.com/Dolibarr/dolibarr/pull/28891#issuecomment-2002268334 // Disable because Phan infers Website type - 'websitepage' => '\WebSitePage', - 'websitepagefile' => 'string', - // 'object' => '\CommonObject', // Deprecated, not enabled because conflicts with $object assignments - ], - - // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`. - // If this is set to `null`, - // then Phan assumes the PHP version which is closest to the minor version - // of the php executable used to execute Phan. - //"target_php_version" => null, - "target_php_version" => '8.2', - //"target_php_version" => '7.3', - //"target_php_version" => '5.6', - - // A list of directories that should be parsed for class and - // method information. After excluding the directories - // defined in exclude_analysis_directory_list, the remaining - // files will be statically analyzed for errors. - // - // Thus, both first-party and third-party code being used by - // your application should be included in this list. - 'directory_list' => [ - 'htdocs', - PHAN_DIR . '/stubs/', - ], - - // A directory list that defines files that will be excluded - // from static analysis, but whose class and method - // information should be included. - // - // Generally, you'll want to include the directories for - // third-party code (such as "vendor/") in this list. - // - // n.b.: If you'd like to parse but not analyze 3rd - // party code, directories containing that code - // should be added to the `directory_list` as - // to `exclude_analysis_directory_list`. - "exclude_analysis_directory_list" => [ - 'htdocs/includes/', - 'htdocs/install/doctemplates/websites/', - 'htdocs/core/class/lessc.class.php', // External library - PHAN_DIR . '/stubs/', - ], - //'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', - 'exclude_file_regex' => '@^(' // @phpstan-ignore-line - .'dummy' // @phpstan-ignore-line - .'|htdocs/.*/canvas/.*/tpl/.*.tpl.php' // @phpstan-ignore-line - .'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line - // Included as stub (old version + incompatible typing hints) - .'|htdocs/includes/restler/.*' // @phpstan-ignore-line - // Included as stub (did not seem properly analysed by phan without it) - .'|htdocs/includes/stripe/.*' // @phpstan-ignore-line - .'|htdocs/conf/conf.php' // @phpstan-ignore-line - .')@', // @phpstan-ignore-line - - // A list of plugin files to execute. - // Plugins which are bundled with Phan can be added here by providing their name - // (e.g. 'AlwaysReturnPlugin') - // - // Documentation about available bundled plugins can be found - // at https://github.com/phan/phan/tree/master/.phan/plugins - // - // Alternately, you can pass in the full path to a PHP file - // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') - 'ParamMatchRegexPlugin' => [ - '/^GETPOST$/' => [1, $sanitizeRegex, 'GetPostUnknownSanitizeType'], - '/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'], - // Note: trick to have different key for same regex: - '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], - '/^sanitizeVal$/' => [1, $sanitizeRegex,"UnknownSanitizeType"], - ], - 'plugins' => [ +$config['plugins'] = [ __DIR__.'/plugins/NoVarDumpPlugin.php', __DIR__.'/plugins/ParamMatchRegexPlugin.php', 'DeprecateAliasPlugin', @@ -367,11 +55,11 @@ return [ 'UseReturnValuePlugin', 'EmptyStatementListPlugin', 'LoopVariableReusePlugin', - ], + ]; - // Add any issue types (such as 'PhanUndeclaredMethod') - // here to inhibit them from being reported - 'suppress_issue_types' => [ +// Add any issue types (such as 'PhanUndeclaredMethod') +// here to inhibit them from being reported +$config['suppress_issue_types'] = [ 'PhanCompatibleNegativeStringOffset', // return false positive 'PhanPluginWhitespaceTab', // Dolibarr used tabs @@ -394,50 +82,6 @@ return [ 'PhanPluginDuplicateConditionalNullCoalescing', // Not essential - 990+ occurrences 'PhanPluginRedundantAssignmentInGlobalScope', // Not essential, a lot of false warning 'PhanPluginDuplicateCatchStatementBody', // Requires PHP7.1 - 50+ occurrences - ], - // You can put relative paths to internal stubs in this config option. - // Phan will continue using its detailed type annotations, - // but load the constants, classes, functions, and classes (and their Reflection types) - // from these stub files (doubling as valid php files). - // Use a different extension from php (and preferably a separate folder) - // to avoid accidentally parsing these as PHP (includes projects depending on this). - // The 'mkstubs' script can be used to generate your own stubs (compatible with php 7.0+ right now) - // Note: The array key must be the same as the extension name reported by `php -m`, - // so that phan can skip loading the stubs if the extension is actually available. - 'autoload_internal_extension_signatures' => [ - // Stubs may be available at https://github.com/JetBrains/phpstorm-stubs/tree/master - - // Xdebug stubs are bundled with Phan 0.10.1+/0.8.9+ for usage, - // because Phan disables xdebug by default. - //'xdebug' => 'vendor/phan/phan/.phan/internal_stubs/xdebug.phan_php', - //'memcached' => PHAN_DIR . '/your_internal_stubs_folder_name/memcached.phan_php', - //'PDO' => PHAN_DIR . '/stubs/PDO.phan_php', - 'brotli' => PHAN_DIR . '/stubs/brotli.phan_php', - 'curl' => PHAN_DIR . '/stubs/curl.phan_php', - 'calendar' => PHAN_DIR . '/stubs/calendar.phan_php', - 'fileinfo' => PHAN_DIR . '/stubs/fileinfo.phan_php', - 'ftp' => PHAN_DIR . '/stubs/ftp.phan_php', - 'gd' => PHAN_DIR . '/stubs/gd.phan_php', - 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', - 'imap' => PHAN_DIR . '/stubs/imap.phan_php', - 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', - 'intl' => PHAN_DIR . '/stubs/intl.phan_php', - 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', - 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', - 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', - 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', - 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', - 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', - 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', - 'pdo_pgsql' => PHAN_DIR . '/stubs/pdo_pgsql.phan_php', - 'pdo_sqlite' => PHAN_DIR . '/stubs/pdo_sqlite.phan_php', - 'pgsql' => PHAN_DIR . '/stubs/pgsql.phan_php', - 'session' => PHAN_DIR . '/stubs/session.phan_php', - 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', - 'soap' => PHAN_DIR . '/stubs/soap.phan_php', - 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', - 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', - 'zip' => PHAN_DIR . '/stubs/zip.phan_php', - ], - ]; + +return $config; diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index 5df01eb7ae6..79a3d589d38 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -3,101 +3,22 @@ * Copyright (C) 2024 Frédéric France */ -// Uncomment require_once to enable corresponding fixer + +// Load default configuration (with many exclusions) +// +$config = include __DIR__.DIRECTORY_SEPARATOR."config.php"; + //require_once __DIR__.'/plugins/DeprecatedModuleNameFixer.php'; //require_once __DIR__.'/plugins/PriceFormFixer.php'; //require_once __DIR__.'/plugins/UrlEncodeStringifyFixer.php'; require_once __DIR__.'/plugins/SelectDateFixer.php'; -define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); -define('DOL_DOCUMENT_ROOT', DOL_PROJECT_ROOT.'/htdocs'); -define('PHAN_DIR', __DIR__); - -$DEPRECATED_MODULE_MAPPING = array( - 'actioncomm' => 'agenda', - 'adherent' => 'member', - 'adherent_type' => 'member_type', - 'banque' => 'bank', - 'categorie' => 'category', - 'commande' => 'order', - 'contrat' => 'contract', - 'entrepot' => 'stock', - 'expedition' => 'shipping', - 'facture' => 'invoice', - 'ficheinter' => 'intervention', - 'product_fournisseur_price' => 'productsupplierprice', - 'product_price' => 'productprice', - 'projet' => 'project', - 'propale' => 'propal', - 'socpeople' => 'contact', -); - -$deprecatedModuleNameRegex = '/^(?!(?:'.implode('|', array_keys($DEPRECATED_MODULE_MAPPING)).')$).*/'; +//$deprecatedModuleNameRegex = '/^(?!(?:'.implode('|', array_keys($DEPRECATED_MODULE_MAPPING)).')$).*/'; require_once __DIR__.'/plugins/DeprecatedModuleNameFixer.php'; -/** - * This configuration will be read and overlaid on top of the - * default configuration. Command line arguments will be applied - * after this file is read. - */ -return [ - // 'processes' => 6, - 'backward_compatibility_checks' => false, - 'simplify_ast' => true, - 'analyzed_file_extensions' => ['php','inc'], - 'globals_type_map' => [ - 'conf' => '\Conf', - 'db' => '\DoliDB', - 'extrafields' => '\ExtraFields', - 'hookmanager' => '\HookManager', - 'langs' => '\Translate', - 'mysoc' => '\Societe', - 'nblines' => '\int', - 'user' => '\User', - ], - - // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`. - // If this is set to `null`, - // then Phan assumes the PHP version which is closest to the minor version - // of the php executable used to execute Phan. - //"target_php_version" => null, - "target_php_version" => '8.2', - //"target_php_version" => '7.3', - //"target_php_version" => '5.6', - - // A list of directories that should be parsed for class and - // method information. After excluding the directories - // defined in exclude_analysis_directory_list, the remaining - // files will be statically analyzed for errors. - // - // Thus, both first-party and third-party code being used by - // your application should be included in this list. - 'directory_list' => [ - 'htdocs', - PHAN_DIR . '/stubs/', - ], - - // A directory list that defines files that will be excluded - // from static analysis, but whose class and method - // information should be included. - // - // Generally, you'll want to include the directories for - // third-party code (such as "vendor/") in this list. - // - // n.b.: If you'd like to parse but not analyze 3rd - // party code, directories containing that code - // should be added to the `directory_list` as - // to `exclude_analysis_directory_list`. - "exclude_analysis_directory_list" => [ - 'htdocs/includes/', - 'htdocs/install/doctemplates/websites/', - 'htdocs/core/class/lessc.class.php', // External library - PHAN_DIR . '/stubs/', - ], - //'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', - 'exclude_file_regex' => '@^(' // @phpstan-ignore-line +$config['exclude_file_regex'] = '@^(' // @phpstan-ignore-line .'dummy' // @phpstan-ignore-line .'|htdocs/.*/canvas/.*/tpl/.*.tpl.php' // @phpstan-ignore-line .'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line @@ -108,144 +29,12 @@ return [ .'|htdocs/conf/conf.php' // @phpstan-ignore-line //.'|htdocs/[^c][^o][^r][^e][^/].*' // For testing @phpstan-ignore-line //.'|htdocs/[^h].*' // For testing on restricted set @phpstan-ignore-line - .')@', // @phpstan-ignore-line + .')@'; // @phpstan-ignore-line - // A list of plugin files to execute. - // Plugins which are bundled with Phan can be added here by providing their name - // (e.g. 'AlwaysReturnPlugin') - // - // Documentation about available bundled plugins can be found - // at https://github.com/phan/phan/tree/master/.phan/plugins - // - // Alternately, you can pass in the full path to a PHP file - // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') - 'ParamMatchRegexPlugin' => [ - '/^isModEnabled$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], - ], - 'plugins' => [ - __DIR__.'/plugins/ParamMatchRegexPlugin.php', - 'DeprecateAliasPlugin', - // __DIR__.'/plugins/NoVarDumpPlugin.php', - //__DIR__.'/plugins/GetPostFixerPlugin.php', - //'PHPDocToRealTypesPlugin', +// $config['plugins'][] = __DIR__.'/plugins/ParamMatchRegexPlugin.php'; +$config['plugins'][] = 'DeprecateAliasPlugin'; +$config['plugins'][] = 'DeprecateAliasPlugin'; +// $config['plugins'][] = __DIR__.'/plugins/GetPostFixerPlugin.php'; +// $config['plugins'][] = 'PHPDocToRealTypesPlugin'; - /* - //'EmptyMethodAndFunctionPlugin', - 'InvalidVariableIssetPlugin', - //'MoreSpecificElementTypePlugin', - 'NoAssertPlugin', - 'NotFullyQualifiedUsagePlugin', - 'PHPDocRedundantPlugin', - 'PHPUnitNotDeadCodePlugin', - //'PossiblyStaticMethodPlugin', - 'PreferNamespaceUsePlugin', - 'PrintfCheckerPlugin', - 'RedundantAssignmentPlugin', - - 'ConstantVariablePlugin', // Warns about values that are actually constant - //'HasPHPDocPlugin', // Requires PHPDoc - 'InlineHTMLPlugin', // html in PHP file, or at end of file - 'NonBoolBranchPlugin', // Requires test on bool, nont on ints - 'NonBoolInLogicalArithPlugin', - 'NumericalComparisonPlugin', - 'PHPDocToRealTypesPlugin', - 'PHPDocInWrongCommentPlugin', // Missing /** (/* was used) - //'ShortArrayPlugin', // Checks that [] is used - //'StrictLiteralComparisonPlugin', - 'UnknownClassElementAccessPlugin', - 'UnknownElementTypePlugin', - 'WhitespacePlugin', - //'RemoveDebugStatementPlugin', // Reports echo, print, ... - //'StrictComparisonPlugin', // Expects === - 'SuspiciousParamOrderPlugin', - 'UnsafeCodePlugin', - //'UnusedSuppressionPlugin', - - 'AlwaysReturnPlugin', - //'DollarDollarPlugin', - 'DuplicateArrayKeyPlugin', - 'DuplicateExpressionPlugin', - 'PregRegexCheckerPlugin', - 'PrintfCheckerPlugin', - 'SleepCheckerPlugin', - // Checks for syntactically unreachable statements in - // the global scope or function bodies. - 'UnreachableCodePlugin', - 'UseReturnValuePlugin', - 'EmptyStatementListPlugin', - 'LoopVariableReusePlugin', - */ - ], - - // Add any issue types (such as 'PhanUndeclaredMethod') - // here to inhibit them from being reported - 'suppress_issue_types' => [ - 'PhanCompatibleNegativeStringOffset', // return false positive - - 'PhanPluginWhitespaceTab', // Dolibarr used tabs - 'PhanPluginCanUsePHP71Void', // Dolibarr is maintaining 7.0 compatibility - 'PhanPluginShortArray', // Dolibarr uses array() - 'PhanPluginShortArrayList', // Dolibarr uses array() - // The following may require that --quick is not used - // Fixers From PHPDocToRealTypesPlugin: - 'PhanPluginCanUseParamType', // Fixer - Report/Add types in the function definition (function abc(string $var) (adds string) - 'PhanPluginCanUseReturnType', // Fixer - Report/Add return types in the function definition (function abc(string $var) (adds string) - 'PhanPluginCanUseNullableParamType', // Fixer - Report/Add nullable parameter types in the function definition - 'PhanPluginCanUseNullableReturnType', // Fixer - Report/Add nullable return types in the function definition - - 'PhanPluginNonBoolBranch', // Not essential - 31240+ occurrences - 'PhanPluginNumericalComparison', // Not essential - 19870+ occurrences - 'PhanTypeMismatchArgument', // Not essential - 12300+ occurrences - 'PhanPluginNonBoolInLogicalArith', // Not essential - 11040+ occurrences - 'PhanPluginConstantVariableScalar', // Not essential - 5180+ occurrences - 'PhanPluginDuplicateAdjacentStatement', - 'PhanPluginDuplicateConditionalTernaryDuplication', // 2750+ occurrences - 'PhanPluginDuplicateConditionalNullCoalescing', // Not essential - 990+ occurrences - 'PhanPluginRedundantAssignmentInGlobalScope', // Not essential, a lot of false warning - ], - // You can put relative paths to internal stubs in this config option. - // Phan will continue using its detailed type annotations, - // but load the constants, classes, functions, and classes (and their Reflection types) - // from these stub files (doubling as valid php files). - // Use a different extension from php (and preferably a separate folder) - // to avoid accidentally parsing these as PHP (includes projects depending on this). - // The 'mkstubs' script can be used to generate your own stubs (compatible with php 7.0+ right now) - // Note: The array key must be the same as the extension name reported by `php -m`, - // so that phan can skip loading the stubs if the extension is actually available. - 'autoload_internal_extension_signatures' => [ - // Stubs may be available at https://github.com/JetBrains/phpstorm-stubs/tree/master - - // Xdebug stubs are bundled with Phan 0.10.1+/0.8.9+ for usage, - // because Phan disables xdebug by default. - //'xdebug' => 'vendor/phan/phan/.phan/internal_stubs/xdebug.phan_php', - //'memcached' => PHAN_DIR . '/your_internal_stubs_folder_name/memcached.phan_php', - //'PDO' => PHAN_DIR . '/stubs/PDO.phan_php', - 'brotli' => PHAN_DIR . '/stubs/brotli.phan_php', - 'curl' => PHAN_DIR . '/stubs/curl.phan_php', - 'calendar' => PHAN_DIR . '/stubs/calendar.phan_php', - 'fileinfo' => PHAN_DIR . '/stubs/fileinfo.phan_php', - 'ftp' => PHAN_DIR . '/stubs/ftp.phan_php', - 'gd' => PHAN_DIR . '/stubs/gd.phan_php', - 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', - 'imap' => PHAN_DIR . '/stubs/imap.phan_php', - 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', - 'intl' => PHAN_DIR . '/stubs/intl.phan_php', - 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', - 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', - 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', - 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', - 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', - 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', - 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', - 'pdo_pgsql' => PHAN_DIR . '/stubs/pdo_pgsql.phan_php', - 'pdo_sqlite' => PHAN_DIR . '/stubs/pdo_sqlite.phan_php', - 'pgsql' => PHAN_DIR . '/stubs/pgsql.phan_php', - 'session' => PHAN_DIR . '/stubs/session.phan_php', - 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', - 'soap' => PHAN_DIR . '/stubs/soap.phan_php', - 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', - 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', - 'zip' => PHAN_DIR . '/stubs/zip.phan_php', - ], - - ]; +return $config; From a30bf48e1676afd86199e62b73a108f161be064f Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 01:14:55 +0100 Subject: [PATCH 090/315] Improve phpdoc typing --- htdocs/core/lib/functions.lib.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b258dc47d5d..49fffa7be7c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -642,8 +642,8 @@ function GETPOSTISSET($paramname) * Return true if the parameter $paramname is submit from a POST OR GET as an array. * Can be used before GETPOST to know if the $check param of GETPOST need to check an array or a string * - * @param string $paramname Name or parameter to test - * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get) + * @param string $paramname Name or parameter to test + * @param int<0,3> $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get) * @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty) */ function GETPOSTISARRAY($paramname, $method = 0) @@ -1011,9 +1011,9 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null * Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] * Note: The property $user->default_values is loaded by main.php when loading the user. * - * @param string $paramname Name of the $_GET or $_POST parameter - * @param int $method Type of method (0 = $_GET then $_POST, 1 = only $_GET, 2 = only $_POST, 3 = $_POST then $_GET) - * @return int Value converted into integer + * @param string $paramname Name of the $_GET or $_POST parameter + * @param int<0,3> $method Type of method (0 = $_GET then $_POST, 1 = only $_GET, 2 = only $_POST, 3 = $_POST then $_GET) + * @return int Value converted into integer */ function GETPOSTINT($paramname, $method = 0) { @@ -1663,10 +1663,10 @@ function dol_string_nounprintableascii($str, $removetabcrlf = 1) /** * Returns text escaped for inclusion into javascript code * - * @param string $stringtoescape String to escape - * @param int $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \ - * @param int $noescapebackslashn 0=Escape also \n. 1=Do not escape \n. - * @return string Escaped string. Both ' and " are escaped into ' if they are escaped. + * @param string $stringtoescape String to escape + * @param int<0,3> $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \ + * @param int $noescapebackslashn 0=Escape also \n. 1=Do not escape \n. + * @return string Escaped string. Both ' and " are escaped into ' if they are escaped. */ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) { @@ -2420,7 +2420,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab /** * Show tab footer of a card * - * @param int $notab -1 or 0=Add tab footer, 1=no tab footer + * @param int<-1,1> $notab -1 or 0=Add tab footer, 1=no tab footer * @return void * @deprecated Use print dol_get_fiche_end() instead */ @@ -2432,7 +2432,7 @@ function dol_fiche_end($notab = 0) /** * Return tab footer of a card * - * @param int $notab -1 or 0=Add tab footer, 1=no tab footer + * @param int<-1,1> $notab -1 or 0=Add tab footer, 1=no tab footer * @return string */ function dol_get_fiche_end($notab = 0) From 6e5841b13dc76288735bab684242989235af7275 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 01:21:07 +0100 Subject: [PATCH 091/315] Add checks on checkVal, price2num and GETPOSTFLOAT arguments --- dev/tools/phan/config.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index c70f6dd5058..92760bd48d5 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -350,10 +350,13 @@ return [ // Note: trick to have different key for same regex: '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], '/^sanitizeVal$/' => [1, $sanitizeRegex,"UnknownSanitizeType"], + '/^checkVal$/' => [1, $sanitizeRegex,"UnknownCheckValSanitizeType"], '/^\\\\ExtraFields::addExtraField$/' => [2, $extraFieldTypeRegex,"UnknownExtrafieldTypeBack"], '/^dol_now$/' => [0, '{^(?:auto|gmt|tz(?:server|ref|user(?:rel)?))$}',"InvalidDolNowArgument"], // '', 0, 1 match bool and int values '/^dol_mktime$/' => [6, '{^(?:|0|1|auto|gmt|tz(?:server|ref|user(?:rel)?|,[+a-zA-Z-/]+))$}',"InvalidDolMktimeArgument"], // '', 0, 1 match bool and int values '/^dol_print_date$/' => [2, '{^(?:|0|1|auto|gmt|tz(?:server|user(?:rel)?))$}',"InvalidDolMktimeArgument"], + '/^GETPOSTFLOAT$/' => [1, '{^(?:|M[UTS]|C[UT]|\d+)$}',"InvalidGetPostFloatRounding"], + '/^price2num$/' => [1, '{^(?:|M[UTS]|C[UT]|\d+)$}',"InvalidPrice2NumRounding"], ], 'plugins' => [ __DIR__.'/plugins/NoVarDumpPlugin.php', From 1c9c665b0b208c5613c1718166971fe4aa873670 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 01:42:24 +0100 Subject: [PATCH 092/315] Update baseline (improved) --- dev/tools/phan/baseline.txt | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 46d02c0404f..6fa9139c750 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,24 +9,21 @@ */ return [ // # Issue statistics: - // PhanParamSignatureMismatch : 25+ occurrences + // PhanParamSignatureMismatch : 20+ occurrences // PhanPluginSuspiciousParamPosition : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences - // PhanTypeMismatchReturn : 8 occurrences - // PhanRedefineFunctionInternal : 6 occurrences - // PhanTypeArraySuspiciousNull : 6 occurrences + // PhanTypeMismatchReturn : 5 occurrences // PhanParamTooMany : 4 occurrences - // PhanTypeMismatchReturnNullable : 3 occurrences // PhanAccessMethodProtected : 1 occurrence // PhanAccessPropertyStaticAsNonStatic : 1 occurrence // PhanNoopStringLiteral : 1 occurrence + // PhanTypeArraySuspiciousNull : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'htdocs/adherents/admin/member.php' => ['PhanParamTooMany'], 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/barcode/printsheet.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected'], @@ -36,23 +33,15 @@ return [ 'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/class/commondocgenerator.class.php' => ['PhanTypeArraySuspiciousNull'], - 'htdocs/core/class/commonobject.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/class/extrafields.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/class/html.form.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/pgsql.class.php' => ['PhanParamSignatureMismatch'], - 'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnNullable'], + 'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanRedefineFunctionInternal'], 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidRightOperandOfAdd'], - 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch'], - 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], - 'htdocs/expedition/class/api_shipments.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/expensereport/class/api_expensereports.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/fourn/class/fournisseur.commande.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/fourn/class/fournisseur.facture.class.php' => ['PhanTypeMismatchReturn'], From 24e48998cec40b7151271afe7fdac1623a1367d9 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 11:32:50 +0100 Subject: [PATCH 093/315] Add nempty to spelling --- dev/tools/codespell/codespell-dict.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tools/codespell/codespell-dict.txt b/dev/tools/codespell/codespell-dict.txt index 1cd7ec6bfb2..32bfa0aa414 100644 --- a/dev/tools/codespell/codespell-dict.txt +++ b/dev/tools/codespell/codespell-dict.txt @@ -18,6 +18,7 @@ dollibarr->dolibarr extrafeild->extrafield thoose->those # fiche->card +nempty->an empty, empty, not empty, mot de passe->password not de passe->password nothtml->nohtml From 25faef6da81fddc205542317d1e92a38f8eb95d8 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 11:34:32 +0100 Subject: [PATCH 094/315] Improve typing for arg $showempty --- htdocs/core/class/html.form.class.php | 124 +++++++++++++------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e14b020b144..97082b64db2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -926,7 +926,7 @@ class Form * @param integer $maxlength Max length for labels (0=no limit) * @param string $morecss More css class * @param string $usecodeaskey ''=Use id as key (default), 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key - * @param int|string $showempty Show empty choice + * @param int<0,1>|string $showempty Show empty choice * @param int $disablefavorites 1=Disable favorites, * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...) * @param array $exclude_country_code Array of country code (iso2) to exclude @@ -1148,7 +1148,7 @@ class Form * * @param string $selected Preselected type * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field + * @param int<0,1> $showempty Add an empty field * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') * @return void @@ -1303,7 +1303,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter Optional filters criteras. WARNING: To avoid SQL injection, only few chars [.a-z0-9 =<>()] are allowed here. Example: ((s.client:IN:1,3) AND (s.status:=:1)). Do not use a filter coming from input of users. - * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') + * @param string|int<1,1> $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -1381,8 +1381,8 @@ class Form * @param string $filter Optional filters criteras. WARNING: To avoid SQL injection, only few chars [.a-z0-9 =<>] are allowed here, example: 's.rowid <> x' * If you need parenthesis, use the Universal Filter Syntax, example: '(s.client:in:1,3)' * Do not use a filter coming from input of users. - * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param string|int<0,1> $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') + * @param int<0,1> $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use standard HTML select component without beautification * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $filterkey Filter on key value @@ -1720,7 +1720,7 @@ class Form * @param int $socid Id of third party or 0 for all * @param string $selected Id of preselected contact * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list + * @param int<0,3> $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list * @param integer $showfunction Add function into label @@ -1750,7 +1750,7 @@ class Form * @param int $socid Id of third party or 0 for all or -1 for empty list * @param array|int $selected Array of ID of preselected contact id * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int|string $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list + * @param int<0,3>|string $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list * @param integer $showfunction Add function into label @@ -2458,7 +2458,7 @@ class Form * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @param int $hidepriceinlabel 1=Hide prices in label @@ -2623,7 +2623,7 @@ class Form * @param int $limit Limit on number of returned lines * @param int $status Sell status -1=Return all bom, 0=Draft BOM, 1=Validated BOM * @param int $type type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param string $morecss Add more css on select * @param string $nooutput No print, return the output into a string * @param int $forcecombo Force to use combo box @@ -2709,7 +2709,7 @@ class Form * @param int $finished Filter on finished field: 2=No filter * @param int $outputmode 0=HTML select string, 1=Array * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @param int $hidepriceinlabel 1=Hide prices in label @@ -4838,13 +4838,13 @@ class Form } /** - * Creates HTML units selector (code => label) + * Creates HTML units selector (code => label) * - * @param string $selected Preselected Unit ID - * @param string $htmlname Select name - * @param int $showempty Add a nempty line - * @param string $unit_type Restrict to one given unit type - * @return string HTML select + * @param string $selected Preselected Unit ID + * @param string $htmlname Select name + * @param int<0,1> $showempty Add an empty line + * @param string $unit_type Restrict to one given unit type + * @return string HTML select */ public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0, $unit_type = '') { @@ -6205,9 +6205,9 @@ class Form * @param string $selected Id preselected * @param string $htmlname Name of HTML select * @param string $filter Optional filters criteras. WARNING: To avoid SQL injection, only few chars [.a-z0-9 =<>()] are allowed here (example: 's.rowid <> x', 's.client IN (1,3)'). Do not use a filter coming from input of users. - * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box + * @param string|int<0,1> $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') + * @param int<0,1> $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int<0,1> $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param int $nooutput No print output. Return it only. * @param array $excludeids Exclude IDs from the select combo @@ -7355,21 +7355,21 @@ class Form /** * Return list of tickets in Ajax if Ajax activated or go to selectTicketsList * - * @param string $selected Preselected tickets - * @param string $htmlname Name of HTML select field (must be unique in page). - * @param string $filtertype To add a filter - * @param int $limit Limit on number of returned lines - * @param int $status Ticket status - * @param string $selected_input_value Value of preselected input text (for use with ajax) - * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) - * @param array $ajaxoptions Options for ajax_autocompleter - * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box - * @param string $morecss Add more css on select - * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) - * @param int $nooutput No print, return the output into a string - * @return string + * @param string $selected Preselected tickets + * @param string $htmlname Name of HTML select field (must be unique in page). + * @param string $filtertype To add a filter + * @param int $limit Limit on number of returned lines + * @param int $status Ticket status + * @param string $selected_input_value Value of preselected input text (for use with ajax) + * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) + * @param array $ajaxoptions Options for ajax_autocompleter + * @param int $socid Thirdparty Id (to get also price dedicated to this customer) + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param int<0,1> $forcecombo Force to use combo box + * @param string $morecss Add more css on select + * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) + * @param int $nooutput No print, return the output into a string + * @return string */ public function selectTickets($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0) { @@ -7422,20 +7422,20 @@ class Form /** - * Return list of tickets. + * Return list of tickets. * Called by selectTickets. * - * @param string $selected Preselected ticket - * @param string $htmlname Name of select html - * @param string $filtertype Filter on ticket type - * @param int $limit Limit on number of returned lines - * @param string $filterkey Filter on ticket ref or subject - * @param int $status Ticket status - * @param int $outputmode 0=HTML select string, 1=Array - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string $selected Preselected ticket + * @param string $htmlname Name of select html + * @param string $filtertype Filter on ticket type + * @param int $limit Limit on number of returned lines + * @param string $filterkey Filter on ticket ref or subject + * @param int $status Ticket status + * @param int $outputmode 0=HTML select string, 1=Array + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box - * @param string $morecss Add more css on select - * @return array|string Array of keys for json or HTML component + * @param string $morecss Add more css on select + * @return array|string Array of keys for json or HTML component */ public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '') { @@ -7590,7 +7590,7 @@ class Form * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) @@ -7657,7 +7657,7 @@ class Form * @param string $filterkey Filter on project ref or subject * @param int $status Ticket status * @param int $outputmode 0=HTML select string, 1=Array - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @return array|string Array of keys for json or HTML component @@ -7819,7 +7819,7 @@ class Form * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon before and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) @@ -7889,7 +7889,7 @@ class Form * @param string $filterkey Filter on member status * @param int $status Member status * @param int $outputmode 0=HTML select string, 1=Array - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string|int<0,1> $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @return array|string Array of keys for json or HTML string component @@ -8042,18 +8042,18 @@ class Form * Can use autocomplete with ajax after x key pressed or a full combo, depending on setup. * This is the generic method that will replace all specific existing methods. * - * @param string $objectdesc 'ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]'. For hard coded custom needs. Try to prefer method using $objectfield instead of $objectdesc. - * @param string $htmlname Name of HTML select component - * @param int $preSelectedValue Preselected value (ID of element) - * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) - * @param string $searchkey Search criteria - * @param string $placeholder Place holder - * @param string $morecss More CSS - * @param string $moreparams More params provided to ajax call - * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) - * @param int $disabled 1=Html component is disabled - * @param string $selected_input_value Value of preselected input text (for use with ajax) - * @param string $objectfield Object:Field that contains the definition (in table $fields or $extrafields). Example: 'Object:xxx' or 'Module_Object:xxx' or 'Object:options_xxx' or 'Module_Object:options_xxx' + * @param string $objectdesc 'ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]'. For hard coded custom needs. Try to prefer method using $objectfield instead of $objectdesc. + * @param string $htmlname Name of HTML select component + * @param int $preSelectedValue Preselected value (ID of element) + * @param string|int<0,1> $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) + * @param string $searchkey Search criteria + * @param string $placeholder Place holder + * @param string $morecss More CSS + * @param string $moreparams More params provided to ajax call + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) + * @param int $disabled 1=Html component is disabled + * @param string $selected_input_value Value of preselected input text (for use with ajax) + * @param string $objectfield Object:Field that contains the definition (in table $fields or $extrafields). Example: 'Object:xxx' or 'Module_Object:xxx' or 'Object:options_xxx' or 'Module_Object:options_xxx' * @return string Return HTML string * @see selectForFormsList(), select_thirdparty_list() */ @@ -8201,7 +8201,7 @@ class Form * @param Object $objecttmp Object to know the table to scan for combo. * @param string $htmlname Name of HTML select component * @param int $preselectedvalue Preselected value (ID of element) - * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) + * @param string|int<0,1> $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) * @param string $searchkey Search value * @param string $placeholder Place holder * @param string $morecss More CSS From ceeaf8b53488e3245ea34d3a5ee467f39044274b Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 11:41:53 +0100 Subject: [PATCH 095/315] Be less restrictive on links index (for phpstan) --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 49fffa7be7c..33fba3f8641 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2220,7 +2220,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 /** * Show tabs of a record * - * @param array,string>> $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. + * @param array> $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. * @param string $active Active tab name * @param string $title Title * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no separation under tab (to start a tab just after), -3=-2+'noborderbottom' From f41d21407fb6dd0141e10ad13cab6923e1f440c2 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 12:11:42 +0100 Subject: [PATCH 096/315] Fix typing for $links arg in dol_fiche_head() --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 33fba3f8641..d58ee238e15 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2220,7 +2220,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 /** * Show tabs of a record * - * @param array> $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. + * @param array,string>> $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. * @param string $active Active tab name * @param string $title Title * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no separation under tab (to start a tab just after), -3=-2+'noborderbottom' From c0fd71f922095b0601d80f3ac11c4da16c285dc4 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 14:29:44 +0100 Subject: [PATCH 097/315] PHPdoc - correct return type for countMembersByTypeAndStatus --- htdocs/adherents/class/adherentstats.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 612f408edd9..3417d97eec7 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -170,7 +170,7 @@ class AdherentStats extends Stats * Return count of member by status group by adh type, total and average * * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus($numberYears = 0) { From ebb4c2111acccdafdf21202e3fc6b90c4db4c36d Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 14:40:42 +0100 Subject: [PATCH 098/315] Improve gender, admin, entity typing --- htdocs/user/class/user.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2bbbb39519f..40d316d9ebc 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -11,9 +11,9 @@ * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2018 charlene Benke - * Copyright (C) 2018-2021 Nicolas ZABOURI - * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2019 Abbes Bahfir + * Copyright (C) 2018-2021 Nicolas ZABOURI + * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019 Abbes Bahfir * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -112,7 +112,7 @@ class User extends CommonObject public $fullname; /** - * @var string gender + * @var string|int<-1,-1> gender (man|woman|other) */ public $gender; @@ -337,7 +337,7 @@ class User extends CommonObject public $lastsearch_values; // To store last saved search criteria for user /** - * @var array|array Array of User (filled from fetchAll) or Array with hierarchy of user information (filled with get_full_tree() + * @var array|array,admin:int<0,1>,photo:string,fullpath:string,fullname:string,level:int}> Array of User (filled from fetchAll) or Array with hierarchy of user information (filled with get_full_tree() */ public $users = array(); public $parentof; // To store an array of all parents for all ids. @@ -1745,7 +1745,7 @@ class User extends CommonObject $this->civility_code = $contact->civility_code; $this->lastname = $contact->lastname; $this->firstname = $contact->firstname; - //$this->gender = $contact->gender; // contact ha sno gender + //$this->gender = $contact->gender; // contact has no gender $this->email = $contact->email; $this->socialnetworks = $contact->socialnetworks; $this->office_phone = $contact->phone_pro; @@ -2067,7 +2067,7 @@ class User extends CommonObject $sql .= ", employee = ".(int) $this->employee; $sql .= ", login = '".$this->db->escape($this->login)."'"; $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape(dolEncrypt($this->api_key, '', '', 'dolibarr'))."'" : "null"); - $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' + $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' or 'other' $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth, 'tzserver')."'" : 'null'); if (!empty($user->admin)) { $sql .= ", admin = ".(int) $this->admin; // admin flag can be set/unset only by an admin user @@ -3706,7 +3706,7 @@ class User extends CommonObject * * @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree. * @param string $filter SQL filter on users. This parameter must not come from user input. - * @return int<-1,-1>|array Array of user information (also: $this->users). Note: $this->parentof is also set. + * @return int<-1,-1>|array,admin:int<0,1>,photo:string,fullpath:string,fullname:string,level:int}> Array of user information (also: $this->users). Note: $this->parentof is also set. */ public function get_full_tree($deleteafterid = 0, $filter = '') { From bf6cd7949459ba0da812b593d0113926373de6f0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:10:28 +0100 Subject: [PATCH 099/315] Improve typing for member_prepare_head() return value --- htdocs/core/lib/member.lib.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 8283de2dc75..ce5294d3ff9 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2015-2016 Alexandre Spangaro * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2024 MDW * * 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 @@ -27,8 +28,8 @@ /** * Return array head with list of tabs to view object information * - * @param Adherent $object Member - * @return array head + * @param Adherent $object Member + * @return array> head links */ function member_prepare_head(Adherent $object) { @@ -128,7 +129,7 @@ function member_prepare_head(Adherent $object) // Show agenda tab $head[$h][0] = DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; // Enable caching of thirdparty count actioncomm require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; @@ -170,7 +171,7 @@ function member_prepare_head(Adherent $object) * Return array head with list of tabs to view object information * * @param AdherentType $object Member - * @return array head + * @return array> head links */ function member_type_prepare_head(AdherentType $object) { @@ -216,7 +217,7 @@ function member_type_prepare_head(AdherentType $object) /** * Return array head with list of tabs to view object information * - * @return array head + * @return array> head links */ function member_admin_prepare_head() { @@ -278,7 +279,7 @@ function member_admin_prepare_head() * Return array head with list of tabs to view object stats information * * @param Adherent $object Member or null - * @return array head + * @return array> head links */ function member_stats_prepare_head($object) { @@ -332,7 +333,7 @@ function member_stats_prepare_head($object) * Return array head with list of tabs to view object information * * @param Subscription $object Subscription - * @return array head + * @return array> head links */ function subscription_prepare_head(Subscription $object) { From 84ce3baeaf44960c5c56cb9e2fcddbac8c781ada Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:22:48 +0100 Subject: [PATCH 100/315] Fix arguments to dol_get_fiche_head --- htdocs/categories/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 06510e44aa7..04c9953d92c 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -240,7 +241,7 @@ if ($user->hasRight('categorie', 'creer')) { print load_fiche_titre($langs->trans("CreateCat")); - print dol_get_fiche_head(''); + print dol_get_fiche_head(); print ''; @@ -282,7 +283,7 @@ if ($user->hasRight('categorie', 'creer')) { print '
    '; - print dol_get_fiche_end(''); + print dol_get_fiche_end(); print '
    '; print ''; From 3ea9ca350cddbdb1d11de2b5253303e79d04d415 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:22:51 +0100 Subject: [PATCH 101/315] Fix arguments to dol_get_fiche_head --- htdocs/core/class/html.formticket.class.php | 31 +++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index a5bf6539ac3..aac53b58353 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2021 Juanjo Menent * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2023 Charlene Benke + * Copyright (C) 2024 MDW * * 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 @@ -138,7 +139,7 @@ class FormTicket $this->withcompany = !getDolGlobalInt("TICKETS_NO_COMPANY_ON_FORM") && isModEnabled("societe"); $this->withfromsocid = 0; $this->withfromcontactid = 0; - $this->withreadid=0; + $this->withreadid = 0; //$this->withtitletopic=''; $this->withnotifytiersatcreate = 0; $this->withusercreate = 1; @@ -911,8 +912,8 @@ class FormTicket } elseif ($htmlname != '') { $selectedgroups = array(); $groupvalue = ""; - $groupticket=GETPOST($htmlname, 'aZ09'); - $child_id=GETPOST($htmlname.'_child_id', 'aZ09') ? GETPOST($htmlname.'_child_id', 'aZ09') : 0; + $groupticket = GETPOST($htmlname, 'aZ09'); + $child_id = GETPOST($htmlname.'_child_id', 'aZ09') ? GETPOST($htmlname.'_child_id', 'aZ09') : 0; if (!empty($groupticket)) { $tmpgroupticket = $groupticket; $sql = "SELECT ctc.rowid, ctc.fk_parent, ctc.code"; @@ -1025,7 +1026,7 @@ class FormTicket if ($resql) { $num_rows = $this->db->num_rows($resql); $i = 0; - $arrayidused=array(); + $arrayidused = array(); while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); if ($obj) { @@ -1054,7 +1055,7 @@ class FormTicket } $stringtoprint .= ''; if (empty($tabscript[$groupcodefather])) { - $tabscript[$groupcodefather] = 'if ($("#'.$htmlname.($levelid > 1 ? '_child_'.($levelid-1) : '').'").val() == "'.dol_escape_js($groupcodefather).'"){ + $tabscript[$groupcodefather] = 'if ($("#'.$htmlname.($levelid > 1 ? '_child_'.($levelid - 1) : '').'").val() == "'.dol_escape_js($groupcodefather).'"){ $(".'.$htmlname.'_'.dol_escape_htmltag($fatherid).'_child_'.$levelid.'").show() console.log("We show child tickets of '.$groupcodefather.' group ticket") }else{ @@ -1068,11 +1069,11 @@ class FormTicket } else { dol_print_error($this->db); } - $stringtoprint .=''; + $stringtoprint .= ''; - $stringtoprint .=''; + $stringtoprint .= '})'; + $stringtoprint .= ''; } - $stringtoprint .=''; + $stringtoprint .= ''; $stringtoprint .= ajax_combobox($htmlname); return $stringtoprint; From a61e3d38994a88b749ef15be4109213e834c0dab Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:22:53 +0100 Subject: [PATCH 102/315] Fix arguments to dol_get_fiche_head --- htdocs/fichinter/card.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a8301b48558..507affb5fab 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -11,6 +11,7 @@ * Copyright (C) 2020-2024 Frédéric France * Copyright (C) 2023 Benjamin Grembi * Copyright (C) 2023-2024 William Mead + * Copyright (C) 2024 MDW * * 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 @@ -117,7 +118,7 @@ $usercancreate = $user->hasRight('ficheinter', 'creer'); * Actions */ -$parameters = array('socid'=>$socid); +$parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -1185,7 +1186,7 @@ if ($action == 'create') { } if (!$formconfirm) { - $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid); + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; @@ -1204,8 +1205,8 @@ if ($action == 'create') { $morehtmlref = '
    '; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '
    '.$object->thirdparty->getNomUrl(1, 'customer'); // Project From 31cc9ffb1605ee0a163807aab88bd08d2fe3be0a Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:22:55 +0100 Subject: [PATCH 103/315] Fix arguments to dol_get_fiche_head --- htdocs/intracommreport/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 7adc9ea0eb7..8557b019fa6 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -1,6 +1,7 @@ * Copyright (C) 2019-2020 Open-DSI + * Copyright (C) 2024 MDW * * 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 @@ -234,7 +235,7 @@ if ($id > 0 && $action != 'edit') { */ //$head = intracommreport_prepare_head($object); - print dol_get_fiche_head("", 'general', $langs->trans("IntracommReport"), -1, 'user'); + print dol_get_fiche_head(array(), 'general', $langs->trans("IntracommReport"), -1, 'user'); // Confirm remove report if ($action == 'delete') { From 8c19fe57dd22e6c1e41bc5c84e2e07876d8f7778 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:22:58 +0100 Subject: [PATCH 104/315] Fix arguments to dol_get_fiche_head --- htdocs/modulebuilder/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 3c0d1e41776..0de6c3e47d8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -4960,7 +4960,7 @@ if ($module == 'initmodule') { print ''.$langs->trans("EnterNameOfDictionaryDesc").'

    '; - print dol_get_fiche_head(''); + print dol_get_fiche_head(); print ''; print ''; print ''; From bdfb1b9a0087d94603cdaf416d2860b803fd5b83 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:01 +0100 Subject: [PATCH 105/315] Fix arguments to dol_get_fiche_head --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3813ec3432e..478f9641615 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1364,7 +1364,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $object->country = $tmparray['label']; } - print dol_get_fiche_head(''); + print dol_get_fiche_head(); // Call Hook tabContentCreateProduct $parameters = array(); @@ -3032,7 +3032,7 @@ if (getDolGlobalString('PRODUCT_ADD_FORM_ADD_TO') && $object->id && ($action == print load_fiche_titre($langs->trans("AddToDraft"), '', ''); - print dol_get_fiche_head(''); + print dol_get_fiche_head(); $html .= ''; From faae9b921a686b9550316aac8fc9c384ca487d72 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:05 +0100 Subject: [PATCH 106/315] Fix arguments to dol_get_fiche_head --- htdocs/product/price.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2ad194f3413..62cf075097b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1417,7 +1417,7 @@ if ($action == 'edit_vat' && ($user->hasRight('produit', 'creer') || $user->hasR print ''; print ''; - print dol_get_fiche_head(''); + print dol_get_fiche_head(); print '
    '.$langs->trans("Table").'
    '.$langs->trans("Quantity").' '; $html .= '
    '; @@ -1446,7 +1446,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) { print ''; print ''; - print dol_get_fiche_head(''); + print dol_get_fiche_head(); print '
    '; print '
    '; @@ -1582,7 +1582,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) { print ''; print ''; - //print dol_get_fiche_head('', '', '', -1); + //print dol_get_fiche_head(array(), '', '', -1); if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && getDolGlobalString('PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL')) { print $langs->trans('UseMultipriceRules').' price_autogen ? 'checked' : '').'>

    '; From 47ef0645cfbda3138b7ceb51430226d1b1a67395 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:08 +0100 Subject: [PATCH 107/315] Fix arguments to dol_get_fiche_head --- htdocs/projet/tasks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index d0e044f03b3..da7cd0581d2 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -724,7 +724,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer') && (empty($object- print ''; } - print dol_get_fiche_head(''); + print dol_get_fiche_head(); print '
    '; print '
    '; From 5c0917cf898fafc52eba073b9c2e50f25954f44c Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:11 +0100 Subject: [PATCH 108/315] Fix arguments to dol_get_fiche_head --- htdocs/public/company/new.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index 289adc1020b..0d26ad7ad9d 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -8,6 +8,7 @@ * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021 Waël Almoman * Copyright (C) 2022 Udo Tamm + * Copyright (C) 2024 MDW * * 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 @@ -327,7 +328,7 @@ $messagemandatory = '' . $langs->trans("FieldsWithAreMandatory", //print '
    '.$langs->trans("FieldsWithAreMandatory", '*').'
    '; //print $langs->trans("FieldsWithIsForPublic",'**').'
    '; -print dol_get_fiche_head(''); +print dol_get_fiche_head(); print ''."\n"; } - print dol_get_fiche_head(''); + print dol_get_fiche_head(); print '
    '; From 4316aa411ea2401238664e7c7cc985116af59d44 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:37 +0100 Subject: [PATCH 118/315] Fix arguments to dol_get_fiche_head --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 39cbc75b199..722e21c5cd0 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1213,7 +1213,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; } - print dol_get_fiche_head(null, 'card', '', 0, ''); + print dol_get_fiche_head(array(), 'card', '', 0, ''); // Call Hook tabContentCreateThirdparty $parameters = array(); From 66ce94bafb581c338e8c8dc3163d405efa2dee39 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:41 +0100 Subject: [PATCH 119/315] Fix arguments to dol_get_fiche_head --- htdocs/user/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 2b68a23c5c5..2863f54963e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -15,6 +15,7 @@ * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2018 David Beniamine + * Copyright (C) 2024 MDW * * 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 @@ -890,7 +891,7 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; - print dol_get_fiche_head('', '', '', 0, ''); + print dol_get_fiche_head(array(), '', '', 0, ''); dol_set_focus('#lastname'); From ebefa90b2561a6b65bf75e32c372e111c67a0b45 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 13:23:43 +0100 Subject: [PATCH 120/315] Fix arguments to dol_get_fiche_head --- htdocs/user/group/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 37ab864ccde..6400ee3c975 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -5,6 +5,7 @@ * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Florian Henry * Copyright (C) 2018 Juanjo Menent + * Copyright (C) 2024 MDW * * 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 @@ -274,7 +275,7 @@ if ($action == 'create') { print ''; print ''; - print dol_get_fiche_head('', '', '', 0, ''); + print dol_get_fiche_head(array(), '', '', 0, ''); print '
    '; From 13262e18d00be0d99dbf3e1f2a9e5b883f7d2980 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 26 Mar 2024 12:17:16 +0100 Subject: [PATCH 121/315] Fix: Remove 'alpha' argument to GETPOSTINT() # Fix: Remove 'alpha' argument to GETPOSTINT() Remove 'alpha' argument to GETPOSTINT() which does not take that. The targetted values are ints in this context. --- htdocs/societe/ajax/company.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index db97f1aa138..7505ea18ece 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2019 Laurent Destailleur + * Copyright (C) 2024 MDW * * 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 @@ -49,8 +50,8 @@ $outjson = (GETPOSTINT('outjson') ? GETPOSTINT('outjson') : 0); $action = GETPOST('action', 'aZ09'); $id = GETPOSTINT('id'); $excludeids = GETPOST('excludeids', 'intcomma'); -$showtype = GETPOSTINT('showtype', 'alpha'); -$showcode = GETPOSTINT('showcode', 'alpha'); +$showtype = GETPOSTINT('showtype'); +$showcode = GETPOSTINT('showcode'); $object = new Societe($db); if ($id > 0) { From 2aaa0779e25152bbea05a0f481c05334a2ef4d55 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 27 Mar 2024 10:27:15 +0100 Subject: [PATCH 122/315] FIX Missing declaration of type export FEC/FEC2 for export with file source --- htdocs/accountancy/bookkeeping/export.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 498a8ee2ed3..83f972f46c7 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -766,7 +766,10 @@ if ($action == 'export_file') { } // add documents in an archive for accountancy export (Quadratus) - if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS) { + if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS + || getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC + || getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC2 + ) { $form_question['notifiedexportfull'] = array( 'name' => 'notifiedexportfull', 'type' => 'checkbox', From bcd99c1365f6fff93a6c573d9aac96c8673390bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Thu, 28 Mar 2024 09:19:46 +0100 Subject: [PATCH 123/315] NEW: consider document lines in element properties --- htdocs/core/lib/functions.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3ff1c19a100..fa47bcc3e8b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12149,6 +12149,17 @@ function getElementProperties($elementType) $subelement = $regs[2]; } + // Object lines will use parent classpath and module ref + if (substr($element_type, -3) == 'det') { + $module = preg_replace('/det$/', '', $element); + $subelement = preg_replace('/det$/', '', $subelement); + $classpath = $module.'/class'; + $classfile = $module; + $classname = preg_replace('/det$/', 'Line', $element); + if (in_array($module, array('expedition', 'propale', 'facture', 'contrat', 'fichinter', 'commandefournisseur'))) { + $classname = preg_replace('/det$/', 'Ligne', $element); + } + } // For compatibility and to work with non standard path if ($elementType == "action") { $classpath = 'comm/action/class'; From 2ab704d630040aad60470405bb39d8624151f966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Thu, 28 Mar 2024 10:36:49 +0100 Subject: [PATCH 124/315] whoops --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index fa47bcc3e8b..d395acd38e2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12150,7 +12150,7 @@ function getElementProperties($elementType) } // Object lines will use parent classpath and module ref - if (substr($element_type, -3) == 'det') { + if (substr($elementType, -3) == 'det') { $module = preg_replace('/det$/', '', $element); $subelement = preg_replace('/det$/', '', $subelement); $classpath = $module.'/class'; From b9c50507ad44c3d78dbb60d5735549c4c3d70c65 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:59:42 +0100 Subject: [PATCH 125/315] Fix Order bug Fixed the bug that caused the update() function to delete the contents of the fk_user_author field and leave the fk_user_modif field empty. --- htdocs/commande/class/commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 11bfddf4837..7f490756ba5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3355,7 +3355,7 @@ class Commande extends CommonOrder $sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").","; $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; - $sql .= " fk_user_author=".(isset($this->user_author_id) ? $this->user_author_id : "null").","; + $sql .= " fk_user_modif=".(isset($user->id) ? $user->id : "null").","; $sql .= " fk_user_valid=".((isset($this->user_validation_id) && $this->user_validation_id > 0) ? $this->user_validation_id : "null").","; $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; From b2919085eec366fb224ed21ef318e5fe395f17ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 13:05:50 +0100 Subject: [PATCH 126/315] Update export.php --- htdocs/accountancy/bookkeeping/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 83f972f46c7..ede15e0fc2d 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -765,7 +765,7 @@ if ($action == 'export_file') { $form_question['separator3'] = array('name'=>'separator3', 'type'=>'separator'); } - // add documents in an archive for accountancy export (Quadratus) + // add documents in an archive for some accountancy export format if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS || getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC || getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_FEC2 From 09bf1acfface0b974e9a0a996fdb82205f9c09e3 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 28 Mar 2024 13:08:35 +0100 Subject: [PATCH 127/315] FIX : StockTransfer class has no table_element_line --- .../stock/stocktransfer/class/stocktransfer.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index 363929ec4ac..8772da81ec3 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -47,6 +47,11 @@ class StockTransfer extends CommonObject */ public $table_element = 'stocktransfer_stocktransfer'; + /** + * @var string Name of subtable line + */ + public $table_element_line = 'stocktransfer_stocktransferline'; + /** * @var int Does this object support multicompany module ? * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table From 574b73700bcc47f76d6883f0acdcaf203242b218 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 28 Mar 2024 13:21:35 +0100 Subject: [PATCH 128/315] FIX : StockTransfer class has no table_element_line --- .../product/stock/stocktransfer/class/stocktransfer.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index 8772da81ec3..ff385fd5fdf 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -51,7 +51,7 @@ class StockTransfer extends CommonObject * @var string Name of subtable line */ public $table_element_line = 'stocktransfer_stocktransferline'; - + /** * @var int Does this object support multicompany module ? * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table From 816e80c4d52bedcc935eb597d14de5ff0d172df6 Mon Sep 17 00:00:00 2001 From: rsanjoseo Date: Thu, 28 Mar 2024 09:02:55 +0100 Subject: [PATCH 129/315] FIX $object->oldcopy may be a stdClass and not original object depending on copy type, so we realod a new object to run the del_to_abo() --- ...e_50_modMailmanspip_Mailmanspipsynchro.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index fb161a16dbd..17312704156 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -1,6 +1,8 @@ * Copyright (C) 2014 Marcos García + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Rafael San José * * 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 @@ -115,10 +117,13 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers // Add user into some linked tools (mailman, spip, etc...) if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) { if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) { // If email has changed or if list has changed we delete mailman subscription for old email - if ($object->oldcopy->del_to_abo() < 0) { - $this->errors = $object->oldcopy->errors; - if (!empty($object->oldcopy->error)) { - $this->errors[] = $object->oldcopy->error; + // $object->oldcopy may be a stdClass and not original object depending on copy type, so we realod a new object to run the del_to_abo() + $tmpmember = new Adherent($db); + $tmpmember->fetch($object->oldcopy->id); + if ($tmpmember->del_to_abo() < 0) { + $this->errors = $tmpmember->errors; + if (!empty($tmpmember->error)) { + $this->errors[] = $tmpmember->error; } $return = -1; } else { From 3b4d4fa46f642545c6133155e961fdd52714741a Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 28 Mar 2024 13:08:35 +0100 Subject: [PATCH 130/315] FIX : StockTransfer class has no table_element_line --- .../stock/stocktransfer/class/stocktransfer.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index d76dc386e5a..451a9bbd75f 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -46,6 +46,11 @@ class StockTransfer extends CommonObject */ public $table_element = 'stocktransfer_stocktransfer'; + /** + * @var string Name of subtable line + */ + public $table_element_line = 'stocktransfer_stocktransferline'; + /** * @var int Does this object support multicompany module ? * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table From 7fd3ed35d69c8e861dc0aa4740dd117b14a95d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 28 Mar 2024 14:24:51 +0100 Subject: [PATCH 131/315] fix interface_50_modMailmanspip_Mailmanspipsynchro.class.php --- .../interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index 88dfe698910..4626228ef93 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -117,7 +117,7 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) { if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) { // If email has changed or if list has changed we delete mailman subscription for old email // $object->oldcopy may be a stdClass and not original object depending on copy type, so we realod a new object to run the del_to_abo() - $tmpmember = new Adherent($db); + $tmpmember = new Adherent($this->db); $tmpmember->fetch($object->oldcopy->id); if ($tmpmember->del_to_abo() < 0) { $this->errors = $tmpmember->errors; From 3fd0af7987b64de3833e3f520dd05642303a5d1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 14:27:33 +0100 Subject: [PATCH 132/315] Fix #29085 --- htdocs/compta/facture/list.php | 2 -- htdocs/fourn/facture/list.php | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 645737d1f7f..10ec76785c1 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -144,8 +144,6 @@ $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $sear $search_categ_cus = GETPOSTINT("search_categ_cus"); $search_product_category = GETPOSTINT('search_product_category'); $search_fac_rec_source_title = GETPOST("search_fac_rec_source_title", 'alpha'); -$search_btn = GETPOST('button_search', 'alpha'); -$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_late = GETPOST('search_late'); if ($search_late == 'late') { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 3817273ab6f..190a837fca0 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -68,8 +68,8 @@ $search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha"); $search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha"); $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_refsupplier = GETPOST('search_refsupplier', 'alpha'); -$search_type = GETPOSTINT('search_type'); -$search_subtype = GETPOSTINT('search_subtype'); +$search_type = GETPOST('search_type', 'intcomma'); +$search_subtype = GETPOST('search_subtype', 'intcomma'); $search_project = GETPOST('search_project', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); $search_company_alias = GETPOST('search_company_alias', 'alpha'); @@ -85,8 +85,8 @@ $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'a $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $search_status = GETPOST('search_status', 'intcomma'); // Can be '' or a numeric -$search_paymentmode = GETPOSTINT('search_paymentmode'); -$search_paymentcond = GETPOSTINT('search_paymentcond'); +$search_paymentmode = GETPOST('search_paymentmode', 'intcomma'); +$search_paymentcond = GETPOST('search_paymentcond', 'intcomma'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST("search_state"); From 94391c9b616dc345759e1169aa831212321cc183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 28 Mar 2024 14:32:17 +0100 Subject: [PATCH 133/315] add MailSentBy for potential future use --- dev/translation/ignore_translation_keys.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/translation/ignore_translation_keys.lst b/dev/translation/ignore_translation_keys.lst index 21b8f270427..4e58e862175 100644 --- a/dev/translation/ignore_translation_keys.lst +++ b/dev/translation/ignore_translation_keys.lst @@ -45,6 +45,7 @@ IPP_Device InstallChoiceRecommanded IsInPackage MailNoChangePossible +MailSentBy ModuleBuilderDesc2 ModulesMarketPlaceDesc MoveField From 797118403734928207b9b8636e06b26d13aadb20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 14:34:58 +0100 Subject: [PATCH 134/315] Remove not used translation --- htdocs/langs/en_US/main.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 73ebf6faa54..d6dfb8bc74b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -705,7 +705,6 @@ CloseWindow=Close window Response=Response Priority=Priority SendByMail=Send by email -MailSentBy=Email sent by MailSentByTo=Email sent by %s to %s NotSent=Not sent TextUsedInTheMessageBody=Email body From c92de3117fc6062755f14f7f3f3e3b79b2f630f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 14:38:43 +0100 Subject: [PATCH 135/315] Fix var not found --- .../interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index 17312704156..e964f1e9176 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -118,7 +118,7 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) { if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) { // If email has changed or if list has changed we delete mailman subscription for old email // $object->oldcopy may be a stdClass and not original object depending on copy type, so we realod a new object to run the del_to_abo() - $tmpmember = new Adherent($db); + $tmpmember = new Adherent($this->db); $tmpmember->fetch($object->oldcopy->id); if ($tmpmember->del_to_abo() < 0) { $this->errors = $tmpmember->errors; From 96711686da15126d49568d17ae35557980891e9d Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 28 Mar 2024 14:56:10 +0100 Subject: [PATCH 136/315] Fix select member type id width --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0bc4aeed29c..7d9b73d444b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1016,7 +1016,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $listetype = $adht->liste_array(1); print img_picto('', $adht->picto, 'class="pictofixedwidth"'); if (count($listetype)) { - print $form->selectarray("typeid", $listetype, (GETPOST('typeid', 'int') ? GETPOST('typeid', 'int') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray("typeid", $listetype, (GETPOST('typeid', 'int') ? GETPOST('typeid', 'int') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', 'minwidth150', 1); } else { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } From 2a1eb6494cc3bfc36b1df19def211684c9de93cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 14:57:01 +0100 Subject: [PATCH 137/315] Fix phpcs --- .../product/stock/stocktransfer/class/stocktransfer.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index 451a9bbd75f..72c158b1242 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -50,7 +50,7 @@ class StockTransfer extends CommonObject * @var string Name of subtable line */ public $table_element_line = 'stocktransfer_stocktransferline'; - + /** * @var int Does this object support multicompany module ? * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table From 337be78694f0be3ca95fb0fb038b1d75d91a5c7d Mon Sep 17 00:00:00 2001 From: terhoy <70033666+terhoy@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:13:38 +0100 Subject: [PATCH 138/315] Update mails_templates.php Fix for issue #2910, Sort by email template fails with DB_ERROR_NOSUCHFIELD Unknown column 'type_templatetype_template' in 'order clause' --- htdocs/admin/mails_templates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 546427463da..dcec50a89a4 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1041,7 +1041,7 @@ foreach ($fieldlist as $field => $value) { } $sortfieldtouse = ($sortable ? $fieldlist[$field] : ''); if ($sortfieldtouse == 'type_template') { - $sortfieldtouse .= 'type_template,lang,position,label'; + $sortfieldtouse .= ',lang,position,label'; } print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $css.' '); } From 3a3ccc253b8eceddee84f158b2c262a4033b9402 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 16:18:50 +0100 Subject: [PATCH 139/315] Fix GET use --- htdocs/accountancy/admin/categories_list.php | 5 ----- htdocs/accountancy/admin/journals_list.php | 6 ------ htdocs/compta/paiement/card.php | 4 ++-- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9f7ec9be7cf..4ca98e4c730 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -299,11 +299,6 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($db->error(), null, 'errors'); } } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition -} - -if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index d64c8de7693..aec9df77614 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -272,14 +272,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($db->error(), null, 'errors'); } } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } -//if (GETPOST('actioncancel', 'alpha')) -//{ -// $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition -//} - if ($action == 'confirm_delete' && $confirm == 'yes') { // delete if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 63a47618cd7..382e9875d88 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -288,8 +288,8 @@ if ($action == 'delete') { // Confirmation of payment validation if ($action == 'valide') { - $facid = $_GET['facid']; - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2); + $facid = GETPOSTINT('facid'); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.((int) $facid), $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2); } $linkback = ''.$langs->trans("BackToList").''; From 39d2f3376f6b3eff592d97fdf30e409ef52bae85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 16:25:32 +0100 Subject: [PATCH 140/315] Limit the information visible --- build/exe/doliwamp/index.php.install | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/build/exe/doliwamp/index.php.install b/build/exe/doliwamp/index.php.install index 0df983529f4..2ccd4a5ff66 100644 --- a/build/exe/doliwamp/index.php.install +++ b/build/exe/doliwamp/index.php.install @@ -3,7 +3,7 @@ // Page created by Shepard [Fabian Pijcke] // Arno Esterhuizen // and Romain Bourdon -// +// // icones by Mark James // // Modified from WampServer project by Laurent Destailleur (NLTechno) @@ -260,7 +260,7 @@ if (isset($_GET['askhelp'])) // Show PHPInfo if (isset($_GET['phpinfo'])) { - phpinfo(); + phpinfo(INFO_GENERAL|INFO_MODULES); exit(); } @@ -274,27 +274,27 @@ if (isset($_GET['img'])) header("Content-type: image/png"); echo base64_decode($pngFolder); exit(); - + case 'pngFolderGo' : header("Content-type: image/png"); echo base64_decode($pngFolderGo); exit(); - + case 'pngLogo' : header("Content-type: image/png"); echo base64_decode($pngLogo); exit(); - + case 'pngPlugin' : header("Content-type: image/png"); echo base64_decode($pngPlugin); exit(); - + case 'pngWrench' : header("Content-type: image/png"); echo base64_decode($pngWrench); exit(); - + case 'favicon' : header("Content-type: image/x-icon"); echo base64_decode($favicon); @@ -324,7 +324,7 @@ foreach ($loaded_extensions as $extension) { $phpExtContents .= "
  • ${extension}
  • "; } - + // Read alias directory $listoffile=array(); $aliasarray=array(); @@ -337,10 +337,10 @@ if (is_dir($aliasDir)) { } } sort($listoffiles); - + foreach($listoffiles as $file) { if (is_file($aliasDir.$file) && preg_match('/\.conf/',$file)) - { + { $msg = ''; $aliasContents.='
    '; elseif (preg_match('/phpmyadmin/i',$file)) $aliasContents .= $file.''; else $aliasContents .= $file.''; - + $aliasarray[]=$file; } } @@ -358,13 +358,13 @@ if (is_dir($aliasDir)) { } if (!isset($aliasContents)) $aliasContents = ''; - + // Read projects in www dir $listoffiles=array(); $handle=opendir("."); if (is_resource($handle)) { - while ($file = readdir($handle)) + while ($file = readdir($handle)) { $listoffiles[]=$file; } @@ -372,14 +372,14 @@ if (is_resource($handle)) { } foreach($listoffiles as $file) { - if (is_dir($file) && !in_array($file,$projectsListIgnore) && !in_array($file,$aliasarray)) - { + if (is_dir($file) && !in_array($file,$projectsListIgnore) && !in_array($file,$aliasarray)) + { $projectContents .= ''; } } @@ -509,7 +509,7 @@ a:hover { font-size: 0.85em; } - + @@ -533,7 +533,7 @@ a:hover {
    ${apacheVersion}  
    {$langues[$langue]['versp']}
    ${phpVersion}  
    -
    {$langues[$langue]['phpExt']}
    +
    {$langues[$langue]['phpExt']}
      ${phpExtContents} @@ -554,8 +554,8 @@ a:hover {
    - ${aliasContents} - ${projectContents} + ${aliasContents} + ${projectContents}
      '; @@ -350,7 +350,7 @@ if (is_dir($aliasDir)) { if (preg_match('/dolibarr/i',$file)) $aliasContents .= $file.'
    http://localhost'.($apachePort != 80?':'.$apachePort:'').'/'.$file.'/http://ipofyourserver'.($apachePort != 80?':'.$apachePort:'').'/'.$file.'/
    http://localhost'.($apachePort != 80?':'.$apachePort:'').'/'.$file.'/'.$langues[$langue]['NotAvailable'].'
    '.$langues[$langue]['NotAvailable'].'
    '.$langues[$langue]['txtNoAlias'].'
    http://localhost'.($apachePort != 80?':'.$apachePort:'').'/'.$file.'/)'.''.$langues[$langue]['NotAvailable'].'
    {$langues[$langue]['FromInternet']}

    {$langues[$langue]['titrePage']}

    From 3e8c3edd6d9db9c6bdb863dc5c25a161c5c922c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 17:10:22 +0100 Subject: [PATCH 141/315] Clean code from _GET --- htdocs/admin/company.php | 8 +++---- htdocs/admin/ldap_contacts.php | 2 +- htdocs/admin/ldap_members.php | 2 +- htdocs/admin/ldap_members_types.php | 2 +- htdocs/admin/mailman.php | 4 ++-- htdocs/admin/modules.php | 2 +- htdocs/admin/spip.php | 4 ++-- htdocs/admin/system/phpinfo.php | 2 +- htdocs/admin/tools/dolibarr_import.php | 4 +--- htdocs/admin/website.php | 5 ---- htdocs/api/class/api_access.class.php | 2 +- htdocs/bookmarks/bookmarks.lib.php | 4 ++-- htdocs/categories/photos.php | 14 +++++------ htdocs/comm/action/document.php | 1 - htdocs/comm/mailing/card.php | 4 ++-- htdocs/commande/list.php | 4 ++-- htdocs/compta/accounting-files.php | 2 +- htdocs/compta/bank/card.php | 6 ++--- htdocs/compta/bank/treso.php | 2 +- .../compta/cashcontrol/cashcontrol_card.php | 2 +- htdocs/compta/cashcontrol/report.php | 2 +- htdocs/compta/clients.php | 6 ++--- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/localtax/card.php | 2 +- htdocs/compta/payment_sc/card.php | 2 +- htdocs/compta/payment_vat/card.php | 23 ------------------- htdocs/contact/list.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/contrat/document.php | 1 - htdocs/core/actions_linkedfiles.inc.php | 2 +- htdocs/core/ajax/fetchKnowledgeRecord.php | 4 ++-- htdocs/core/ajax/flowjs-server.php | 2 -- htdocs/core/ajax/locationincoterms.php | 3 +-- htdocs/core/ajax/onlineSign.php | 2 +- htdocs/core/ajax/selectobject.php | 1 - htdocs/core/ajax/ziptown.php | 1 - htdocs/core/class/openid.class.php | 16 ++++++------- htdocs/core/datepicker.php | 3 +-- .../connectors/php/connector.lib.php | 8 +------ .../connectors/php/connector.php | 7 ++---- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/login/functions_openid.php | 8 +++---- .../barcode/doc/phpbarcode.modules.php | 1 - .../barcode/doc/tcpdfbarcode.modules.php | 2 -- htdocs/core/photos_resize.php | 4 ++-- htdocs/core/tpl/filemanager.tpl.php | 2 +- htdocs/ecm/dir_card.php | 2 +- htdocs/ecm/index_auto.php | 4 ++-- htdocs/expedition/card.php | 2 +- 49 files changed, 72 insertions(+), 124 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 1a5a68fc085..5861d5121cb 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -281,8 +281,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) } if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs - if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) { - $isimage = image_format_supported($_GET["file"]); + if (file_exists($conf->mycompany->dir_output.'/logos/'.GETPOST("file"))) { + $isimage = image_format_supported(GETPOST("file")); // Create thumbs of logo if ($isimage > 0) { @@ -297,7 +297,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thu //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb. Used on logon for example - $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality); + $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthsmall, $maxheightsmall, '_small', $quality); if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) { $imgThumbSmall = $reg[1]; // Save only basename dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); @@ -306,7 +306,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thu } // Create mini thumbs. Used on menu or for setup page for example - $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality); + $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthmini, $maxheightmini, '_mini', $quality); if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) { $imgThumbMini = $reg[1]; // Save only basename dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index f97b35f1968..1aa2eeb55c4 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -293,7 +293,7 @@ show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); if (function_exists("ldap_connect")) { - if ($_GET["action"] == 'test') { + if ($action == 'test') { // Create object $object = new Contact($db); $object->initAsSpecimen(); diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index fda38fe67b8..2b32bed8391 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -444,7 +444,7 @@ if (getDolGlobalString('LDAP_MEMBER_ACTIVE')) { } if (function_exists("ldap_connect")) { - if ($_GET["action"] == 'testmember') { + if ($action == 'testmember') { // Create object $object = new Adherent($db); $object->initAsSpecimen(); diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 277cac9a8fc..dc827857f8d 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -200,7 +200,7 @@ if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDA } if (function_exists("ldap_connect")) { - if ($_GET["action"] == 'testmembertype') { + if ($action == 'testmembertype') { // Create object $object = new AdherentType($db); $object->initAsSpecimen(); diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 4c014640d00..8d5adcbf6f1 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -80,7 +80,7 @@ if ($action == 'update' || $action == 'add') { // Action to activate a submodule of the 'adherent' module if ($action == 'set') { - $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + $result = dolibarr_set_const($db, GETPOST("name", 'aZ09'), GETPOST("value"), '', 0, '', $conf->entity); if ($result < 0) { dol_print_error($db); } @@ -88,7 +88,7 @@ if ($action == 'set') { // Action to deactivate a submodule of the 'adherent' module if ($action == 'unset') { - $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); + $result = dolibarr_del_const($db, GETPOST("name", 'aZ09'), $conf->entity); if ($result < 0) { dol_print_error($db); } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index a551752ad06..0a4dd01d914 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -30,7 +30,7 @@ * \brief Page to activate/disable all modules */ -if (!defined('CSRFCHECK_WITH_TOKEN') && (empty($_GET['action']) || $_GET['action'] != 'reset')) { // We force security except to disable modules so we can do it if problem of a module +if (!defined('CSRFCHECK_WITH_TOKEN') && (empty($_GET['action']) || $_GET['action'] != 'reset')) { // We force security except to disable modules so we can do it if a problem occurs on a module define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index f9009151061..c5d919c6de3 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -82,7 +82,7 @@ if ($action == 'update' || $action == 'add') { // Action activation d'un sous module du module adherent if ($action == 'set') { - $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + $result = dolibarr_set_const($db, GETPOST("name", 'aZ09'), GETPOST("value"), '', 0, '', $conf->entity); if ($result < 0) { dol_print_error($db); } @@ -90,7 +90,7 @@ if ($action == 'set') { // Action deactivation d'un sous module du module adherent if ($action == 'unset') { - $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); + $result = dolibarr_del_const($db, GETPOST("name", 'aZ09'), $conf->entity); if ($result < 0) { dol_print_error($db); } diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 3c410fbe0d4..3d154fe2b8a 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -115,7 +115,7 @@ if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) { print ''; print 'GET and POST support'; -if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here +if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here. This is a specific test. print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); print ' ('.$langs->trans("Recheck").')'; } else { diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 7fd6a95a4c9..8313c5f1c0f 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -166,7 +166,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print '
    '; print ajax_autoselect('restorecommand'); - if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { + if (!GETPOST("showpass") && $dolibarr_main_db_pass) { print '
    '.$langs->trans("UnHidePassword").''; } //else print '
    '.$langs->trans("HidePassword").''; @@ -205,8 +205,6 @@ if (in_array($type, array('mysql', 'mysqli'))) { print '
    '; print '
    '; print ajax_autoselect('restorecommand'); - //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
    '.$langs->trans("UnHidePassword").''; - //else print '
    '.$langs->trans("HidePassword").''; print '
    '; print '
    '; diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index b517491d14c..82d578686fc 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -300,11 +300,6 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $db->rollback(); } } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition -} - -if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 8e4bdb0db9f..61f664d8562 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -106,7 +106,7 @@ class DolibarrApiAccess implements iAuthenticate // api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx $api_key = ''; - if (isset($_GET['api_key'])) { // For backward compatibility + if (isset($_GET['api_key'])) { // For backward compatibility. Keep $_GET here. // TODO Add option to disable use of api key on url. Return errors if used. $api_key = $_GET['api_key']; } diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 711e4fa5a49..edd6988d38b 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -29,7 +29,7 @@ */ function printDropdownBookmarksList() { - global $conf, $user, $db, $langs, $sortfield, $sortorder; + global $user, $db, $langs, $sortfield, $sortorder; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -40,7 +40,7 @@ function printDropdownBookmarksList() $url = $_SERVER["PHP_SELF"]; $url_param = array(); if (!empty($_SERVER["QUERY_STRING"])) { - if (is_array($_GET)) { + if (is_array($_GET)) { // Parse the original GET URL. So we must keep $_GET here. foreach ($_GET as $key => $val) { if (is_array($val)) { foreach ($val as $tmpsubval) { diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index bd40d078fa1..f44052afbd8 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -95,12 +95,12 @@ if (empty($reshook)) { } } - if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->hasRight('categorie', 'creer')) { - $object->delete_photo($upload_dir."/".$_GET["file"]); + if ($action == 'confirm_delete' && GETPOST("file") && $confirm == 'yes' && $user->hasRight('categorie', 'creer')) { + $object->delete_photo($upload_dir."/".GETPOST("file")); } - if ($action == 'addthumb' && $_GET["file"]) { - $object->addThumbs($upload_dir."/".$_GET["file"]); + if ($action == 'addthumb' && GETPOST("file")) { + $object->addThumbs($upload_dir."/".GETPOST("file")); } } @@ -133,10 +133,10 @@ if ($object->id) { dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.$type, 0, '', '', 1); /* - * Confirmation de la suppression de photo - */ + * Confirmation deletion of picture + */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type).'&file='.urlencode(GETPOST("file")), $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); } print '
    '; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index ccda6ff5be1..fb8c8dd2417 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -52,7 +52,6 @@ if ($user->socid) { $socid = $user->socid; } if ($user->socid > 0) { - unset($_GET["action"]); $action = ''; } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 8a876bda03c..a3d84f89d64 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -972,7 +972,7 @@ if ($action == 'create') { if (getDolGlobalString('MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS')) { setEventMessages($langs->trans("MailSendSetupIs3", getDolGlobalString('MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS')), null, 'warnings'); } - $_GET["action"] = ''; + $action = ''; } elseif (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < 0) { if (getDolGlobalString('MAILING_LIMIT_WARNING_PHPMAIL') && $sendingmode == 'mail') { setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); @@ -987,7 +987,7 @@ if ($action == 'create') { if ($conf->file->mailing_limit_sendbyweb != '-1') { // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed to increase it. setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } - $_GET["action"] = ''; + $action = ''; } else { if (getDolGlobalString('MAILING_LIMIT_WARNING_PHPMAIL') && $sendingmode == 'mail') { setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index ac6213ed0b7..6b32e42a81e 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -682,8 +682,8 @@ if (empty($reshook)) { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; + $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ? + $_GET["originid"] = $_POST["originid"]; // Keep GET and POST here ? if (!empty($errors)) { setEventMessages(null, $errors, 'errors'); } else { diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 36b12bf6b36..e20eeed6436 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -27,7 +27,7 @@ * \brief Page to show portoflio and files of a thirdparty and download it */ -if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file +if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file. Keep $_GET and $_POST here if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 25b52d8fc1c..60f34320312 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -69,7 +69,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $hookmanager->initHooks(array('bankcard', 'globalcard')); // Security check -$id = GETPOSTINT("id") ? GETPOSTINT("id") : GETPOSTINT('ref'); +$id = GETPOSTINT("id") ? GETPOSTINT("id") : GETPOST('ref'); $fieldid = GETPOSTINT("id") ? 'rowid' : 'ref'; if (GETPOSTINT("id") || GETPOST("ref")) { @@ -319,11 +319,11 @@ if (empty($reshook)) { $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"] = GETPOSTINT("id"); // Force chargement page en mode visu + $id = GETPOSTINT("id"); // Force load of this page } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; // Force chargement page edition + $action = 'edit'; // Force load of page in edit mode } } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index ef683b833af..c43d85e1f60 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -85,7 +85,7 @@ if (GETPOST("account") || GETPOST("ref")) { } if (GETPOST("ref")) { $result = $object->fetch(0, GETPOST("ref")); - $_GET["account"] = $object->id; + $id = $object->id; } $title = $object->ref.' - '.$langs->trans("PlannedTransactions"); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 74cce92938d..b16ed740d01 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -66,7 +66,7 @@ if (!$sortorder) { $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; if ($contextpage == 'takepos') { - $_GET['optioncss'] = 'print'; + $optioncss = 'print'; } $arrayofpaymentmode = array('cash' => 'Cash', 'cheque' => 'Cheque', 'card' => 'CreditCard'); diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c59c5be8b34..18c41bc47f9 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -37,7 +37,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); // Disable browser notification } -$_GET['optioncss'] = "print"; +$optioncss = "print"; // Load Dolibarr environment require '../../main.inc.php'; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index c7963e95090..aa361fa1010 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -151,16 +151,16 @@ if ($resql) { print ''; print ''; - print ''; + print ''; print ' '; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a847b7ca292..56fc5218598 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2080,8 +2080,8 @@ if (empty($reshook)) { } else { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; + $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ? + $_GET["originid"] = $_POST["originid"]; // Keep GET and POST here ? setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') { diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index e302bcc2ee1..9b3ec6e2544 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -87,7 +87,7 @@ if ($action == 'add' && !$cancel) { } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"] = "create"; + $action = "create"; } } diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 9288421622e..482c9594d29 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -245,7 +245,7 @@ print '
    '; /* if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') + if ($user->socid == 0 && $object->statut == 0 && $action == '') { if ($user->hasRight('facture', 'paiement')){ print ''.$langs->trans('Valid').''; diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 4d9d34abc75..df69e995365 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -150,17 +150,6 @@ if ($action == 'delete') { print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } -/* - * Validation confirmation of payment - */ -/* -if ($action == 'valide') -{ - $facid = $_GET['facid']; - print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); - -} -*/ $linkback = ''.$langs->trans("BackToList").''; @@ -283,18 +272,6 @@ if ($resql) { */ print '
    '; -/* -if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) -{ - if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') - { - if ($user->hasRight('facture', 'paiement')) { - print ''.$langs->trans('Valid').''; - } - } -} -*/ - if ($action == '') { if ($user->hasRight('tax', 'charges', 'supprimer')) { if (!$disable_delete) { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c7058f80d68..43b6294a5b5 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -57,7 +57,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'co $mode = GETPOST('mode', 'alpha'); if ($contextpage == 'poslist') { - $_GET['optioncss'] = 'print'; + $optioncss = 'print'; } // Security check diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 97ce15937e2..47f524aba73 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -707,7 +707,7 @@ if (empty($reshook)) { if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) { setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); $action = 'editline'; - $_GET['rowid'] = GETPOST('elrowid'); + $_GET['rowid'] = GETPOST('elrowid'); // Keep $_GET here. Used by GETPOST('rowid') later $error++; } diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 6f19a21fa69..28a1c9455e2 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -47,7 +47,6 @@ $ref = GETPOST('ref', 'alpha'); // Security check if ($user->socid > 0) { - unset($_GET["action"]); $action = ''; $socid = $user->socid; } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index ed0d8b4e8ec..7820754cae3 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -119,7 +119,7 @@ if (GETPOST('sendit', 'alpha') && getDolGlobalString('MAIN_UPLOAD_DOC') && !empt // Delete file/link if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissiontoadd)) { - $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); if (GETPOST('section', 'alpha')) { // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; diff --git a/htdocs/core/ajax/fetchKnowledgeRecord.php b/htdocs/core/ajax/fetchKnowledgeRecord.php index 6e4f1ddd953..9445546b849 100644 --- a/htdocs/core/ajax/fetchKnowledgeRecord.php +++ b/htdocs/core/ajax/fetchKnowledgeRecord.php @@ -35,8 +35,8 @@ if (!defined('NOREQUIRESOC')) { if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } -// If there is no need to load and show top and left menu -if (!empty($_GET['public'])) { // GETPOST() is not yet defined so we use $_GET +// If we need access without being logged. +if (!empty($_GET['public'])) { // Keep $_GET here. GETPOST() is not yet defined so we use $_GET if (!defined("NOLOGIN")) { define("NOLOGIN", '1'); } diff --git a/htdocs/core/ajax/flowjs-server.php b/htdocs/core/ajax/flowjs-server.php index dfe8b4ad2ce..12fd91e12a0 100644 --- a/htdocs/core/ajax/flowjs-server.php +++ b/htdocs/core/ajax/flowjs-server.php @@ -74,8 +74,6 @@ if (!empty($conf->$module->dir_temp)) { top_httphead(); -dol_syslog(implode(',', $_GET)); - $result = false; if (!empty($upload_dir)) { diff --git a/htdocs/core/ajax/locationincoterms.php b/htdocs/core/ajax/locationincoterms.php index 5d541238466..6be6645c1b4 100644 --- a/htdocs/core/ajax/locationincoterms.php +++ b/htdocs/core/ajax/locationincoterms.php @@ -63,8 +63,7 @@ top_httphead(); //print ''."\n"; -dol_syslog('location_incoterms call with MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY='.(!getDolGlobalString('MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY') ? '' : $conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY)); -//var_dump($_GET); +dol_syslog('location_incoterms call with MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY='.getDolGlobalString('MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY', '')); // Generation of list of zip-town if (GETPOST('location_incoterms')) { diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index de58f75c303..b861d7c3796 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -48,7 +48,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); // Keep $_GET and $_POST here. GETPOST not yet defined. if (is_numeric($entity)) { define("DOLENTITY", $entity); } diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php index aa702375d3e..f7c4726ac80 100644 --- a/htdocs/core/ajax/selectobject.php +++ b/htdocs/core/ajax/selectobject.php @@ -149,7 +149,6 @@ $form = new Form($db); top_httphead($outjson ? 'application/json' : 'text/html'); //print ''."\n"; -//print_r($_GET); $arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1, 0, '', $filter); diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 21ccd582933..6ecfbb387f9 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -57,7 +57,6 @@ if (!getDolGlobalString('MAIN_USE_ZIPTOWN_DICTIONNARY')) { //print ''."\n"; dol_syslog('ziptown call with MAIN_USE_ZIPTOWN_DICTIONNARY='.getDolGlobalString('MAIN_USE_ZIPTOWN_DICTIONNARY')); -//var_dump($_GET); // Generation of list of zip-town if (GETPOST('zipcode') || GETPOST('town')) { diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 142fb711ecb..b1b4b3c97a7 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -432,26 +432,24 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * ValidateWithServer + * validateWithServer * * @return boolean */ - public function ValidateWithServer() + public function validateWithServer() { - // phpcs:enable $params = array( - 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), - 'openid.signed' => urlencode($_GET['openid_signed']), - 'openid.sig' => urlencode($_GET['openid_sig']) + 'openid.assoc_handle' => urlencode(GETPOST('openid_assoc_handle')), + 'openid.signed' => urlencode(GETPOST('openid_signed')), + 'openid.sig' => urlencode(GETPOST('openid_sig')) ); // Send only required parameters to confirm validity - $arr_signed = explode(",", str_replace('sreg.', 'sreg_', $_GET['openid_signed'])); + $arr_signed = explode(",", str_replace('sreg.', 'sreg_', GETPOST('openid_signed'))); $num = count($arr_signed); for ($i = 0; $i < $num; $i++) { $s = str_replace('sreg_', 'sreg.', $arr_signed[$i]); - $c = $_GET['openid_'.$arr_signed[$i]]; + $c = GETPOST('openid_'.$arr_signed[$i]); // if ($c != ""){ $params['openid.'.$s] = urlencode($c); // } diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 788289de2e3..61352fa2b2c 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -108,10 +108,10 @@ print ''."\n"; $qualified = true; +// TODO Replace with GETPOST if (!isset($_GET["sd"])) { $_GET["sd"] = "00000000"; } - if (!isset($_GET["m"]) || !isset($_GET["y"])) { $qualified = false; } @@ -126,7 +126,6 @@ if (isset($_GET["m"]) && isset($_GET["y"])) { // If parameters provided, we show calendar if ($qualified) { - //print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit; displayBox(GETPOSTINT("sd"), GETPOSTINT("m"), GETPOSTINT("y")); } else { dol_print_error(null, 'ErrorBadParameters'); diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index afdfa2b6ffd..e95af16f784 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -243,14 +243,11 @@ function GetFoldersAndFiles($resourceType, $currentFolder) */ function CreateFolder($resourceType, $currentFolder) { - if (!isset($_GET)) { - global $_GET; - } $sErrorNumber = '0'; $sErrorMsg = ''; if (isset($_GET['NewFolderName'])) { - $sNewFolderName = $_GET['NewFolderName']; + $sNewFolderName = GETPOST('NewFolderName'); $sNewFolderName = SanitizeFolderName($sNewFolderName); if (strpos($sNewFolderName, '..') !== false) { @@ -741,9 +738,6 @@ function IsAllowedCommand($sCommand) */ function GetCurrentFolder() { - if (!isset($_GET)) { - global $_GET; - } $sCurrentFolder = isset($_GET['CurrentFolder']) ? GETPOST('CurrentFolder', '', 1) : '/'; // Check the current folder syntax (must begin and start with a slash). diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.php b/htdocs/core/filemanagerdol/connectors/php/connector.php index 080e331b048..49b55f30b09 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.php @@ -40,16 +40,13 @@ DoResponse(); */ function DoResponse() { - if (!isset($_GET)) { - global $_GET; - } if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) { return; } // Get the main request information. - $sCommand = $_GET['Command']; - $sResourceType = $_GET['Type']; + $sCommand = GETPOST('Command'); + $sResourceType = GETPOST('Type'); $sCurrentFolder = GetCurrentFolder(); // Check if it is an allowed command diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d58ee238e15..ff84b50796d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2036,7 +2036,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output // If html log tag enabled and url parameter log defined, we show output log on HTML comments - if (getDolGlobalString('MAIN_ENABLE_LOG_INLINE_HTML') && !empty($_GET["log"])) { + if (getDolGlobalString('MAIN_ENABLE_LOG_INLINE_HTML') && GETPOSTINT("log")) { print "\n\n\n"; diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index 7495cb3fe03..e11a1b55b81 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -39,7 +39,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/openid.class.php'; */ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) { - global $db, $conf, $langs; + global $db, $conf; dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest); @@ -62,11 +62,11 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) return false; } return false; - } elseif ($_GET['openid_mode'] == 'id_res') { + } elseif (GETPOST('openid_mode') == 'id_res') { // Perform HTTP Request to OpenID server to validate key $openid = new SimpleOpenID(); $openid->SetIdentity(GETPOST('openid_identity')); - $openid_validation_result = $openid->ValidateWithServer(); + $openid_validation_result = $openid->validateWithServer(); if ($openid_validation_result === true) { // OK HERE KEY IS VALID @@ -93,7 +93,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) //echo "INVALID AUTHORIZATION"; return false; } - } elseif ($_GET['openid_mode'] == 'cancel') { + } elseif (GETPOST('openid_mode') == 'cancel') { // User Canceled your Request //echo "USER CANCELED REQUEST"; return false; diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index 706b6213a7c..231b55f37b7 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -135,7 +135,6 @@ class modPhpbarcode extends ModeleBarCode */ public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { - global $_GET, $_SERVER; global $conf; global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index dcb69e6642a..b3d62ca0901 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -106,8 +106,6 @@ class modTcpdfbarcode extends ModeleBarCode */ public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { - global $_GET; - $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); if (empty($tcpdfEncoding)) { return -1; diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 70c8da59d2a..416dd3959e0 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -404,7 +404,7 @@ if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") } } else { setEventMessages($result, null, 'errors'); - $_GET['file'] = $_POST["file"]; + //$_GET['file'] = $_POST["file"]; $action = ''; } } @@ -467,7 +467,7 @@ if ($action == 'confirm_crop') { } } else { setEventMessages($result, null, 'errors'); - $_GET['file'] = $_POST["file"]; + //$_GET['file'] = $_POST["file"]; $action = ''; } } diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 9c09f821638..7acbddd72fa 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -62,7 +62,7 @@ if (!isset($section)) { // Confirm remove file (for non javascript users) if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax)) { // TODO Add website, pageid, filemanager if defined - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); } // Start container of all panels diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 7444815a11e..46fe08c71fb 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -139,7 +139,7 @@ if (GETPOST("sendit") && getDolGlobalString('MAIN_UPLOAD_DOC') && $permissiontou // Remove file if ($action == 'confirm_deletefile' && $confirm == 'yes' && $permissiontoupload) { $langs->load("other"); - $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here $ret = dol_delete_file($file); if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 7a0338a0126..a46470e9d7a 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -137,7 +137,7 @@ if ($action == 'confirm_deletefile') { $relativepath = ''; } $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); - $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). + $file = $upload_dir."/".GETPOST('urlfile'); $ret = dol_delete_file($file); if ($ret) { @@ -417,7 +417,7 @@ print dol_get_fiche_head($head, 'index_auto', '', -1, ''); // Confirm remove file (for non javascript users) if ($action == 'deletefile' && empty($conf->use_javascript_ajax)) { - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); } // Start container of all panels diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 61b6fb26300..16a71da87da 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -444,7 +444,7 @@ if (empty($reshook)) { exit; } else { $db->rollback(); - $_GET["commande_id"] = GETPOSTINT('commande_id'); + //$_GET["commande_id"] = GETPOSTINT('commande_id'); $action = 'create'; } } elseif ($action == 'create_delivery' && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'creer')) { From d1cb440916068102d65a9ab71c8659f54a68a55b Mon Sep 17 00:00:00 2001 From: Jonathan lescaut Date: Thu, 28 Mar 2024 17:56:39 +0100 Subject: [PATCH 142/315] massAction unlocate commercial --- htdocs/core/actions_massactions.inc.php | 42 +++++++++++++++++++++++++ htdocs/core/tpl/massactions_pre.tpl.php | 10 ++++++ htdocs/langs/en_US/companies.lang | 1 + htdocs/societe/list.php | 3 +- 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2fca6e22a33..410cdf5aa21 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1544,6 +1544,48 @@ if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommerci } } +if (!$error && ($massaction == 'Unassigncommercial' || ($action == 'Unassigncommercial' && $confirm == 'yes')) && $permissiontoadd) { + $db->begin(); + + $objecttmp = new $objectclass($db); + $nbok = 0; + + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + if (in_array($objecttmp->element, array('societe'))) { + $TCommercial = GETPOST("commercial", "alpha"); + if (is_array($TCommercial)){ + foreach ($TCommercial as $commercial){ + $result = $objecttmp->del_commercial($user, $commercial); + } + } + } + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("CommercialsAffected", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("CommercialAffected"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } +} // Approve for leave only if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { $db->begin(); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index cf57e63b9c5..d27b1f9c0f5 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -394,6 +394,16 @@ if ($massaction == 'presetcommercial') { 'value' => $form->multiselectarray('commercial', $userlist, null, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1)); print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAllocateCommercial"), $langs->trans("ConfirmAllocateCommercialQuestion", count($toselect)), "affectcommercial", $formquestion, 1, 0, 200, 500, 1); } +if ($massaction == 'unsetcommercial') { + $formquestion = array(); + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); + $formquestion[] = array('type' => 'other', + 'name' => 'Unassigncommercial', + 'label' => $form->editfieldkey('UnallocateCommercial', 'commercial_id', '', $object, 0), + 'value' => $form->multiselectarray('commercial', $userlist, null, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1)); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUnallocateCommercial"), $langs->trans("ConfirmUnallocateCommercialQuestion", count($toselect)), "Unassigncommercial", $formquestion, 1, 0, 200, 500, 1); +} + if ($massaction == 'preapproveleave') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, 'yes', 0, 200, 500, 1); } diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index d1ca72b826a..81febdac01c 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -384,6 +384,7 @@ JuridicalStatus200=Independent DeleteFile=Delete file ConfirmDeleteFile=Are you sure you want to delete this file %s? AllocateCommercial=Assigned to sales representative +UnallocateCommercial = De-assigning a sales representative Organization=Organization FiscalYearInformation=Fiscal Year FiscalMonthStart=Starting month of the fiscal year diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 73fdb35e5af..fbdc79e3244 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -203,7 +203,6 @@ if ($type == 'f') { $search_type = '4'; } } - // Initialize technical objects to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); $extrafields = new ExtraFields($db); @@ -1106,7 +1105,9 @@ if ($user->hasRight("societe", "creer")) { } if ($user->hasRight("societe", "creer")) { $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); + $arrayofmassactions['unsetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("UnallocateCommercial"); } + if ($user->hasRight('societe', 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } From 22dec27423e72b40f031f061f850af25f55aeb72 Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:40:24 +0100 Subject: [PATCH 143/315] BugFix Autocomplete under dialog box --- htdocs/theme/eldy/global.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 667e22a6974..df5ee6c6aa6 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5124,6 +5124,9 @@ div#card-errors { .ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-draggable { z-index: 1005 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ } +.ui-menu.ui-widget.ui-widget-content.ui-autocomplete.ui-front { + z-index:1006 !important; /* To always be over the dialog box */ +} .ui-dialog.ui-widget.ui-widget-content { border: 1px solid #e0e0e0; border-radius: 6px; From b8d75178b11aa50a9d9f1ac00e94091ebbaa993e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 18:45:28 +0100 Subject: [PATCH 144/315] fix phpstan --- htdocs/user/hierarchy.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index e7a12510b73..64d9436545b 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -4,7 +4,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * * 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 @@ -124,11 +124,11 @@ if (!is_array($user_arbo) && $user_arbo < 0) { $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); foreach ($fulltree as $key => $val) { $userstatic->id = $val['id']; - $userstatic->ref = $val['id']; + $userstatic->ref = (string) $val['id']; $userstatic->login = $val['login']; $userstatic->firstname = $val['firstname']; $userstatic->lastname = $val['lastname']; - $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; $userstatic->email = $val['email']; $userstatic->gender = $val['gender']; $userstatic->socid = $val['fk_soc']; From 9a5c7525abdb4059ae00332003127c4c11229e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 18:54:46 +0100 Subject: [PATCH 145/315] fix phpstan --- htdocs/core/class/commonobjectline.class.php | 55 +++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 92a84376184..3b0a1b11321 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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,8 +79,15 @@ abstract class CommonObjectLine extends CommonObject public $multilangs; - public $product_type; // type in line - public $fk_product; // product id in line (when line is linked to a product) + /** + * @var int type in line + */ + public $product_type; + + /** + * @var int product id in line (when line is linked to a product or service) + */ + public $fk_product; /** * Description of the line @@ -95,17 +103,48 @@ abstract class CommonObjectLine extends CommonObject */ public $description; - public $product; // To store full product object after a fetch_product() on a line - public $product_ref; // ref in product table - public $product_label; // label in product table - public $product_barcode; // barcode in product table - public $product_desc; // desc in product table - public $fk_product_type; // type in product table + /** + * @var Product Object product to store full product object after a fetch_product() on a line + */ + public $product; + + /** + * @var string reference in product table + */ + public $product_ref; + + /** + * @var string label in product table + */ + public $product_label; + + /** + * @var string barcode in product table + */ + public $product_barcode; + + /** + * @var string description in product table + */ + public $product_desc; + + /** + * @var int type in product table + */ + public $fk_product_type; public $qty; public $duree; public $remise_percent; + + /** + * @var int info_bits + */ public $info_bits; + + /** + * @var int special code + */ public $special_code; public $subprice; public $tva_tx; From a223e04c7f340db7adafcb8e898b6f7bcde07ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 19:01:32 +0100 Subject: [PATCH 146/315] fix phpstan --- htdocs/fourn/class/fournisseur.facture.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2f2f97137f8..e9c44d23b78 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2062,7 +2062,7 @@ class FactureFournisseur extends CommonInvoice * @param int $origin_id id origin document * @param double $pu_devise Amount in currency * @param string $ref_supplier Supplier ref - * @param string $special_code Special code + * @param int $special_code Special code * @param int $fk_parent_line Parent line id * @param int $fk_remise_except Id discount used * @return int >0 if OK, <0 if KO @@ -2253,7 +2253,7 @@ class FactureFournisseur extends CommonInvoice $supplierinvoiceline->fk_remise_except = $fk_remise_except; - $supplierinvoiceline->special_code = (string) $special_code; + $supplierinvoiceline->special_code = (int) $special_code; $supplierinvoiceline->fk_parent_line = $fk_parent_line; $supplierinvoiceline->origin = $this->origin; $supplierinvoiceline->origin_id = $origin_id; @@ -3917,6 +3917,9 @@ class SupplierInvoiceLine extends CommonObjectLine */ public $fk_parent_line; + /** + * @var int special code + */ public $special_code; /** From cf41d3633bfe710304aa8e17999cfd36ebd29fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 20:08:44 +0100 Subject: [PATCH 147/315] fix phpstan --- htdocs/fourn/class/fournisseur.commande.class.php | 6 +++++- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b018cda619d..25ff3185583 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3774,6 +3774,10 @@ class CommandeFournisseurLigne extends CommonOrderLine public $fk_facture; public $rang = 0; + + /** + * @var int special code + */ public $special_code = 0; /** @@ -4014,7 +4018,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= "null,"; } $sql .= "'".$this->db->escape($this->product_type)."',"; - $sql .= "'".$this->db->escape($this->special_code)."',"; + $sql .= (int) $this->special_code . ","; $sql .= "'".$this->db->escape($this->rang)."',"; $sql .= "'".$this->db->escape($this->qty)."', "; $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e9c44d23b78..9fa472cc406 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2067,14 +2067,14 @@ class FactureFournisseur extends CommonInvoice * @param int $fk_remise_except Id discount used * @return int >0 if OK, <0 if KO */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = 0, $date_end = 0, $fk_code_ventilation = 0, $info_bits = 0, $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = 0, $array_options = [], $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = 0, $date_end = 0, $fk_code_ventilation = 0, $info_bits = 0, $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = 0, $array_options = [], $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = 0, $fk_parent_line = 0, $fk_remise_except = 0) { global $langs, $mysoc; dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$fk_code_ventilation,$info_bits,$price_base_type,$type,$fk_unit,fk_remise_except=$fk_remise_except", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - if ($this->statut == self::STATUS_DRAFT) { + if ($this->status == self::STATUS_DRAFT) { // Clean parameters if (empty($remise_percent)) { $remise_percent = 0; From 5b1af9586420fa569dfa775b8f64ffa73b745c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 20:16:32 +0100 Subject: [PATCH 148/315] fix phpstan --- htdocs/comm/propal/class/propal.class.php | 9 ++++++--- htdocs/compta/facture/class/facture-rec.class.php | 4 ++++ htdocs/core/class/commoninvoice.class.php | 13 +++++++------ htdocs/core/class/commonorder.class.php | 4 ++++ htdocs/fichinter/class/fichinterrec.class.php | 4 ++++ .../fourn/class/fournisseur.facture-rec.class.php | 4 ++++ .../class/supplier_proposal.class.php | 3 +++ 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 35e268885b8..499ab5088af 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -4012,10 +4012,13 @@ class PropaleLigne extends CommonObjectLine public $marge_tx; public $marque_tx; + /** + * 1: frais de port + * 2: ecotaxe + * 3: option line (when qty = 0) + * @var int special code + */ public $special_code; // Tag for special lines (exclusive tags) - // 1: frais de port - // 2: ecotaxe - // 3: option line (when qty = 0) public $info_bits = 0; // Some other info: // Bit 0: 0 si TVA normal - 1 if TVA NPR diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1ed0209e4b0..3fefc83c6b7 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -129,6 +129,10 @@ class FactureRec extends CommonInvoice public $unit_frequency; public $rang; + + /** + * @var int special code + */ public $special_code; public $usenewprice = 0; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 769de345f4e..d78747713bc 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -2002,18 +2002,19 @@ abstract class CommonInvoiceLine extends CommonObjectLine /** * List of special options to define line: - * '1': shipment cost lines - * '2': ecotaxe - * '3': ?? - * 'idorcodeofmodule': a meaning for the module - * @var string + * 1: shipment cost lines + * 2: ecotaxe + * 3: ?? + * id of module: a meaning for the module + * @var int */ - public $special_code = ''; + public $special_code = 0; /** * @deprecated Use user_creation_id */ public $fk_user_author; + /** * @deprecated Use user_modification_id */ diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index dc5de2b9863..39ce201cb6f 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -218,6 +219,9 @@ abstract class CommonOrderLine extends CommonObjectLine */ public $info_bits = 0; + /** + * @var int special code + */ public $special_code = 0; public $fk_multicurrency; diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 3f34bdf65fb..cf3751fa06e 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -110,6 +110,10 @@ class FichinterRec extends Fichinter * int rank */ public $rang; + + /** + * @var int special code + */ public $special_code; public $usenewprice = 0; diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 2fbdc41be62..cf5f79a3ed7 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -2027,6 +2027,10 @@ class FactureFournisseurLigneRec extends CommonObjectLine public $date_start; public $date_end; public $info_bits; + + /** + * @var int special code + */ public $special_code; public $rang; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 9ba40dbacf0..8eecbf1a417 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2879,6 +2879,9 @@ class SupplierProposalLine extends CommonObjectLine public $marge_tx; public $marque_tx; + /** + * @var int special code + */ public $special_code; // Tag for special lines (exclusive tags) // 1: frais de port // 2: ecotaxe From e73f79ca96a3a8d384e994a0a3b91f988befe3c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 20:19:28 +0100 Subject: [PATCH 149/315] Qual: Remove unnecessary use of $_GET --- htdocs/document.php | 3 +- htdocs/exports/export.php | 12 +++--- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/commande/list.php | 4 +- htdocs/fourn/facture/card.php | 12 +++--- htdocs/fourn/facture/document.php | 2 +- htdocs/fourn/facture/list.php | 1 - htdocs/imports/emptyexample.php | 8 ++-- htdocs/imports/import.php | 39 +------------------ htdocs/index.php | 2 +- htdocs/install/step4.php | 6 +-- htdocs/install/upgrade.php | 4 +- htdocs/product/ajax/products.php | 3 +- htdocs/product/fournisseurs.php | 4 +- htdocs/product/stock/massstockmove.php | 2 +- htdocs/product/stock/product.php | 2 +- htdocs/product/stock/valo.php | 20 +++++----- htdocs/projet/tasks/contact.php | 2 +- htdocs/projet/tasks/time.php | 4 +- htdocs/public/agenda/agendaexport.php | 10 ++--- .../eventorganization/subscriptionok.php | 2 +- htdocs/public/members/new.php | 1 + htdocs/public/members/public_card.php | 2 +- htdocs/public/members/public_list.php | 2 +- htdocs/public/partnership/new.php | 2 +- htdocs/public/payment/newpayment.php | 1 + htdocs/public/payment/paymentko.php | 2 +- htdocs/public/payment/paymentok.php | 2 +- htdocs/public/project/index.php | 1 + htdocs/public/project/new.php | 1 + htdocs/public/project/suggestbooth.php | 2 +- htdocs/public/project/suggestconference.php | 2 +- htdocs/public/project/viewandvote.php | 1 + htdocs/public/stripe/ipn.php | 7 ++-- htdocs/public/test/test_arrays.php | 2 +- htdocs/public/ticket/create_ticket.php | 1 + htdocs/public/ticket/index.php | 1 + htdocs/public/ticket/list.php | 1 + htdocs/public/ticket/view.php | 1 + htdocs/reception/card.php | 2 +- htdocs/reception/list.php | 4 +- htdocs/societe/ajax/company.php | 1 - .../canvas/actions_card_common.class.php | 10 ++--- htdocs/takepos/admin/other.php | 8 ++-- htdocs/takepos/admin/printqr.php | 2 +- htdocs/takepos/admin/setup.php | 2 +- htdocs/takepos/admin/terminal.php | 2 +- htdocs/ticket/list.php | 4 +- htdocs/viewimage.php | 7 ++-- .../controllers/document.controller.class.php | 2 +- htdocs/website/samples/wrapper.php | 10 ++--- 51 files changed, 103 insertions(+), 127 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index 17f0d61676e..2090fe89838 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -61,6 +61,7 @@ if (isset($_GET["hashp"]) && !defined("NOLOGIN")) { } } // Some value of modulepart can be used to get resources that are public so no login are required. +// Keep $_GET here, GETPOST is not available yet if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { if (!defined("NOLOGIN")) { define("NOLOGIN", 1); @@ -98,7 +99,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $encoding = ''; $action = GETPOST('action', 'aZ09'); -$original_file = GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). +$original_file = GETPOST('file', 'alphanohtml'); $hashp = GETPOST('hashp', 'aZ09'); $modulepart = GETPOST('modulepart', 'alpha'); $urlsource = GETPOST('urlsource', 'alpha'); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 638dbd6b700..90439554f76 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -219,11 +219,11 @@ if ($action == 'selectfield') { // Selection of field at step 2 } } if ($action == 'unselectfield') { - if ($_GET["field"] == 'all') { + if (GETPOST("field") == 'all') { $array_selected = array(); $_SESSION["export_selected_fields"] = $array_selected; } else { - unset($array_selected[$_GET["field"]]); + unset($array_selected[GETPOST("field")]); // Renumber fields of array_selected (from 1 to nb_elements) asort($array_selected); $i = 0; @@ -238,7 +238,7 @@ if ($action == 'unselectfield') { } if ($action == 'downfield' || $action == 'upfield') { - $pos = $array_selected[$_GET["field"]]; + $pos = $array_selected[GETPOST("field")]; if ($action == 'downfield') { $newpos = $pos + 1; } @@ -253,9 +253,9 @@ if ($action == 'downfield' || $action == 'upfield') { break; } } - //print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)"); + //print("Switch pos=$pos (code=".GETPOST("field").") and newpos=$newpos (code=$newcode)"); if ($newcode) { // Si newcode trouve (protection contre resoumission de page) - $array_selected[$_GET["field"]] = $newpos; + $array_selected[GETPOST("field")] = $newpos; $array_selected[$newcode] = $pos; $_SESSION["export_selected_fields"] = $array_selected; } @@ -290,7 +290,7 @@ if ($action == 'builddoc') { // Delete file if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes') { - $file = $upload_dir."/".GETPOST('file'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir."/".GETPOST('file'); $ret = dol_delete_file($file); if ($ret) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 0f716bcecc1..9b1c7d93518 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1420,7 +1420,7 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; } else { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode((string) ($id))); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index e7a23eab863..b7ecdb9b8ee 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -730,8 +730,8 @@ if (empty($reshook)) { } else { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; + $_GET["origin"] = $_POST["origin"]; // Keep this ? + $_GET["originid"] = $_POST["originid"]; // Keep this ? setEventMessages("Error", null, 'errors'); $error++; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ead7de640e9..e5e347d37c4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -801,7 +801,7 @@ if (empty($reshook)) { if (empty($dateinvoice)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; $error++; } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (!getDolGlobalString('INVOICE_MAX_FUTURE_DELAY') ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; @@ -867,7 +867,7 @@ if (empty($reshook)) { if (empty($dateinvoice)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; $error++; } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (!getDolGlobalString('INVOICE_MAX_FUTURE_DELAY') ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; @@ -878,7 +878,7 @@ if (empty($reshook)) { if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplierBill')), null, 'errors'); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; $error++; } @@ -1035,7 +1035,7 @@ if (empty($reshook)) { if (empty($dateinvoice)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; $error++; } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (!getDolGlobalString('INVOICE_MAX_FUTURE_DELAY') ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { $error++; @@ -1046,7 +1046,7 @@ if (empty($reshook)) { if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplierBill')), null, 'errors'); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; $error++; } @@ -1405,7 +1405,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; - $_GET['socid'] = $_POST['socid']; + //$_GET['socid'] = $_POST['socid']; } else { $db->commit(); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index ea6fe3335d0..584f9c20303 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -157,7 +157,7 @@ if ($object->id > 0) { * Confirm delete file */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); } print ''; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 190a837fca0..9a57e3ddf0d 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -137,7 +137,6 @@ $socid = GETPOSTINT('socid'); // Security check if ($user->socid > 0) { $action = ''; - $_GET["action"] = ''; $socid = $user->socid; } diff --git a/htdocs/imports/emptyexample.php b/htdocs/imports/emptyexample.php index 6d8b3f2d647..e1ca1e55bbd 100644 --- a/htdocs/imports/emptyexample.php +++ b/htdocs/imports/emptyexample.php @@ -80,13 +80,13 @@ $fieldstarget = $objimport->array_import_fields[0]; $valuestarget = $objimport->array_import_examplevalues[0]; $attachment = true; -if (isset($_GET["attachment"])) { - $attachment = $_GET["attachment"]; +if (GETPOSTISSET("attachment")) { + $attachment = GETPOST("attachment"); } //$attachment = false; $contenttype = dol_mimetype($format); -if (isset($_GET["contenttype"])) { - $contenttype = $_GET["contenttype"]; +if (GETPOSTISSET("contenttype")) { + $contenttype = GETPOST("contenttype"); } //$contenttype='text/plain'; $outputencoding = 'UTF-8'; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index ba8128b7316..57071a1b17d 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -184,41 +184,6 @@ if (empty($array_match_file_to_database)) { * Actions */ -/* -if ($action=='downfield' || $action=='upfield') -{ - $pos=$array_match_file_to_database[$_GET["field"]]; - if ($action=='downfield') $newpos=$pos+1; - if ($action=='upfield') $newpos=$pos-1; - // Recherche code avec qui switcher - $newcode=""; - foreach($array_match_file_to_database as $code=>$value) - { - if ($value == $newpos) - { - $newcode=$code; - break; - } - } - //print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)"); - if ($newcode) // Si newcode trouve (protection contre resoumission de page) - { - $array_match_file_to_database[$_GET["field"]]=$newpos; - $array_match_file_to_database[$newcode]=$pos; - $_SESSION["dol_array_match_file_to_database"]=$serialized_array_match_file_to_database; - } -} -*/ -// if ($action == 'builddoc') { -// // Build import file -// $result = $objimport->build_file($user, GETPOST('model', 'alpha'), $datatoimport, $array_match_file_to_database); -// if ($result < 0) { -// setEventMessages($objimport->error, $objimport->errors, 'errors'); -// } else { -// setEventMessages($langs->trans("FileSuccessfullyBuilt"), null, 'mesgs'); -// } -// } - if ($action == 'deleteprof') { if (GETPOSTINT("id")) { $objimport->fetch(GETPOSTINT("id")); @@ -286,7 +251,7 @@ if ($step == 3 && $datatoimport) { $param .= '&endatlinenb='.urlencode($endatlinenb); } - $file = $conf->import->dir_temp.'/'.GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $conf->import->dir_temp.'/'.GETPOST('urlfile'); $ret = dol_delete_file($file); if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); @@ -2085,7 +2050,7 @@ if ($step == 6 && $datatoimport) { $obj->import_close_file(); } - $nboflines = (!empty($_GET["nboflines"]) ? $_GET["nboflines"] : dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport)); + $nboflines = GETPOST("nboflines", dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport)); $param = '&format='.$format.'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport).'&nboflines='.urlencode($nboflines); if ($excludefirstline) { diff --git a/htdocs/index.php b/htdocs/index.php index 6ab07c74f12..1402d4de8e5 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -32,7 +32,7 @@ require 'main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // If not defined, we select menu "home" -$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ? GETPOST('mainmenu', 'aZ09') : 'home'; +$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ? GETPOST('mainmenu', 'aZ09') : 'home'; // Keep this ? $action = GETPOST('action', 'aZ09'); $hookmanager->initHooks(array('index')); diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index 7d7d3133e53..c93f4c815e1 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -87,13 +87,13 @@ if ($db->ok) { print ''; print '
    '; - if (isset($_GET["error"]) && $_GET["error"] == 1) { + if (GETPOSTINT("error") == 1) { print '
    '; print '
    '.$langs->trans("PasswordsMismatch").'
    '; $error = 0; // We show button } - if (isset($_GET["error"]) && $_GET["error"] == 2) { + if (GETPOSTINT("error") == 2) { print '
    '; print '
    '; print $langs->trans("PleaseTypePassword"); @@ -101,7 +101,7 @@ if ($db->ok) { $error = 0; // We show button } - if (isset($_GET["error"]) && $_GET["error"] == 3) { + if (GETPOSTINT("error") == 3) { print '
    '; print '
    '.$langs->trans("PleaseTypeALogin").'
    '; $error = 0; // We show button diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index d80205028c8..67b22abf07d 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -418,9 +418,9 @@ if (!$ok && isset($argv[1])) { } dolibarr_install_syslog("Exit ".$ret); -dolibarr_install_syslog("--- upgrade: end ".((int) (!$ok && empty($_GET["ignoreerrors"])))." dirmodule=".$dirmodule); +dolibarr_install_syslog("--- upgrade: end ".((int) (!$ok && !GETPOST("ignoreerrors")))." dirmodule=".$dirmodule); -$nonext = (!$ok && empty($_GET["ignoreerrors"])) ? 2 : 0; +$nonext = (!$ok && !GETPOST("ignoreerrors")) ? 2 : 0; if ($dirmodule) { $nonext = 1; } diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 3f26a9ad2b4..711af593d2e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -35,7 +35,7 @@ if (!defined('NOREQUIREHTML')) { if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } -if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) { +if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) { // Keep $_GET here, GETPOST is not yet defined define('NOREQUIREHTML', '1'); } @@ -67,7 +67,6 @@ restrictedArea($user, 'produit|service|commande|propal|facture', 0, 'product&pro */ // print ''."\n"; -// print_r($_GET); if ($action == 'fetch' && !empty($id)) { // action='fetch' is used to get product information on a product. So when action='fetch', id must be the product id. diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 646c8fc7fef..3de815d6f73 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -66,8 +66,8 @@ $extrafields = new ExtraFields($db); // If socid provided by ajax company selector if (GETPOSTINT('search_fourn_id')) { - $_GET['id_fourn'] = GETPOSTINT('search_fourn_id'); - $_POST['id_fourn'] = GETPOSTINT('search_fourn_id'); + $_GET['id_fourn'] = GETPOSTINT('search_fourn_id'); // Keep set to $_GET an $_POST. Used later. + $_POST['id_fourn'] = GETPOSTINT('search_fourn_id'); // Keep set to $_GET an $_POST. Used later. } // Security check diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 88b51aa78ab..8963040b36e 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -519,7 +519,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { $param .= '&endatlinenb='.urlencode($endatlinenb); } - $file = $conf->stock->dir_temp.'/'.GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $conf->stock->dir_temp.'/'.GETPOST('urlfile'); $ret = dol_delete_file($file); if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 39f35080378..0677267100c 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -70,7 +70,7 @@ $ref = GETPOST('ref', 'alpha'); $stocklimit = (float) GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); -$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; +$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; $d_eatby = dol_mktime(0, 0, 0, GETPOSTINT('eatbymonth'), GETPOSTINT('eatbyday'), GETPOSTINT('eatbyyear')); $d_sellby = dol_mktime(0, 0, 0, GETPOSTINT('sellbymonth'), GETPOSTINT('sellbyday'), GETPOSTINT('sellbyyear')); $pdluoid = GETPOSTINT('pdluoid'); diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 259f139a177..36ab59584ae 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -30,30 +30,32 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page $langs->load("stocks"); -// Security check -$result = restrictedArea($user, 'stock'); - $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $limit * $page; + if (!$sortfield) { $sortfield = "e.ref"; } if (!$sortorder) { $sortorder = "ASC"; } -$page = $_GET["page"]; -if ($page < 0) { - $page = 0; -} -$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; -$offset = $limit * $page; $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +// Security check +$result = restrictedArea($user, 'stock'); + /* * View diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 015c70a72e2..723a31e9122 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -426,7 +426,7 @@ if ($id > 0 || !empty($ref)) { print ''; $thirdpartyofproject = $projectstatic->getListContactId('thirdparty'); - $selectedCompany = isset($_GET["newcompany"]) ? $_GET["newcompany"] : $projectstatic->socid; + $selectedCompany = GETPOSISSET("newcompany") ? GETPOST("newcompany") : $projectstatic->socid; $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, '&withproject='.$withproject); print ''; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index d36587339a1..b2bbf98186f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -2338,7 +2338,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Product if (!empty($arrayfields['t.fk_product']['checked'])) { print ''; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { + if ($action == 'editline' && GETPOSTINT('lineid') == $task_time->rowid) { print img_picto('', 'service'); print $form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500', 0, '', null, 1); } elseif (!empty($task_time->fk_product)) { @@ -2395,7 +2395,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($task_time->invoice_id) { $result = $tmpinvoice->fetch($task_time->invoice_id); if ($result > 0) { - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { + if ($action == 'editline' && GETPOSTINT('lineid') == $task_time->rowid) { print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id, 'invoiceid', 'invoicelineid', 'maxwidth500', array('p.rowid' => $projectstatic->id)); } else { print $tmpinvoice->getNomUrl(1); diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index 484b3bab1d3..b4d6f415b33 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -178,7 +178,7 @@ if ($reshook < 0) { llxFooterVierge(); } elseif (empty($reshook)) { // Check exportkey - if (empty($_GET["exportkey"]) || getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY') != $_GET["exportkey"]) { + if (!GETPOST("exportkey") || getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY') != GETPOST("exportkey")) { $user->getrights(); top_httphead(); @@ -328,13 +328,13 @@ if ($format == 'rss') { $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays); if ($result >= 0) { $attachment = false; - if (isset($_GET["attachment"])) { - $attachment = $_GET["attachment"]; + if (GETPOSTISSET("attachment")) { + $attachment = GETPOST("attachment"); } //$attachment = false; $contenttype = 'application/rss+xml'; - if (isset($_GET["contenttype"])) { - $contenttype = $_GET["contenttype"]; + if (GETPOSTISSET("contenttype")) { + $contenttype = GETPOST("contenttype"); } //$contenttype='text/plain'; $outputencoding = 'UTF-8'; diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index e432909c0a2..fab5a6e70bf 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -42,7 +42,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b3c02132dde..6f4525031ea 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -53,6 +53,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index ead24c23bd1..2862d9004b0 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -40,7 +40,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index 1401d22b82a..1f2fcf4bac7 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -39,7 +39,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 4b1a1420fae..9a1db3d88cc 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -45,7 +45,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index ad4b0d1bdd8..79623a7d393 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -51,6 +51,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)))); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 4e1b3825ca2..dcb89788136 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -40,7 +40,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and this test must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 4a6c958ba9a..87c49592c93 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -44,7 +44,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index 60c91239254..c7a33c386df 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -36,6 +36,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)))); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 284a6a5e93b..0b41a315145 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -44,6 +44,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 005122121be..d5abd931716 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -38,7 +38,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index c92edcb7973..063c0508d20 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -38,7 +38,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/project/viewandvote.php b/htdocs/public/project/viewandvote.php index 90b56165cc2..7c088fa7249 100644 --- a/htdocs/public/project/viewandvote.php +++ b/htdocs/public/project/viewandvote.php @@ -36,6 +36,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)))); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index ed8dac838c5..0285d408390 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -31,6 +31,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); @@ -58,8 +59,8 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; // You can find your endpoint's secret in your webhook settings -if (isset($_GET['connect'])) { - if (isset($_GET['test'])) { +if (GETPOSTISSET('connect')) { + if (GETPOSTISSET('test')) { $endpoint_secret = getDolGlobalString('STRIPE_TEST_WEBHOOK_CONNECT_KEY'); $service = 'StripeTest'; $servicestatus = 0; @@ -69,7 +70,7 @@ if (isset($_GET['connect'])) { $servicestatus = 1; } } else { - if (isset($_GET['test'])) { + if (GETPOSTISSET('test')) { $endpoint_secret = getDolGlobalString('STRIPE_TEST_WEBHOOK_KEY'); $service = 'StripeTest'; $servicestatus = 0; diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 838052dac5b..e14597b9eee 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -53,7 +53,7 @@ if (empty($usedolheader)) { - " /> + " /> diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 1a482944772..f7c408c07ed 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -45,6 +45,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 64a70c95c0d..860a82ec0ff 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -40,6 +40,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 1842af349b4..aa6687371a9 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -38,6 +38,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index a966813ca05..60a3c512969 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -40,6 +40,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 2d1da5c8336..1fceafab74e 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -450,7 +450,7 @@ if (empty($reshook)) { exit; } else { $db->rollback(); - $_GET["commande_id"] = GETPOSTINT('commande_id'); + //$_GET["commande_id"] = GETPOSTINT('commande_id'); $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $permissiontovalidate) { diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 5721ff01232..73020077bc5 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -571,8 +571,8 @@ if (empty($reshook)) { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; + $_GET["origin"] = $_POST["origin"]; // Keep this ? + $_GET["originid"] = $_POST["originid"]; // Keep this ? setEventMessages($object->error, $errors, 'errors'); $error++; } diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 7505ea18ece..e0c5e1fe42d 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -74,7 +74,6 @@ restrictedArea($user, 'societe', $object->id, '&societe'); top_httphead('application/json'); //print ''."\n"; -//print_r($_GET); if (!empty($action) && $action == 'fetch' && !empty($id)) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 5125bfdc389..42820ce8369 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -93,19 +93,19 @@ abstract class ActionsCardCommon $this->assign_post($action); } - if ($_GET["type"] == 'f') { + if (GETPOST("type") == 'f') { $this->object->fournisseur = 1; } - if ($_GET["type"] == 'c') { + if (GETPOST("type") == 'c') { $this->object->client = 1; } - if ($_GET["type"] == 'p') { + if (GETPOST("type") == 'p') { $this->object->client = 2; } - if ($_GET["type"] == 'cp') { + if (GETPOST("type") == 'cp') { $this->object->client = 3; } - if ($_REQUEST["private"] == 1) { + if (GETPOST("private") == 1) { $this->object->particulier = 1; } diff --git a/htdocs/takepos/admin/other.php b/htdocs/takepos/admin/other.php index 5e2af98b966..c8540ecb5e0 100644 --- a/htdocs/takepos/admin/other.php +++ b/htdocs/takepos/admin/other.php @@ -29,10 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; // If socid provided by ajax company selector -if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { - $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); - $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); - $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); +if (GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha')) { + $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); // Keep this ? + $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); // Keep this ? + $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); // Keep this ? } // Security check diff --git a/htdocs/takepos/admin/printqr.php b/htdocs/takepos/admin/printqr.php index 8d6a27faff0..4e130ff18cc 100644 --- a/htdocs/takepos/admin/printqr.php +++ b/htdocs/takepos/admin/printqr.php @@ -33,7 +33,7 @@ $langs->load("cashdesk"); $id = GETPOSTINT('id'); -$_GET['optioncss'] = "print"; +//$_GET['optioncss'] = "print"; print '
    '; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 453d0115797..c94a0cc1db9 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // If socid provided by ajax company selector -if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { +if (GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha')) { $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index f417c2a9988..b6b2b2857b7 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $terminal = GETPOSTINT('terminal'); // If socid provided by ajax company selector -if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) { +if (GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha')) { $_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha'); $_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha'); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index b6433a6eac8..b042a7908c4 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -107,9 +107,9 @@ if (!$sortorder) { $sortorder = "DESC"; } -if (GETPOST('search_fk_status', 'alpha') == 'non_closed') { +/*if (GETPOST('search_fk_status', 'alpha') == 'non_closed') { $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility -} +}*/ // Initialize array of search criteria $search_all = (GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall')); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index c5b582cc254..6daec2a1569 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -55,6 +55,7 @@ if (!defined('NOREQUIREAJAX')) { // Some value of modulepart can be used to get resources that are public so no login are required. // Note that only directory logo is free to access without login. $needlogin = 1; +// Keep $_GET here, GETPOST is not available yet if (isset($_GET["modulepart"])) { // Some value of modulepart can be used to get resources that are public so no login are required. @@ -129,9 +130,9 @@ require 'main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $action = GETPOST('action', 'aZ09'); -$original_file = GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). -$hashp = GETPOST('hashp', 'aZ09', 1); // Must be read only by GET -$modulepart = GETPOST('modulepart', 'alpha', 1); // Must be read only by GET +$original_file = GETPOST('file', 'alphanohtml'); +$hashp = GETPOST('hashp', 'aZ09', 1); +$modulepart = GETPOST('modulepart', 'alpha', 1); $urlsource = GETPOST('urlsource', 'alpha'); $entity = (GETPOSTINT('entity') ? GETPOSTINT('entity') : $conf->entity); diff --git a/htdocs/webportal/controllers/document.controller.class.php b/htdocs/webportal/controllers/document.controller.class.php index d09b4dc5fb2..cf457c63ecf 100644 --- a/htdocs/webportal/controllers/document.controller.class.php +++ b/htdocs/webportal/controllers/document.controller.class.php @@ -110,7 +110,7 @@ class DocumentController extends Controller if (preg_match('/\.(html|htm)$/i', $original_file)) { $attachment = false; } - if (isset($_GET["attachment"])) { + if (GETPOSTISSET("attachment")) { $attachment = GETPOST("attachment", 'alpha') ? true : false; } if (getDolGlobalString('MAIN_DISABLE_FORCE_SAVEAS')) { diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index e6f78442c1e..4e39f2bbbaa 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -62,7 +62,7 @@ $attachment = true; if (preg_match('/\.(html|htm)$/i', $original_file)) { $attachment = false; } -if (isset($_GET["attachment"])) { +if (GETPOSTISSET("attachment")) { $attachment = (GETPOST("attachment", 'alphanohtml') ? true : false); } if (getDolGlobalString('MAIN_DISABLE_FORCE_SAVEAS_WEBSITE')) { @@ -183,13 +183,13 @@ if ($rss) { if ($result >= 0) { $attachment = false; - if (isset($_GET["attachment"])) { - $attachment = $_GET["attachment"]; + if (GETPOSTISSET("attachment")) { + $attachment = GETPOST("attachment"); } //$attachment = false; $contenttype = 'application/rss+xml'; - if (isset($_GET["contenttype"])) { - $contenttype = $_GET["contenttype"]; + if (GETPOSTISSET("contenttype")) { + $contenttype = GETPOST("contenttype"); } //$contenttype='text/plain'; $outputencoding = 'UTF-8'; From afcf1710f9df915441bcc561d6ae8de4d3fa7398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 20:20:41 +0100 Subject: [PATCH 150/315] fix phpstan --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 72a9829eebe..710cf3edaab 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -6554,7 +6554,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql .= ", product_type=".$this->product_type; $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; - $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; + $sql .= ", special_code=" . (int) $this->special_code; if (empty($this->skip_update_total)) { $sql .= ", total_ht=".price2num($this->total_ht); $sql .= ", total_tva=".price2num($this->total_tva); From 3535623ffcd92089a70d732c1848dc687d7ad200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 20:27:56 +0100 Subject: [PATCH 151/315] fix phpstan --- htdocs/projet/tasks/contact.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 723a31e9122..cc4143d03f6 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2024 Frédéric France * * 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 @@ -426,7 +427,7 @@ if ($id > 0 || !empty($ref)) { print ''; $thirdpartyofproject = $projectstatic->getListContactId('thirdparty'); - $selectedCompany = GETPOSISSET("newcompany") ? GETPOST("newcompany") : $projectstatic->socid; + $selectedCompany = GETPOSTISSET("newcompany") ? GETPOST("newcompany") : $projectstatic->socid; $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, '&withproject='.$withproject); print ''; From 7a7b1953eda027a6ececb0612930915e90b62834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 28 Mar 2024 20:34:33 +0100 Subject: [PATCH 152/315] fix phpstan --- htdocs/accountancy/expensereport/lines.php | 3 ++- htdocs/accountancy/expensereport/list.php | 3 ++- htdocs/accountancy/journal/bankjournal.php | 5 ++--- htdocs/comm/propal/list.php | 6 +++--- htdocs/commande/list.php | 4 ++-- htdocs/commande/list_det.php | 6 +++--- htdocs/compta/facture/list.php | 3 +-- htdocs/compta/sociales/payments.php | 3 ++- htdocs/contrat/list.php | 3 ++- htdocs/core/ajax/ajaxdirtree.php | 6 +++--- htdocs/core/boxes/box_birthdays.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formother.class.php | 2 +- htdocs/expensereport/index.php | 4 ++-- htdocs/fourn/commande/index.php | 3 ++- htdocs/fourn/commande/list.php | 4 ++-- htdocs/hrm/index.php | 4 ++-- htdocs/projet/list.php | 5 +++-- htdocs/projet/tasks/contact.php | 2 +- htdocs/user/notify/card.php | 5 +++-- 20 files changed, 41 insertions(+), 36 deletions(-) diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index c23cb2f5e88..58cc1eb6100 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -4,6 +4,7 @@ * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2024 Frédéric France * * 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 @@ -383,7 +384,7 @@ if ($result) { $userstatic->id = $objp->userid; $userstatic->ref = $objp->label; $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; + $userstatic->status = $objp->statut; $userstatic->email = $objp->email; $userstatic->gender = $objp->gender; $userstatic->firstname = $objp->firstname; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 78565a1f06a..1257e0e8c93 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2024 Frédéric France * * 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 @@ -462,7 +463,7 @@ if ($result) { $userstatic->id = $objp->userid; $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; + $userstatic->status = $objp->statut; $userstatic->email = $objp->email; $userstatic->gender = $objp->gender; $userstatic->firstname = $objp->firstname; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index d716ad9f3a0..66c43e2eb7a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -8,7 +8,7 @@ * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2017-2023 Frédéric France + * Copyright (C) 2017-2024 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Eric Seigne * Copyright (C) 2021 Gauthier VERDOL @@ -393,7 +393,6 @@ if ($result) { $userstatic->email = $tabuser[$obj->rowid]['email']; $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; - $userstatic->statut = $tabuser[$obj->rowid]['status']; $userstatic->status = $tabuser[$obj->rowid]['status']; $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; if ($userstatic->id > 0) { @@ -478,7 +477,7 @@ if ($result) { $userstatic->email = $tmpsalary->user->email; $userstatic->firstname = $tmpsalary->user->firstname; $userstatic->lastname = $tmpsalary->user->lastname; - $userstatic->statut = $tmpsalary->user->status; + $userstatic->status = $tmpsalary->user->status; $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; if ($userstatic->id > 0) { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 117511e1f87..1769bafaaad 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -15,7 +15,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019-2021 Alexandre Spangaro * Copyright (C) 2021 Anthony Berton - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2024 Frédéric France * Copyright (C) 2022 Josep Lluís Amador * Copyright (C) 2024 MDW * @@ -2166,7 +2166,7 @@ while ($i < $imaxinloop) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; + $userstatic->status = $obj->user_statut; $userstatic->entity = $obj->user_entity; $userstatic->photo = $obj->photo; $userstatic->office_phone = $obj->office_phone; @@ -2207,7 +2207,7 @@ while ($i < $imaxinloop) { $userstatic->lastname = $val['lastname']; $userstatic->firstname = $val['firstname']; $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; $userstatic->login = $val['login']; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 6b32e42a81e..1ca44dac3c1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016-2023 Ferran Marcet @@ -2503,7 +2503,7 @@ while ($i < $imaxinloop) { $userstatic->lastname = $val['lastname']; $userstatic->firstname = $val['firstname']; $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; $userstatic->login = $val['login']; diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 0e8f09ed021..bd076d8cccc 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016-2021 Ferran Marcet @@ -1909,7 +1909,7 @@ if ($resql) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; + $userstatic->status = $obj->user_statut; $userstatic->entity = $obj->entity; $userstatic->photo = $obj->photo; $userstatic->office_phone = $obj->office_phone; @@ -1951,7 +1951,7 @@ if ($resql) { $userstatic->lastname = $val['lastname']; $userstatic->firstname = $val['firstname']; $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; $userstatic->login = $val['login']; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 10ec76785c1..a6da251aa7c 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -17,6 +17,7 @@ * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -2419,7 +2420,6 @@ if ($num > 0) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; // deprecated $userstatic->status = $obj->user_statut; $userstatic->entity = $obj->entity; $userstatic->photo = $obj->photo; @@ -2462,7 +2462,6 @@ if ($num > 0) { $userstatic->lastname = $val['lastname']; $userstatic->firstname = $val['firstname']; $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; // deprecated $userstatic->status = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index b97882242e3..fe85314f123 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -307,7 +308,7 @@ while ($i < min($num, $limit)) { $userstatic->admin = $obj->admin; $userstatic->login = $obj->login; $userstatic->email = $obj->email; - $userstatic->statut = $obj->statut; + $userstatic->status = $obj->statut; print $userstatic->getNomUrl(1); print "\n"; } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 43c7b8da85b..90d39b3846a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2019 Nicolas Zabouri * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -1255,7 +1256,7 @@ while ($i < $imaxinloop) { $userstatic->lastname = $val['lastname']; $userstatic->firstname = $val['firstname']; $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; $userstatic->login = $val['login']; diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 47e980cfd6c..4c8ea0fd144 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -308,7 +308,7 @@ if (empty($conf->use_javascript_ajax) || getDolGlobalString('MAIN_ECM_DISABLE_JS print ''; $userstatic->id = $val['fk_user_c']; $userstatic->lastname = $val['login_c']; - $userstatic->statut = $val['statut_c']; + $userstatic->status = $val['statut_c']; $htmltooltip = ''.$langs->trans("ECMSection").': '.$val['label'].'
    '; $htmltooltip = ''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
    '; $htmltooltip .= ''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).'
    '; @@ -482,7 +482,7 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, print ''; $userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0; $userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0; - $userstatic->statut = isset($val['statut_c']) ? $val['statut_c'] : 0; + $userstatic->status = isset($val['statut_c']) ? $val['statut_c'] : 0; $htmltooltip = ''.$langs->trans("ECMSection").': '.$val['label'].'
    '; $htmltooltip = ''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
    '; $htmltooltip .= ''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).'
    '; diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 050611acc00..ffb16d94071 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015 Frederic France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -119,7 +119,7 @@ class box_birthdays extends ModeleBoxes $userstatic->firstname = $data[$j]->firstname; $userstatic->lastname = $data[$j]->lastname; $userstatic->email = $data[$j]->email; - $userstatic->statut = $data[$j]->status; + $userstatic->status = $data[$j]->status; $dateb = $this->db->jdate($data[$j]->datea); $age = idate('Y', dol_now()) - idate('Y', $dateb); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 97082b64db2..a894a8b0525 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2137,7 +2137,7 @@ class Form $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->photo = $obj->photo; - $userstatic->statut = $obj->status; + $userstatic->status = $obj->status; $userstatic->entity = $obj->entity; $userstatic->admin = $obj->admin; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5b49aeb41ac..5832422d394 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -579,7 +579,7 @@ class FormOther $userstatic->lastname = $obj_usr->lastname; $userstatic->firstname = $obj_usr->firstname; $userstatic->photo = $obj_usr->photo; - $userstatic->statut = $obj_usr->status; + $userstatic->status = $obj_usr->status; $userstatic->entity = $obj_usr->entity; $userstatic->admin = $obj_usr->admin; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 016fbfee019..d5f37475f66 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2019 Frédéric FRANCE + * Copyright (C) 2019-2024 Frédéric France * * 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 @@ -243,7 +243,7 @@ if ($result) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->login = $obj->login; - $userstatic->statut = $obj->user_status; + $userstatic->status = $obj->user_status; $userstatic->photo = $obj->photo; print ''; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 0c96ebe718e..46fa4f15166 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Vinicius Nogueira * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2024 Frédéric France * * 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 @@ -263,7 +264,7 @@ if ($resql) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->email; - $userstatic->statut = $obj->statut; + $userstatic->status = $obj->statut; print $userstatic->getNomUrl(1); print ''; print "\n"; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index b7ecdb9b8ee..64df4a9dfa0 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2018-2022 Charlene Benke * Copyright (C) 2019 Nicolas Zabouri * Copyright (C) 2021-2023 Alexandre Spangaro @@ -1804,7 +1804,7 @@ if ($resql) { $userstatic->login = $obj->login; $userstatic->photo = $obj->photo; $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_status; + $userstatic->status = $obj->user_status; if (!empty($arrayfields['u.login']['checked'])) { print ''; if ($userstatic->id) { diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 0bf7d5c5ff6..37ca42598d7 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -4,7 +4,7 @@ * Copyright (C) 2012-2014 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2024 Frédéric France * * 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 @@ -320,7 +320,7 @@ if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'read')) { $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->email; $userstatic->login = $obj->login; - $userstatic->statut = $obj->user_status; + $userstatic->status = $obj->user_status; $userstatic->photo = $obj->photo; print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9b07083156d..fadb09ca3af 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -9,6 +9,7 @@ * Copyright (C) 2019 Juanjo Menent * Copyright (C) 2020 Tobias Sean * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -1631,7 +1632,7 @@ while ($i < $imaxinloop) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; + $userstatic->status = $obj->user_statut; $userstatic->entity = $obj->entity; $userstatic->photo = $obj->photo; $userstatic->office_phone = $obj->office_phone; @@ -1724,7 +1725,7 @@ while ($i < $imaxinloop) { $userstatic->lastname = $val['lastname']; $userstatic->firstname = $val['firstname']; $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; $userstatic->entity = $val['entity']; $userstatic->photo = $val['photo']; $userstatic->login = $val['login']; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index cc4143d03f6..77402f0e98c 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -502,7 +502,7 @@ if ($id > 0 || !empty($ref)) { $userstatic->photo = $tab[$i]['photo']; $userstatic->login = $tab[$i]['login']; $userstatic->email = $tab[$i]['email']; - $userstatic->statut = $tab[$i]['statuscontact']; + $userstatic->status = $tab[$i]['statuscontact']; print $userstatic->getNomUrl(-1); } diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index cec29d8c356..79da83cca39 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2016 Abbes Bahfir + * Copyright (C) 2024 Frédéric France * * 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 @@ -340,7 +341,7 @@ if ($result > 0) { $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->email; - $userstatic->statut = $obj->status; + $userstatic->status = $obj->status; print ''; print ''.$userstatic->getNomUrl(1); @@ -499,7 +500,7 @@ if ($result > 0) { $userstatic->id = $obj->id; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; - $userstatic->statut = $obj->status; + $userstatic->status = $obj->status; $userstatic->email = $obj->email; print $userstatic->getNomUrl(1); print $obj->email ? ' <'.$obj->email.'>' : $langs->trans("NoMail"); From 13e903aca44b57d6740a1ee9d2a2fa6277ea8660 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 20:44:51 +0100 Subject: [PATCH 153/315] Clean use of $_POST --- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/adherents/subscription.php | 10 +++++----- htdocs/admin/website.php | 2 +- htdocs/asset/card.php | 2 -- htdocs/asset/model/card.php | 2 -- htdocs/barcode/printsheet.php | 1 + htdocs/bookcal/availabilities_card.php | 2 -- htdocs/bookcal/calendar_card.php | 2 -- htdocs/categories/card.php | 9 +++++---- 9 files changed, 14 insertions(+), 20 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 35a81bbcf6d..2f97465cc2b 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1837,8 +1837,8 @@ class Adherent extends CommonObject // Possibility to add external linked objects with hooks $invoice->linked_objects['subscription'] = $subscriptionid; - if (!empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) { - $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); + if (GETPOSTISARRAY('other_linked_objects')) { + $invoice->linked_objects = array_merge($invoice->linked_objects, GETPOST('other_linked_objects')); } $result = $invoice->create($user); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 3ace1b42d58..f49d743a372 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -421,11 +421,11 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscripti // Clean some POST vars if (!$error) { - $_POST["subscription"] = ''; - $_POST["accountid"] = ''; - $_POST["operation"] = ''; - $_POST["label"] = ''; - $_POST["num_chq"] = ''; + $accountid = ''; + $operation = ''; + $label = ''; + $num_chq = ''; + $option = ''; } } } diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 82d578686fc..1a1bc1815dd 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -257,7 +257,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $sql .= ","; } $sql .= $field."="; - if ($_POST[$listfieldvalue[$i]] == '') { + if (GETPOST($listfieldvalue[$i]) == '') { $sql .= "null"; } else { $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'"; diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 434ee1f3318..24af02996b7 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -194,8 +194,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print ''."\n"; diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php index 31544663a62..d0d413d543e 100644 --- a/htdocs/asset/model/card.php +++ b/htdocs/asset/model/card.php @@ -180,8 +180,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print '
    ' . "\n"; diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index db52b5aaf19..608297551b8 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -24,6 +24,7 @@ * \brief Page to print sheets with barcodes using the document templates into core/modules/printsheets */ +// Do not use GETPOST, the function does not exists yet. if (!empty($_POST['mode']) && $_POST['mode'] === 'label') { // Page is called to build a PDF and output, we must not renew the token. if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index bc62dd76842..4ab6e667e35 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -253,8 +253,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print '
    '."\n"; diff --git a/htdocs/bookcal/calendar_card.php b/htdocs/bookcal/calendar_card.php index 2b86d58e41d..2f267666132 100644 --- a/htdocs/bookcal/calendar_card.php +++ b/htdocs/bookcal/calendar_card.php @@ -226,8 +226,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print '
    '."\n"; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 04c9953d92c..2a23a4a8784 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -82,6 +82,9 @@ if ($origin) { if ($catorigin && $type == Categorie::TYPE_PRODUCT) { $idCatOrigin = $catorigin; } +if (!GETPOSTISSET('parent') && $catorigin) { + $parent = $catorigin; +} $object = new Categorie($db); @@ -166,7 +169,6 @@ if (empty($reshook)) { $result = $object->create($user); if ($result > 0) { $action = 'confirmed'; - $_POST["addcat"] = ''; } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -221,14 +223,13 @@ llxHeader("", $langs->trans("Categories"), $help_url); if ($user->hasRight('categorie', 'creer')) { // Create or add - if ($action == 'create' || GETPOST("addcat") == 'addcat') { + if ($action == 'create' || $action == 'add') { dol_set_focus('#label'); print ''; print ''; print ''; print ''; - print ''; print ''; print ''; print ''; @@ -270,7 +271,7 @@ if ($user->hasRight('categorie', 'creer')) { // Parent category print ''; From b58e439a176b3d5648ba225fde700ccd10cdf96d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 21:29:02 +0100 Subject: [PATCH 154/315] Clean use of $_POST --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/bom/bom_card.php | 2 +- htdocs/comm/propal/card.php | 6 +++--- htdocs/compta/bank/bankentries_list.php | 3 ++- htdocs/compta/facture/card.php | 4 ++-- htdocs/contrat/card.php | 4 ++-- htdocs/core/actions_massactions.inc.php | 6 +++--- htdocs/core/actions_sendmails.inc.php | 6 +++--- htdocs/core/ajax/onlineSign.php | 2 +- htdocs/core/ajax/saveinplace.php | 2 +- htdocs/core/class/commonobject.class.php | 6 +----- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/login/functions_googleoauth.php | 2 +- htdocs/core/login/functions_ldap.php | 1 - .../core/modules/mailings/fraise.modules.php | 2 +- .../modules/oauth/google_oauthcallback.php | 18 ++---------------- htdocs/core/photos_resize.php | 2 -- htdocs/core/tpl/filemanager.tpl.php | 2 +- .../core/actions_massactions_mail.inc.php | 4 ++-- htdocs/exports/export.php | 1 - htdocs/fichinter/card.php | 4 ++-- htdocs/fourn/commande/card.php | 1 - htdocs/fourn/facture/card-rec.php | 2 +- htdocs/main.inc.php | 11 +++++------ htdocs/modulebuilder/index.php | 2 +- .../template/class/actions_mymodule.class.php | 2 +- .../modulebuilder/template/myobject_card.php | 2 -- htdocs/opensurvey/lib/opensurvey.lib.php | 6 +++--- htdocs/product/inventory/inventory.php | 2 +- .../stock/stocktransfer/stocktransfer_card.php | 2 -- .../stocktransfer/stocktransfer_contact.php | 8 +------- htdocs/public/agenda/agendaexport.php | 1 + htdocs/public/company/new.php | 3 ++- htdocs/public/cron/cron_run_jobs_by_url.php | 1 + .../public/eventorganization/attendee_new.php | 2 +- htdocs/public/members/new.php | 2 +- htdocs/public/payment/newpayment.php | 1 - htdocs/supplier_proposal/card.php | 4 ++-- htdocs/viewimage.php | 4 +++- htdocs/webhook/target_card.php | 2 -- 40 files changed, 54 insertions(+), 85 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 2f97465cc2b..8da35576186 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1838,7 +1838,7 @@ class Adherent extends CommonObject // Possibility to add external linked objects with hooks $invoice->linked_objects['subscription'] = $subscriptionid; if (GETPOSTISARRAY('other_linked_objects')) { - $invoice->linked_objects = array_merge($invoice->linked_objects, GETPOST('other_linked_objects')); + $invoice->linked_objects = array_merge($invoice->linked_objects, GETPOST('other_linked_objects', 'array:int')); } $result = $invoice->create($user); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 5753ce0bc89..a6210efa27a 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -164,7 +164,7 @@ if (empty($reshook)) { $idprod = $bom_child->fk_product; } } else { - $idprod = (!empty(GETPOSTINT('idprodservice')) ? GETPOSTINT('idprodservice') : GETPOSTINT('idprod')); + $idprod = (GETPOSTINT('idprodservice') ? GETPOSTINT('idprodservice') : GETPOSTINT('idprod')); } $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8044e284b73..af70409a70a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -552,9 +552,9 @@ if (empty($reshook)) { $object->origin_id = $originid; // Possibility to add external linked objects with hooks - $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + $object->linked_objects[$object->origin] = $object->origin_id; + if (GETPOSTISARRAY('other_linked_objects')) { + $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int')); } $id = $object->create($user); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 82184b9ecb7..4795d238d6a 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1798,7 +1798,8 @@ if ($resql) { if ($objp->num_releve) { print ' '; } - print 'rowid]) ? ' checked' : '').'>'; + $tmparray = GETPOST('rowid', 'array:int'); + print 'rowid]) ? ' checked' : '').'>'; } } print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 56fc5218598..f13654b0a31 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1547,8 +1547,8 @@ if (empty($reshook)) { } } - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + if (GETPOSTISARRAY('other_linked_objects')) { + $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int')); } $id = $object->create($user); // This include class to add_object_linked() and add add_contact() diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 47f524aba73..23890c825c7 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -289,8 +289,8 @@ if (empty($reshook)) { // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + if (GETPOSTISARRAY('other_linked_objects')) { + $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int')); } $id = $object->create($user); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2fca6e22a33..9ccbbc4e671 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -167,7 +167,7 @@ if (!$error && $massaction == 'confirm_presend') { $receiver = array($receiver); } } - if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) { // if only one recipient, receiver is mandatory + if (!trim(GETPOST('sendto', 'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) { // if only one recipient, receiver is mandatory $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); $massaction = 'presend'; @@ -195,7 +195,7 @@ if (!$error && $massaction == 'confirm_presend') { // Define $sendto $tmparray = array(); - if (trim($_POST['sendto'])) { + if (trim(GETPOST('sendto', 'alphawithlgt'))) { // Recipients are provided into free text $tmparray[] = trim(GETPOST('sendto', 'alphawithlgt')); } @@ -222,7 +222,7 @@ if (!$error && $massaction == 'confirm_presend') { } } $tmparray = array(); - if (trim($_POST['sendtocc'])) { + if (trim(GETPOST('sendtocc', 'alphawithlgt'))) { $tmparray[] = trim(GETPOST('sendtocc', 'alphawithlgt')); } if (count($receivercc) > 0) { diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 7c8efdb5a98..d3039b5ccaf 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -190,12 +190,12 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO } $tmparray = array(); - if (trim($_POST['sendto'])) { + if (trim(GETPOST('sendto', 'alphawithlgt'))) { // Recipients are provided into free text field $tmparray[] = trim(GETPOST('sendto', 'alphawithlgt')); } - if (isset($_POST['tomail']) && trim($_POST['tomail'])) { + if (trim(GETPOST('tomail', 'alphawithlgt'))) { // Recipients are provided into free hidden text field $tmparray[] = trim(GETPOST('tomail', 'alphawithlgt')); } @@ -238,7 +238,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO } } $tmparray = array(); - if (trim($_POST['sendtocc'])) { + if (trim(GETPOST('sendtocc', 'alphawithlgt'))) { $tmparray[] = trim(GETPOST('sendtocc', 'alphawithlgt')); } if (count($receivercc) > 0) { diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index b861d7c3796..8d04732aea4 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -61,7 +61,7 @@ $signature = GETPOST('signaturebase64'); $ref = GETPOST('ref', 'aZ09'); $mode = GETPOST('mode', 'aZ09'); // 'proposal', ... $SECUREKEY = GETPOST("securekey"); // Secure key -$online_sign_name = GETPOST("onlinesignname") ? GETPOST("onlinesignname") : ''; +$online_sign_name = GETPOST("onlinesignname"); $error = 0; $response = ""; diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 6b337a88c68..47fd89b1659 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -127,7 +127,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e $newelement = $element; } - $_POST['action'] = 'update'; // Hack so restrictarea will test permissions on write too + $_POST['action'] = 'update'; // Keep this. It is a hack so restrictarea will test permissions on write too $feature = $newelement; $feature2 = $subelement; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9f93e22fcda..d74538f288d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5636,7 +5636,7 @@ abstract class CommonObject * Common function for all objects extending CommonObject for generating documents * * @param string $modelspath Relative folder where generators are placed - * @param string $modele Generator to use. Caller must set it to obj->model_pdf or $_POST for example. + * @param string $modele Generator to use. Caller must set it to from obj->model_pdf or from GETPOST for example. * @param Translate $outputlangs Output language to use * @param int $hidedetails 1 to hide details. 0 by default * @param int $hidedesc 1 to hide product description. 0 by default @@ -6016,8 +6016,6 @@ abstract class CommonObject **/ public function getDefaultCreateValueFor($fieldname, $alternatevalue = null, $type = 'alphanohtml') { - global $_POST; - // If param here has been posted, we use this value first. if (GETPOSTISSET($fieldname)) { return GETPOST($fieldname, $type, 3); @@ -6176,8 +6174,6 @@ abstract class CommonObject */ public function setValuesForExtraLanguages($onlykey = '') { - global $_POST, $langs; - // Get extra fields foreach ($_POST as $postfieldkey => $postfieldvalue) { $tmparray = explode('-', $postfieldkey); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8e5befafd0a..7cfc5187d49 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2129,7 +2129,7 @@ class ExtraFields */ public function setOptionalsFromPost($extralabels, &$object, $onlykey = '', $todefaultifmissing = 0) { - global $conf, $_POST, $langs; + global $langs; $nofillrequired = 0; // For error when required field left blank $error_field_required = array(); diff --git a/htdocs/core/login/functions_googleoauth.php b/htdocs/core/login/functions_googleoauth.php index 9a60b159586..0e61541192c 100644 --- a/htdocs/core/login/functions_googleoauth.php +++ b/htdocs/core/login/functions_googleoauth.php @@ -39,7 +39,7 @@ */ function check_user_password_googleoauth($usertotest, $passwordtotest, $entitytotest) { - global $_POST, $conf; + global $conf; dol_syslog("functions_googleoauth::check_user_password_googleoauth usertotest=".$usertotest." GETPOST('actionlogin')=".GETPOST('actionlogin')); diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index fde4d4128f9..89c910b8cf2 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -37,7 +37,6 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) { global $db, $conf, $langs; - global $_POST; global $dolibarr_main_auth_ldap_host, $dolibarr_main_auth_ldap_port; global $dolibarr_main_auth_ldap_version, $dolibarr_main_auth_ldap_servertype; global $dolibarr_main_auth_ldap_login_attribute, $dolibarr_main_auth_ldap_dn; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 1547ce1d866..6007b7adb95 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -233,7 +233,7 @@ class mailing_fraise extends MailingTargets public function add_to_target($mailing_id) { // phpcs:enable - global $conf, $langs, $_POST; + global $conf, $langs; // Load translation files required by the page $langs->loadLangs(array("members", "companies")); diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 2fc4a4a4b09..4f38e884481 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -161,22 +161,8 @@ if (!GETPOST('code')) { $_SESSION['oauthstateanticsrf'] = $state; // Save more data into session - // Not required. All data are saved into $_SESSION['datafromloginform'] when form is posted with a click on Login with - // Google with param actionlogin=login and beforeoauthloginredirect=google, by the functions_googleoauth.php. - /* - if (!empty($_POST["tz"])) { - $_SESSION["tz"] = $_POST["tz"]; - } - if (!empty($_POST["tz_string"])) { - $_SESSION["tz_string"] = $_POST["tz_string"]; - } - if (!empty($_POST["dst_first"])) { - $_SESSION["dst_first"] = $_POST["dst_first"]; - } - if (!empty($_POST["dst_second"])) { - $_SESSION["dst_second"] = $_POST["dst_second"]; - } - */ + // No need to save more data in sessions. We have several info into $_SESSION['datafromloginform'], saved when form is posted with a click + // on "Login with Google" with param actionlogin=login and beforeoauthloginredirect=google, by the functions_googleoauth.php. if ($forlogin) { $apiService->setApprouvalPrompt('force'); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 416dd3959e0..199d54e3e50 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -404,7 +404,6 @@ if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") } } else { setEventMessages($result, null, 'errors'); - //$_GET['file'] = $_POST["file"]; $action = ''; } } @@ -467,7 +466,6 @@ if ($action == 'confirm_crop') { } } else { setEventMessages($result, null, 'errors'); - //$_GET['file'] = $_POST["file"]; $action = ''; } } diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 7acbddd72fa..0e75907dcba 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -316,7 +316,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg $_POST['modulepart'] = $module; $_POST['openeddir'] = GETPOST('openeddir'); - $_POST['dir'] = empty($_POST['dir']) ? '/' : $_POST['dir']; + $_POST['dir'] = empty($_POST['dir']) ? '/' : GETPOST('dir'); // Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show) print '
    '; diff --git a/htdocs/eventorganization/core/actions_massactions_mail.inc.php b/htdocs/eventorganization/core/actions_massactions_mail.inc.php index 634264c83cf..67aaa624510 100644 --- a/htdocs/eventorganization/core/actions_massactions_mail.inc.php +++ b/htdocs/eventorganization/core/actions_massactions_mail.inc.php @@ -109,7 +109,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') { $receiver = array($receiver); } } - if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofselectedid) == 0) { // if only one recipient, receiver is mandatory + if (!trim(GETPOST('sendto', 'alphawithlgt')) && count($receiver) == 0 && count($listofselectedid) == 0) { // if only one recipient, receiver is mandatory $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); $massaction = 'presend_attendees'; @@ -142,7 +142,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') { } } $tmparray = array(); - if (trim($_POST['sendtocc'])) { + if (trim(GETPOST('sendtocc', 'alphawithlgt'))) { $tmparray[] = trim(GETPOST('sendtocc', 'alphawithlgt')); } $sendtocc = implode(',', $tmparray); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 90439554f76..dac7cee794c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -400,7 +400,6 @@ if ($step == 4 && $action == 'submitFormField') { $filterqualified = 0; } if ($filterqualified) { - //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, $check); } } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 507affb5fab..0091dd56dfe 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -293,8 +293,8 @@ if (empty($reshook)) { // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + if (GETPOSTISARRAY('other_linked_objects')) { + $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int')); } // Extrafields diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9b1c7d93518..c25d8afbdd6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1420,7 +1420,6 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); $action = 'create'; - //$_GET['socid'] = $_POST['socid']; } else { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode((string) ($id))); diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 10dd9fd4e45..f7b0db9ae7f 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -527,7 +527,7 @@ if (empty($reshook)) { // Define special_code for special lines $special_code = 0; - // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices + // if (!GETPOST('qty')) $special_code=3; // Options should not exists on invoices // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5a1f7684755..bf8f1cca1ec 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -327,15 +327,15 @@ require_once 'filefunc.inc.php'; // If there is a POST parameter to tell to save automatically some POST parameters into cookies, we do it. // This is used for example by form of boxes to save personalization of some options. // DOL_AUTOSET_COOKIE=cookiename:val1,val2 and cookiename_val1=aaa cookiename_val2=bbb will set cookie_name with value json_encode(array('val1'=> , )) -if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { - $tmpautoset = explode(':', $_POST["DOL_AUTOSET_COOKIE"], 2); +if (GETPOST("DOL_AUTOSET_COOKIE")) { + $tmpautoset = explode(':', GETPOST("DOL_AUTOSET_COOKIE"), 2); $tmplist = explode(',', $tmpautoset[1]); $cookiearrayvalue = array(); foreach ($tmplist as $tmpkey) { $postkey = $tmpautoset[0].'_'.$tmpkey; - //var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]); - if (!empty($_POST[$postkey])) { - $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; + //var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.GETPOST($postkey); + if (GETPOST($postkey)) { + $cookiearrayvalue[$tmpkey] = GETPOST($postkey); } } $cookiename = $tmpautoset[0]; @@ -764,7 +764,6 @@ if (!defined('NOLOGIN')) { $dol_optimize_smallscreen = GETPOSTINT('dol_optimize_smallscreen', 3); $dol_no_mouse_hover = GETPOSTINT('dol_no_mouse_hover', 3); $dol_use_jmobile = GETPOSTINT('dol_use_jmobile', 3); // 0=default, 1=to say we use app from a webview app, 2=to say we use app from a webview app and keep ajax - //dol_syslog("POST key=".join(array_keys($_POST),',').' value='.join($_POST,',')); // If in demo mode, we check we go to home page through the public/demo/index.php page if (!empty($dolibarr_main_demo) && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php') { // We ask index page diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1cee92393c0..f2261034547 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2941,7 +2941,7 @@ if ($dirins && $action == "update_menu" && GETPOSTINT('menukey') && GETPOST('tab } } } else { - $_POST['type'] = ''; + $_POST['type'] = ''; // TODO Use a var here and later $_POST['titre'] = ''; $_POST['fk_menu'] = ''; $_POST['leftmenu'] = ''; diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 5070ae77e0a..3b9d04b0e38 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -108,7 +108,7 @@ class ActionsMyModule extends CommonHookActions /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' // Do what you want here... - // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. + // You can for example load and use call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and GETPOST values. } if (!$error) { diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index f006c4933ab..62cfd250fdd 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -282,8 +282,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print '
    '.$langs->trans("AddIn").''; print img_picto($langs->trans("ParentCategory"), 'category', 'class="pictofixedwidth"'); - print $form->select_all_categories($type, $catorigin, 'parent'); + print $form->select_all_categories($type, $parent, 'parent'); print ajax_combobox('parent'); print '
    '."\n"; diff --git a/htdocs/opensurvey/lib/opensurvey.lib.php b/htdocs/opensurvey/lib/opensurvey.lib.php index 141f01ab5af..80e272eaf90 100644 --- a/htdocs/opensurvey/lib/opensurvey.lib.php +++ b/htdocs/opensurvey/lib/opensurvey.lib.php @@ -175,9 +175,9 @@ function get_server_name() /** * Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau * - * @param string $name La clé à tester - * @param array $tableau Le tableau où rechercher la clé ($_POST par défaut) - * @return bool Vrai si la clé existe et renvoie une valeur non vide + * @param string $name Key to test + * @param array $tableau Array in which searching key ($_POST by default) + * @return bool True if key exists and return a non empty value */ function issetAndNoEmpty($name, $tableau = null) { diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 0aab3be055c..a70a9a08faf 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -412,7 +412,7 @@ if (empty($reshook)) { } } else { // Clear var - $_POST['batch'] = ''; + $_POST['batch'] = ''; // TODO Replace this with a var $_POST['qtytoadd'] = ''; } } diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 7521fb2ef3b..96b228fba9e 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -439,8 +439,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print '
    '."\n"; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index 33d2ff92f04..8f599eb71de 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -78,7 +78,7 @@ $result = restrictedArea($user, 'stocktransfer', $id, '', 'stocktransfer'); if ($action == 'addcontact' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) { if ($object->id > 0) { $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); - $result = $object->add_contact($contactid, !empty($_POST["typecontact"]) ? $_POST["typecontact"] : $_POST["type"], $_POST["source"]); + $result = $object->add_contact($contactid, GETPOST("typecontact") ? GETPOST("typecontact") : GETPOST("type"), GETPOST("source")); } if ($result >= 0) { @@ -106,12 +106,6 @@ if ($action == 'addcontact' && $user->hasRight('stocktransfer', 'stocktransfer', dol_print_error($db); } } -/* -elseif ($action == 'setaddress' && $user->rights->stocktransfer->stocktransfer->write) -{ - $result=$object->setDeliveryAddress($_POST['fk_address']); - if ($result < 0) dol_print_error($db,$object->error); -}*/ /* diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index b4d6f415b33..0aa90ef50ec 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -74,6 +74,7 @@ function llxFooterVierge() // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index 0d26ad7ad9d..b6e84d2437b 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -44,6 +44,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); @@ -203,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($_POST['code']))); + $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code')))); if (!$ok) { $error++; $errmsg .= $langs->trans("ErrorBadValueForCode") . "
    \n"; diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php index ca3c8c06235..1ebf7b26347 100644 --- a/htdocs/public/cron/cron_run_jobs_by_url.php +++ b/htdocs/public/cron/cron_run_jobs_by_url.php @@ -50,6 +50,7 @@ if (!defined('USESUFFIXINLOG')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index bb3b23a3626..ac3f67baa9d 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -42,7 +42,7 @@ if (!defined('NOIPCHECK')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 6f4525031ea..8fc8e514578 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -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($_POST['code']))); + $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code')))); if (!$ok) { $error++; $errmsg .= $langs->trans("ErrorBadValueForCode")."
    \n"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 79623a7d393..6723ca7c97f 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -390,7 +390,6 @@ if ($action == 'dopayment') { $action = ''; } - //var_dump($_POST); if (empty($mesg)) { dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 0d5e20a7049..c3846425458 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -358,8 +358,8 @@ if (empty($reshook)) { // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + if (GETPOSTISARRAY('other_linked_objects')) { + $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int')); } $id = $object->create($user); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 6daec2a1569..2ebe4c8e9a4 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -101,7 +101,9 @@ if (!$needlogin) { } } -// For multicompany +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index f12b7ee8869..5709df943f3 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -213,8 +213,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; print '
    '."\n"; From fbf0912a9875366ef458ff1e93789f422fa8cd1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Mar 2024 21:33:09 +0100 Subject: [PATCH 155/315] Fix phpunit warnings --- test/phpunit/CodingPhpTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 8b3ed332211..fe3a4760003 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -170,6 +170,7 @@ class CodingPhpTest extends CommonClassTest } if (preg_match('/\.class\.php$/', $file['relativename']) && ! in_array($file['relativename'], array( + 'adherents/class/adherent.class.php', 'adherents/canvas/actions_adherentcard_common.class.php', 'contact/canvas/actions_contactcard_common.class.php', 'compta/facture/class/facture.class.php', @@ -183,6 +184,7 @@ class CodingPhpTest extends CommonClassTest 'core/class/html.formsms.class.php', 'core/class/html.formticket.class.php', 'core/class/utils.class.php', + 'core/class/openid.class.php', 'fourn/class/fournisseur.facture.class.php', 'societe/canvas/actions_card_common.class.php', 'societe/canvas/individual/actions_card_individual.class.php', From 101f16f7b363fc08708054f9c215cbba14297e19 Mon Sep 17 00:00:00 2001 From: Jonathan lescaut Date: Fri, 29 Mar 2024 09:52:07 +0100 Subject: [PATCH 156/315] retour wysy --- htdocs/core/actions_massactions.inc.php | 4 ++-- htdocs/langs/en_US/main.lang | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 410cdf5aa21..b485f7d8b0f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1577,9 +1577,9 @@ if (!$error && ($massaction == 'Unassigncommercial' || ($action == 'Unassigncomm if (!$error) { if ($nbok > 1) { - setEventMessages($langs->trans("CommercialsAffected", $nbok), null, 'mesgs'); + setEventMessages($langs->trans("CommercialsDisaffected", $nbok), null, 'mesgs'); } else { - setEventMessages($langs->trans("CommercialAffected"), null, 'mesgs'); + setEventMessages($langs->trans("CommercialDisaffected"), null, 'mesgs'); } $db->commit(); } else { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index d6dfb8bc74b..cbdde72e3df 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1221,9 +1221,13 @@ Terminated=Terminated Position=Position AddLineOnPosition=Add line on position (at the end if empty) ConfirmAllocateCommercial=Assign sales representative confirmation +ConfirmUnallocateCommercial= Confirmation of the de-assignment of a sales representative ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? +ConfirmUnallocateCommercialQuestion=Are you sure you want to unassign the selected %s record(s)? CommercialsAffected=Sales representatives assigned CommercialAffected=Sales representative assigned +CommercialsDisaffected=Sales representatives disassigned +CommercialDisaffected=Sales representative disassigned YourMessage=Your message YourMessageHasBeenReceived=Your message has been received. We will answer or contact you as soon as possible. UrlToCheck=Url to check From 930ff0d905edcd183d4f0234d2bf69f47213128d Mon Sep 17 00:00:00 2001 From: Jonathan lescaut Date: Fri, 29 Mar 2024 11:06:42 +0100 Subject: [PATCH 157/315] retour PR --- htdocs/core/actions_massactions.inc.php | 2 +- htdocs/core/tpl/massactions_pre.tpl.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b485f7d8b0f..d245ca62708 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1544,7 +1544,7 @@ if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommerci } } -if (!$error && ($massaction == 'Unassigncommercial' || ($action == 'Unassigncommercial' && $confirm == 'yes')) && $permissiontoadd) { +if (!$error && ($massaction == 'unassigncommercial' || ($action == 'unassigncommercial' && $confirm == 'yes')) && $permissiontoadd) { $db->begin(); $objecttmp = new $objectclass($db); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index d27b1f9c0f5..d479a223a12 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -398,10 +398,10 @@ if ($massaction == 'unsetcommercial') { $formquestion = array(); $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); $formquestion[] = array('type' => 'other', - 'name' => 'Unassigncommercial', + 'name' => 'unassigncommercial', 'label' => $form->editfieldkey('UnallocateCommercial', 'commercial_id', '', $object, 0), 'value' => $form->multiselectarray('commercial', $userlist, null, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1)); - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUnallocateCommercial"), $langs->trans("ConfirmUnallocateCommercialQuestion", count($toselect)), "Unassigncommercial", $formquestion, 1, 0, 200, 500, 1); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUnallocateCommercial"), $langs->trans("ConfirmUnallocateCommercialQuestion", count($toselect)), "unassigncommercial", $formquestion, 1, 0, 200, 500, 1); } if ($massaction == 'preapproveleave') { From 0fbaf8b118744bfa41a3e20f7ae448f24a8a8912 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 11:25:33 +0100 Subject: [PATCH 158/315] Fix example --- htdocs/comm/propal/class/api_proposals.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 546d40d052d..cb60b0c9485 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -156,7 +156,7 @@ class Proposals extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $thirdparty_ids Thirdparty ids to filter commercial proposals (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'2016-01-01')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects */ From 5a6791aa5abc2e92745da7cc547751a10ca6725e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 11:43:26 +0100 Subject: [PATCH 159/315] Clean code --- htdocs/comm/propal/class/api_proposals.class.php | 2 -- htdocs/core/class/html.form.class.php | 2 +- htdocs/fourn/facture/list.php | 11 ++--------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index cb60b0c9485..33cc0957c47 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -162,8 +162,6 @@ class Proposals extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { - global $db, $conf; - if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(403); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 97082b64db2..539aa3f4bf3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8407,7 +8407,7 @@ class Form * * @param string $htmlname Name of html select area. Try to start name with "multi" or "search_multi" if this is a multiselect * @param array $array Array like array(key => value) or array(key=>array('label'=>..., 'data-...'=>..., 'disabled'=>..., 'css'=>...)) - * @param string|string[] $id Preselected key or preselected keys for multiselect. Use 'ifone' to autoselect record if there is only one record. + * @param string|string[] $id Preselected key or array of preselected keys for multiselect. Use 'ifone' to autoselect record if there is only one record. * @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (If 1: key is -1 and value is '' or ' ', If placeholder string: key is -1 and value is the string), <0 to add an empty value with key that is this value. * @param int $key_in_label 1 to show key into label with format "[key] value" * @param int $value_as_key 1 to use value as key diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 9a57e3ddf0d..f40fab2257f 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1094,20 +1094,13 @@ if (!empty($arrayfields['f.ref_supplier']['checked'])) { // Type if (!empty($arrayfields['f.type']['checked'])) { print ''; } // Invoice Subtype From fa250c8f8abe7b992a3e5e94400d1e6eafb2ec8f Mon Sep 17 00:00:00 2001 From: terhoy <70033666+terhoy@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:13:38 +0100 Subject: [PATCH 160/315] Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 --- htdocs/admin/mails_templates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 7a6d513c589..b19093eeeb0 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1040,7 +1040,7 @@ foreach ($fieldlist as $field => $value) { } $sortfieldtouse = ($sortable ? $fieldlist[$field] : ''); if ($sortfieldtouse == 'type_template') { - $sortfieldtouse.= 'type_template,lang,position,label'; + $sortfieldtouse .= ',lang,position,label'; } print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $css.' '); } From e3073490cd539b6102862dc044ac7661bb6091e7 Mon Sep 17 00:00:00 2001 From: jyhere Date: Fri, 29 Mar 2024 11:53:31 +0100 Subject: [PATCH 161/315] FIX: supplier proposaldet ref_fourn size supplier_proposaldet ref_fourn size should match product_fournisseur_price ref_fourn size (128) --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index a99b9731232..ef6cfc14731 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -288,3 +288,5 @@ ALTER TABLE llx_expeditiondet ADD COLUMN element_type varchar(50) DEFAULT 'order ALTER TABLE llx_receptiondet_batch CHANGE COLUMN fk_commande fk_element integer; ALTER TABLE llx_receptiondet_batch CHANGE COLUMN fk_commandefourndet fk_elementdet integer; + +ALTER TABLE llx_supplier_proposaldet MODIFY ref_fourn VARCHAR(128) NULL; From 7a5257d776ac360fc104c558dd063d067bd71bff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 11:53:57 +0100 Subject: [PATCH 162/315] Fix #29112 --- htdocs/theme/md/style.css.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ad321f78774..9dabc46d53f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -5173,6 +5173,9 @@ div#card-errors { .ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-draggable { z-index: 1005 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ } +.ui-menu.ui-widget.ui-widget-content.ui-autocomplete.ui-front { + z-index:1006 !important; /* To always be over the dialog box */ +} .ui-dialog.ui-widget.ui-widget-content { border: 1px solid #e0e0e0; From 3130ede583708472e7aaeb247668959f0c7220ba Mon Sep 17 00:00:00 2001 From: Jonathan lescaut Date: Fri, 29 Mar 2024 12:17:47 +0100 Subject: [PATCH 163/315] retour PR --- htdocs/core/actions_massactions.inc.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d245ca62708..b42f6fb0860 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1555,8 +1555,8 @@ if (!$error && ($massaction == 'unassigncommercial' || ($action == 'unassigncomm if ($result > 0) { if (in_array($objecttmp->element, array('societe'))) { $TCommercial = GETPOST("commercial", "alpha"); - if (is_array($TCommercial)){ - foreach ($TCommercial as $commercial){ + if (is_array($TCommercial)) { + foreach ($TCommercial as $commercial) { $result = $objecttmp->del_commercial($user, $commercial); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 97082b64db2..3fd6738addf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8436,7 +8436,7 @@ class Form if ($value_as_key) { $array = array_combine($array, $array); } - +q $out = ''; if ($addjscombo < 0) { From 10d1f6169c0565d175b4ab9cdacbb24306b959e7 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Fri, 29 Mar 2024 13:27:37 +0200 Subject: [PATCH 164/315] Qual translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 90077daa51b..a9d4bde40ae 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -89,7 +89,7 @@ NotAvailableWhenAjaxDisabled=Not available when Ajax disabled AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party TimesheetPreventAfterFollowingMonths=Prevent recording time spent after the following number of months PROJECT_DISPLAY_LINKED_BY_CONTACT=Display project linked by a common contact -PROJECT_DISPLAY_LINKED_BY_CONTACT_help=That option add a new list on Project tab with all projects linked to that thirdparty via a contact relationship +PROJECT_DISPLAY_LINKED_BY_CONTACT_help=This option adds a new list on Project tab with all projects linked to thirdparty via a contact relationship JavascriptDisabled=JavaScript disabled UsePreviewTabs=Use preview tabs ShowPreview=Show preview From 726637937c9e1f6d7c86a0de2719a79a28d04999 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 12:28:55 +0100 Subject: [PATCH 165/315] Fix #29118 --- htdocs/admin/company.php | 28 ++++++++++---------- htdocs/core/class/html.formcompany.class.php | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 87639008243..d8f0cc612f7 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -635,7 +635,7 @@ print ''; if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { print ''; // Object of the company print ''; +print ''; print ''; print '
    '; - $listtype = array( + $typearray = array( FactureFournisseur::TYPE_STANDARD => $langs->trans("InvoiceStandard"), FactureFournisseur::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"), FactureFournisseur::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"), FactureFournisseur::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"), ); - /* - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); - } - */ - //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. - print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); + print $form->selectarray('search_type', $typearray, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); print ''; if ($mysoc->country_code) { - print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'forme_juridique_code'); + print $formcompany->select_juridicalstatus(getDolGlobalString('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'), $mysoc->country_code, '', 'forme_juridique_code'); } else { print $countrynotdefined; } @@ -645,7 +645,7 @@ print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -656,7 +656,7 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -667,7 +667,7 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -678,7 +678,7 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -689,7 +689,7 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -700,7 +700,7 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -711,7 +711,7 @@ if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -722,7 +722,7 @@ if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -733,7 +733,7 @@ if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -744,7 +744,7 @@ if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') { if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') { print '
    '; if (!empty($mysoc->country_code)) { - print ''; + print ''; } else { print $countrynotdefined; } @@ -753,12 +753,12 @@ if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') { // Intra-community VAT number print '
    '; -print ''; +print ''; print '
    '; -print '
    '; @@ -875,7 +875,7 @@ if ($mysoc->useLocalTax(2)) { $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."\n" : ""); if (!isOnlyOneLocalTax(2)) { print '
    : '; - $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); + $formcompany->select_localtax(2, getDolGlobalString('MAIN_INFO_VALUE_LOCALTAX2'), "lt2"); } print '
    : '; print $form->selectarray("clt2", $opcions, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2')); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 466387bbc76..8e529746c73 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1007,7 +1007,7 @@ class FormCompany extends Form * Return a HTML select with localtax values for thirdparties * * @param int $local LocalTax - * @param int $selected Preselected value + * @param float $selected Preselected value * @param string $htmlname HTML select name * @return void */ From 582b791693070c06345e5bd4ad471498435e941c Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Fri, 29 Mar 2024 13:40:31 +0200 Subject: [PATCH 166/315] Qual translation --- htdocs/langs/en_US/cashdesk.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index ff42af8c3fb..3baf275ab15 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -106,7 +106,7 @@ ControlCashOpening=Open the "Control cash box" popup when opening the POS CloseCashFence=Close cash box control CashReport=Cash report MainPrinterToUse=Main printer to use -MainPrinterToUseMore=empty means the browser printer system +MainPrinterToUseMore=leave empty to use the browser printer system OrderPrinterToUse=Order printer to use MainTemplateToUse=Main template to use MainTemplateToUseMore=when not using browser printing system From 18eba7197380ef6532c47f15d70dbc39425b49d0 Mon Sep 17 00:00:00 2001 From: jyhere Date: Fri, 29 Mar 2024 13:19:32 +0100 Subject: [PATCH 167/315] FIX: supplier proposaldet ref_fourn size on create table too --- htdocs/install/mysql/tables/llx_supplier_proposaldet.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql index bbf3decd7fa..2e61c58cc18 100644 --- a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql +++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql @@ -47,7 +47,7 @@ CREATE TABLE llx_supplier_proposaldet ( fk_product_fournisseur_price integer DEFAULT NULL, special_code integer DEFAULT 0, rang integer DEFAULT 0, - ref_fourn varchar(30) DEFAULT NULL, + ref_fourn varchar(128) DEFAULT NULL, fk_multicurrency integer, multicurrency_code varchar(3), multicurrency_subprice double(24,8) DEFAULT 0, From 7689f345a0ee6b7661e70b8f9a4201dc2ff2df56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 29 Mar 2024 13:24:38 +0100 Subject: [PATCH 168/315] fix test --- htdocs/projet/tasks/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 723a31e9122..95de13155a8 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -426,7 +426,7 @@ if ($id > 0 || !empty($ref)) { print ''; $thirdpartyofproject = $projectstatic->getListContactId('thirdparty'); - $selectedCompany = GETPOSISSET("newcompany") ? GETPOST("newcompany") : $projectstatic->socid; + $selectedCompany = GETPOSTISSET("newcompany") ? GETPOST("newcompany") : $projectstatic->socid; $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, '&withproject='.$withproject); print ''; From fa65546800ba13f04354ddfc247381690a88396d Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Fri, 29 Mar 2024 08:04:02 -0500 Subject: [PATCH 169/315] Enable user establishment --- htdocs/user/class/user.class.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 95f404bd701..ab8cf4b6ae0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -11,10 +11,11 @@ * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2018 charlene Benke - * Copyright (C) 2018-2021 Nicolas ZABOURI - * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2019 Abbes Bahfir - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2021 Nicolas ZABOURI + * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019 Abbes Bahfir + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Lenin Rivas * * 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 @@ -379,6 +380,16 @@ class User extends CommonObject */ public $fk_warehouse; + /** + *@var int id of establishment + */ + public $fk_establishment; + + /** + *@var string label of establishment + */ + public $label_establishment; + /** * @var int egroupware id */ @@ -485,10 +496,12 @@ class User extends CommonObject $sql .= " u.national_registration_number,"; $sql .= " u.ref_employee,"; $sql .= " c.code as country_code, c.label as country,"; - $sql .= " d.code_departement as state_code, d.nom as state"; + $sql .= " d.code_departement as state_code, d.nom as state,"; + $sql .= " s.label as label_establishment, u.fk_establishment"; $sql .= " FROM ".$this->db->prefix()."user as u"; $sql .= " LEFT JOIN ".$this->db->prefix()."c_country as c ON u.fk_country = c.rowid"; $sql .= " LEFT JOIN ".$this->db->prefix()."c_departements as d ON u.fk_state = d.rowid"; + $sql .= " LEFT JOIN ".$this->db->prefix()."establishment as s ON u.fk_establishment = s.rowid"; if ($entity < 0) { if ((!isModEnabled('multicompany') || !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (!empty($user->entity))) { @@ -627,6 +640,8 @@ class User extends CommonObject $this->default_range = $obj->default_range; $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; $this->fk_warehouse = $obj->fk_warehouse; + $this->fk_establishment = $obj->fk_establishment; + $this->label_establishment = $obj->label_establishment; // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, // in such case, this admin user must be admin for ALL entities. @@ -2003,6 +2018,7 @@ class User extends CommonObject $this->birth = empty($this->birth) ? '' : $this->birth; $this->fk_warehouse = (int) $this->fk_warehouse; + $this->fk_establishment = (int) $this->fk_establishment; $this->setUpperOrLowerCase(); @@ -2117,6 +2133,7 @@ class User extends CommonObject $sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null'); $sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null'); $sql .= ", fk_warehouse = ".($this->fk_warehouse > 0 ? $this->fk_warehouse : "null"); + $sql .= ", fk_establishment = ".($this->fk_establishment > 0 ? $this->fk_establishment : "null"); $sql .= ", lang = ".($this->lang ? "'".$this->db->escape($this->lang)."'" : "null"); $sql .= " WHERE rowid = ".((int) $this->id); From 68babcbc4649b91ed4ab39f3b1228fd54217f171 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 14:52:27 +0100 Subject: [PATCH 170/315] NEW Add sql stddev_pop db function. --- htdocs/core/db/Database.interface.php | 8 ++++++++ htdocs/core/db/DoliDB.class.php | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 1c9c7a5a05f..9a796160292 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -36,6 +36,14 @@ interface Database */ public function ifsql($test, $resok, $resko); + /** + * Return SQL string to aggregate using the Standard Deviation of population + * + * @param string $nameoffield Name of field + * @return string SQL string + */ + public function stddevPop($nameoffield); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 19bb694558b..01237c5c676 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -105,6 +105,17 @@ abstract class DoliDB implements Database return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } + /** + * Return SQL string to aggregate using the Standard Deviation of population + * + * @param string $nameoffield Name of field + * @return string SQL string + */ + public function stddevPop($nameoffield) + { + return 'STDDEV_POP('.$nameoffield.')'; + } + /** * Return SQL string to force an index * From 67b12fc438117eca365ab1ae0d4d0bf166599c6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 17:08:31 +0100 Subject: [PATCH 171/315] FIX bad search on _ char in like when Debugbar is on --- htdocs/debugbar/class/TraceableDB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 013a31b66ac..4ddcf1eb22e 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -293,7 +293,7 @@ class TraceableDB extends DoliDB */ public function escapeforlike($stringtoencode) { - return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + return $this->db->escapeforlike($stringtoencode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From c87f24e3f493b111bf0312fbbd3cc1da8925804a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 17:09:36 +0100 Subject: [PATCH 172/315] Fix mysqli --- htdocs/core/db/mysqli.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 485477d052d..c98732c2d06 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -518,6 +518,7 @@ class DoliDBMysqli extends DoliDB */ public function escapeforlike($stringtoencode) { + // We must first replace the \ char into \\, then we can replace _ and % into \_ and \% return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode); } From 1e3edf151024915fbd2d2abf5c39884f9ef265b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 17:08:31 +0100 Subject: [PATCH 173/315] FIX bad search on _ char in like when Debugbar is on --- htdocs/debugbar/class/TraceableDB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 9b40abdb668..6cae03edf9c 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -292,7 +292,7 @@ class TraceableDB extends DoliDB */ public function escapeforlike($stringtoencode) { - return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + return $this->db->escapeforlike($stringtoencode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From f6f5d346b71ea1577df1c21a6c67e97264039a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Fri, 29 Mar 2024 17:59:35 +0100 Subject: [PATCH 174/315] fix phpstan phpdoc --- htdocs/core/class/discount.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index d51210bff34..29e663f4e27 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -303,7 +303,7 @@ class DiscountAbsolute extends CommonObject * Delete object in database. If fk_facture_source is defined, we delete all family with same fk_facture_source. If not, only with id is removed * * @param User $user Object of user asking to delete - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @return int<-2,1> Return integer <0 if KO, >0 if OK */ public function delete($user) { @@ -427,7 +427,7 @@ class DiscountAbsolute extends CommonObject * * @param int $rowidline Invoice line id (To use discount into invoice lines) * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduce payment of invoice) - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @return int<-3,1> Return integer <0 if KO, >0 if OK */ public function link_to_invoice($rowidline, $rowidinvoice) { @@ -483,7 +483,7 @@ class DiscountAbsolute extends CommonObject * Link the discount to a particular invoice line or a particular invoice. * Do not call this if discount is linked to a reconcialiated invoice * - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @return int<-3,1> Return integer <0 if KO, >0 if OK */ public function unlink_invoice() { From 32cb705419fbd48f196780ede02e51ad65ee50a1 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 17:50:04 +0100 Subject: [PATCH 175/315] Fix phpdoc int return ranges --- htdocs/core/class/discount.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index d51210bff34..29e663f4e27 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -303,7 +303,7 @@ class DiscountAbsolute extends CommonObject * Delete object in database. If fk_facture_source is defined, we delete all family with same fk_facture_source. If not, only with id is removed * * @param User $user Object of user asking to delete - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @return int<-2,1> Return integer <0 if KO, >0 if OK */ public function delete($user) { @@ -427,7 +427,7 @@ class DiscountAbsolute extends CommonObject * * @param int $rowidline Invoice line id (To use discount into invoice lines) * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduce payment of invoice) - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @return int<-3,1> Return integer <0 if KO, >0 if OK */ public function link_to_invoice($rowidline, $rowidinvoice) { @@ -483,7 +483,7 @@ class DiscountAbsolute extends CommonObject * Link the discount to a particular invoice line or a particular invoice. * Do not call this if discount is linked to a reconcialiated invoice * - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @return int<-3,1> Return integer <0 if KO, >0 if OK */ public function unlink_invoice() { From 0ccdbfe147a385b356a16afda1fb0b9d04579a34 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 18:07:20 +0100 Subject: [PATCH 176/315] Correct/improve phpdoc typing --- htdocs/variants/class/ProductCombination.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 11c9f1db2e5..63fc85ce623 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -663,8 +663,8 @@ class ProductCombination /** * Retrieves all unique attributes for a parent product * - * @param int $productid Product rowid - * @return ProductAttribute[] Array of attributes + * @param int $productid Product rowid + * @return ProductAttributeValue[] Array of attributes */ public function getUniqueAttributesAndValuesByFkProductParent($productid) { @@ -696,6 +696,7 @@ class ProductCombination $attrval = new ProductAttributeValue($this->db); foreach ($res = $attrval->fetchAllByProductAttribute($attr->id, true) as $val) { + '@phan-var-force ProductAttributeValue $val'; $tmp->values[] = $val; } @@ -720,7 +721,7 @@ class ProductCombination * @param User $user Object user * @param Product $product Parent product * @param array> $combinations Attribute and value combinations. - * @param array $variations Price and weight variations + * @param array> $variations Price and weight variations * @param bool|array $price_var_percent Is the price variation a relative variation? * @param bool|float $forced_pricevar If the price variation is forced * @param bool|float $forced_weightvar If the weight variation is forced @@ -813,7 +814,6 @@ class ProductCombination return -1; } } - if ($forced_weightvar === false) { $weight_impact += (float) price2num($variations[$currcombattr][$currcombval]['weight']); } From 9e892f43672d2c5e3044f1c53939f371a24f8f6d Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 18:20:51 +0100 Subject: [PATCH 177/315] Improve dol_clone typing by using phpdoc template --- htdocs/core/lib/functions.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1204e52d5a8..d71455a8044 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1370,9 +1370,11 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) * With native = 1: Use PHP clone. Property that are reference are same pointer. This means $this->db of new object is still valid but point to same this->db than original object. * With native = 2: Property that are reference are different memory area in the new object (full isolation clone). Only scalar and array values are cloned. This means method are not availables and $this->db of new object is not valid. * - * @param object $object Object to clone + * @template T of object + * + * @param T $object Object to clone * @param int $native 0=Full isolation method, 1=Native PHP method, 2=Full isolation method keeping only scalar and array properties (recommended) - * @return object Clone object + * @return T Clone object * @see https://php.net/manual/language.oop5.cloning.php */ function dol_clone($object, $native = 0) From df0e663c1305e673bb408ca777c1e9cc54c02d5a Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 18:23:08 +0100 Subject: [PATCH 178/315] Improve fetAllByProductAttribute phpdoc return type --- htdocs/variants/class/ProductAttributeValue.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index aac6c880ad5..d75ba4a8ebb 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -262,8 +262,8 @@ class ProductAttributeValue extends CommonObjectLine * * @param int $prodattr_id Product attribute id * @param bool $only_used Fetch only used attribute values - * @param int $returnonlydata 0: return object, 1: return only data - * @return ProductAttributeValue[] Array of object + * @param int<0,1> $returnonlydata 0: return object, 1: return only data + * @return ProductAttributeValue[]|stdClass[] Array of object */ public function fetchAllByProductAttribute($prodattr_id, $only_used = false, $returnonlydata = 0) { From 04c3e80fc5ca6cff223861e3721a49f001e5a3e0 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 18:23:58 +0100 Subject: [PATCH 179/315] Fix typing --- htdocs/asset/class/asset.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/class/comment.class.php | 2 +- htdocs/product/class/product.class.php | 2 +- htdocs/resource/class/dolresource.class.php | 2 +- htdocs/societe/class/societe.class.php | 12 ++++++------ htdocs/ticket/class/ticket.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 4c016282171..51b28f18427 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -158,7 +158,7 @@ class Asset extends CommonObject public $status; /** - * @var Asset object oldcopy + * @var static object oldcopy */ public $oldcopy; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 499ab5088af..8e875f598ac 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -130,7 +130,7 @@ class Propal extends CommonObject public $ref_customer; /** - * @var Propal oldcopy with propal properties + * @var static oldcopy with propal properties */ public $oldcopy; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 710cf3edaab..9f3f554e229 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -221,7 +221,7 @@ class Facture extends CommonInvoice public $tab_next_situation_invoice = array(); /** - * @var Facture object oldcopy + * @var static object oldcopy */ public $oldcopy; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ac7c96194cb..833919df82d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -337,7 +337,7 @@ class Contact extends CommonObject /** * Old copy - * @var Contact + * @var static */ public $oldcopy; // To contains a clone of this when we need to save old properties of object diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index f60f5c44183..9ffa0d60a1e 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -77,7 +77,7 @@ class Comment extends CommonObject public $comments = array(); /** - * @var Comment Object oldcopy + * @var static Object oldcopy */ public $oldcopy; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cd24b0197a7..641ba49ed29 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -72,7 +72,7 @@ class Product extends CommonObject public $fk_element = 'fk_product'; /** - * @var Product + * @var static */ public $oldcopy; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index a1ab7ab07f7..36b6dfd78d0 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -128,7 +128,7 @@ class Dolresource extends CommonObject public $cache_code_type_resource; /** - * @var Dolresource Clone of object before changing it + * @var static Clone of object before changing it */ public $oldcopy; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 4723d7085bd..aecf5211359 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -145,7 +145,7 @@ class Societe extends CommonObject public $restrictiononfksoc = 1; /** - * @var Societe To store a cloned copy of object before to edit it and keep track of old properties + * @var static To store a cloned copy of object before to edit it and keep track of old properties */ public $oldcopy; @@ -2498,11 +2498,11 @@ class Societe extends CommonObject /** * Returns amount of included taxes of the current discounts/credits available from the company * - * @param ?User $user Filter on a user author of discounts - * @param string $filter Other filter - * @param integer $maxvalue Filter on max value for discount - * @param int $discount_type 0 => customer discount, 1 => supplier discount - * @return int Return integer <0 if KO, Credit note amount otherwise + * @param ?User $user Filter on a user author of discounts + * @param string $filter Other filter + * @param int $maxvalue Filter on max value for discount + * @param int<0,1> $discount_type 0 => customer discount, 1 => supplier discount + * @return float|int<-1,-1> Return integer <0 if KO, Credit note amount otherwise */ public function getAvailableDiscounts($user = null, $filter = '', $maxvalue = 0, $discount_type = 0) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 70aba99dcea..6f01756cb16 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -269,7 +269,7 @@ class Ticket extends CommonObject public $ip; /** - * @var Ticket $oldcopy State of this ticket as it was stored before an update operation (for triggers) + * @var static $oldcopy State of this ticket as it was stored before an update operation (for triggers) */ public $oldcopy; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ab8cf4b6ae0..58b7ff20d31 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -84,7 +84,7 @@ class User extends CommonObject public $id = 0; /** - * @var User old copy of User + * @var static old copy of User */ public $oldcopy; From b871aa98e84d73d42dc3d9c760c045b38cd66511 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 18:34:21 +0100 Subject: [PATCH 180/315] Reset Product->id to 0, not to null --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 478f9641615..a9a7923b3c2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -923,7 +923,7 @@ if (empty($reshook)) { // We use native clone to keep this->db valid and allow to use later all the methods of object. $clone = dol_clone($object, 1); - $clone->id = null; + $clone->id = 0; $clone->ref = GETPOST('clone_ref', 'alphanohtml'); $clone->status = 0; $clone->status_buy = 0; From 1560ba2603d5f599db5f0be8fe569562a686c888 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 18:47:36 +0100 Subject: [PATCH 181/315] Fix use $rssparser, not undefined $rss --- htdocs/admin/external_rss.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 5d3228ae23a..5781b810489 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * 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 @@ -280,7 +281,7 @@ if ($resql) { print ''; print "".$langs->trans("Status").""; print ""; - if ($result > 0 && empty($rss->error)) { + if ($result > 0 && empty($rssparser->error)) { print ''.$langs->trans("Online").'
    '; } else { print ''.$langs->trans("Offline"); From cb7e8f08d15cfd072e36936433a18671b79f486d Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 19:51:11 +0100 Subject: [PATCH 182/315] Fix typo $obp -> $objp # Fix typo $obp -> $objp Fix typo resulting in null var --- htdocs/ticket/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 14e0ab382d8..76d3b9e9dce 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2016 Jean-François FERRY * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021-2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 ($user->hasRight('ticket', 'read')) { // Category print ''; - if (!empty($obp->category_code)) { + if (!empty($objp->category_code)) { $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$objp->category_code, 'c_ticket_category', 'code', 'label', $objp->category_code); print ''.$s.''; } From 535d9de357a0693edae40bce924b29e5214c4c13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Mar 2024 20:58:48 +0100 Subject: [PATCH 183/315] Translation --- dev/translation/dynamic_translation_keys.lst | 1 + htdocs/langs/en_US/website.lang | 5 +++-- htdocs/langs/fr_FR/website.lang | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dev/translation/dynamic_translation_keys.lst b/dev/translation/dynamic_translation_keys.lst index 41220044fe9..b66526bd241 100644 --- a/dev/translation/dynamic_translation_keys.lst +++ b/dev/translation/dynamic_translation_keys.lst @@ -437,6 +437,7 @@ CardContent CardProduct0 CardProduct1 Cards +Cart CashAccounts CashDeskBankCB CashDeskBankCash diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index a1543ba61f5..5676ed45400 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -162,7 +162,7 @@ AssignedContacts=Assigned contacts WebsiteTypeLabel=Type of Web site WebsiteTypeDolibarrWebsite=Web site (Module WebSites CMS) WebsiteTypeDolibarrPortal=Native and ready to use web portal (Module Web Portal) -WebPortalURL=Web portal URL +WebPortalURL=Web portal URL NewWebsiteAccount=New accounts for websites ModuleWebPortalName=Web portal ModuleWebPortalDesc=A ready to use native web portal for customers, suppliers, partners or members @@ -235,4 +235,5 @@ WebPortalPartnership=Partnership WebPortalPropal=Proposal WebPortalGroupMenuAdmin=Administration WebPortalGroupMenuTechnical=System -PreviewPageContent=Page content +PreviewPageContent=Page content +Cart=Cart diff --git a/htdocs/langs/fr_FR/website.lang b/htdocs/langs/fr_FR/website.lang index 5dc984ebce6..6771817e37e 100644 --- a/htdocs/langs/fr_FR/website.lang +++ b/htdocs/langs/fr_FR/website.lang @@ -235,3 +235,4 @@ WebPortalPartnership=Partenariat WebPortalPropal=Proposition WebPortalGroupMenuAdmin=Administration WebPortalGroupMenuTechnical=Système +Cart=Panier From b7f420d5bd6e0e74e77a4c5ca84e874aa24e2b35 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 29 Mar 2024 20:25:28 +0100 Subject: [PATCH 184/315] Fix phan notices by adding phan typing --- htdocs/theme/eldy/global.inc.php | 74 +++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 0d2f314b5a3..5042a1afccf 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2,6 +2,7 @@ /* /* Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -27,6 +28,59 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { $leftmenuwidth = 210; +' +@phan-var-force string $badgeDanger +@phan-var-force string $badgeWarning +@phan-var-force string $borderwidth +@phan-var-force string $colorbackbody +@phan-var-force string $colorbackhmenu1 +@phan-var-force string $colorbacklinebreak +@phan-var-force string $colorbacklineimpair1 +@phan-var-force string $colorbacklineimpair2 +@phan-var-force string $colorbacklinepair1 +@phan-var-force string $colorbacklinepair2 +@phan-var-force string $colorbacklinepairchecked +@phan-var-force string $colorbacklinepairhover +@phan-var-force string $colorbacktabactive +@phan-var-force string $colorbacktabcard1 +@phan-var-force string $colorbacktitle1 +@phan-var-force string $colorbackvmenu1 +@phan-var-force string $colorblind_deuteranopes_textSuccess +@phan-var-force string $colorblind_deuteranopes_textWarning +@phan-var-force string $colorshadowtitle +@phan-var-force string $colortext +@phan-var-force string $colortextbackhmenu +@phan-var-force string $colortextbacktab +@phan-var-force string $colortextbackvmenu +@phan-var-force string $colortextlink +@phan-var-force string $colortexttitle +@phan-var-force string $colortexttitlelink +@phan-var-force string $colortexttitlenotab +@phan-var-force string $colortexttitlenotab2 +@phan-var-force string $colortopbordertitle1 +@phan-var-force int<0,1> $disableimages +@phan-var-force int<0,1> $dol_optimize_smallscreen +@phan-var-force string $fontlist +@phan-var-force string $fontsize +@phan-var-force int $heightmenu +@phan-var-force string $heightrow +@phan-var-force string $img_button +@phan-var-force string $left +@phan-var-force string $maxwidthloginblock +@phan-var-force int $minwidthtmenu +@phan-var-force int $nbtopmenuentries +@phan-var-force int $nbtopmenuentriesreal +@phan-var-force string $path +@phan-var-force string $right +@phan-var-force string $textDanger +@phan-var-force string $textSuccess +@phan-var-force string $textWarning +@phan-var-force string $toolTipBgColor +@phan-var-force string $toolTipFontColor +@phan-var-force int<0,1> $useboldtitle +@phan-var-force int $userborderontable +'; + ?> /*