From 61bf0aad7400edb8b0fbeef4da9d820b14a7d137 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 2 Nov 2023 15:46:41 +0100 Subject: [PATCH 001/315] FIX darkmode for public subscription page --- htdocs/theme/eldy/global.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5fbbecbc727..b6bdb45c8a7 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4966,7 +4966,7 @@ table.table-fiche-title { } -div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; } +div.backgreypublicpayment { background-color: var(--colorbackbody); padding: 20px; border-bottom: 1px solid #ddd; } .backgreypublicpayment a { color: #222 !important; } .poweredbypublicpayment { float: right; @@ -7167,12 +7167,12 @@ div.tabsElem a.tab { border: 1px solid #e8e8e8; padding: 30px; border-radius: 8px; - background-color: #f8f8f8; + background-color: var(--colorbackgrey); /*box-shadow: 2px 2px 10px #ddd;*/ } .publicnewmemberform #tablesubscribe { - color: #666; + color: var(--colortextbackvmenu); } @media only screen and (max-width: 767px) From a3fa8b82fa861afc023ceda406cd2edb37a2bb27 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 9 Nov 2023 17:04:13 +0100 Subject: [PATCH 002/315] FIX: more correctly parse the select part to be replaced in sql queries --- htdocs/comm/action/list.php | 2 +- htdocs/compta/facture/list.php | 4 ++-- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/ticket/list.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index e2b412e15db..74055477e78 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -563,7 +563,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index da2599dcee2..e2ec217e4a8 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -851,9 +851,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { */ /* The fast and low memory method to get and count full list converts the sql into a sql count */ if ($sall || $search_product_category > 0 || $search_user > 0) { - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql); } else { - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql); $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid/', '', $sqlforcount); } $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 5d4ae896134..aba2e44976f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -369,7 +369,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index f5d74c47c8e..b230dba10b0 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -585,7 +585,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 74abbad9140..6df36351c53 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -294,7 +294,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index d80d44813e0..fe7987f85b3 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -454,7 +454,7 @@ $sql .= $hookmanager->resPrint; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; From 0ca99264a679e21d6dc2a1651f8dbf5b73933755 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 12 Nov 2023 18:02:04 +0100 Subject: [PATCH 003/315] grey in bright mode --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index b6bdb45c8a7..7bf741c9ecc 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4966,7 +4966,7 @@ table.table-fiche-title { } -div.backgreypublicpayment { background-color: var(--colorbackbody); padding: 20px; border-bottom: 1px solid #ddd; } +div.backgreypublicpayment { background-color: var(--colorbacktitle1); padding: 20px; border-bottom: 1px solid #ddd; } .backgreypublicpayment a { color: #222 !important; } .poweredbypublicpayment { float: right; From a258d4193b1b174b70e1796bb124f99f8addaa24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:43:26 +0100 Subject: [PATCH 004/315] FIX : Cleaning code --- htdocs/product/fournisseurs.php | 80 ++++++++++++++++----------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 95a98ebc2d3..36e49d8baa5 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -719,52 +719,50 @@ if ($id > 0 || $ref) { } } $currencies = json_encode($currencies); + print " + "; - var currencies_array = $currencies; - $('select[name="multicurrency_code"]').change(function () { - console.log("We change the currency"); - $('input[name="multicurrency_tx"]').val(currencies_array[$(this).val()]); - update_price_from_multicurrency(); - }); - }); - -END; } else { // Price qty min print ''.$langs->trans("PriceQtyMin").''; From 786ea1029ed07170c3a360f7fc1a7796532282a0 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Sat, 18 Nov 2023 12:40:10 +0100 Subject: [PATCH 005/315] FIX: more correctly parse the select part to be replaced in sql queries, part 2 --- htdocs/comm/action/list.php | 23 ++++++++++++------ htdocs/compta/facture/list.php | 24 ++++++++++++------- .../modulebuilder/template/myobject_list.php | 23 ++++++++++++------ htdocs/product/stock/movement_list.php | 23 ++++++++++++------ htdocs/product/stock/productlot_list.php | 23 ++++++++++++------ htdocs/ticket/list.php | 23 ++++++++++++------ 6 files changed, 96 insertions(+), 43 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 74055477e78..1482412e3cd 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -417,6 +417,8 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$sqlfields = $sql; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object)"; if (empty($user->rights->societe->client->voir) && !$socid) { @@ -563,15 +565,22 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; + + if (!$resql) { + dol_print_error($db); + } else { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } - $db->free($resql); } // Complete request and execute it with limit diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e2ec217e4a8..3a814081554 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -586,6 +586,9 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; + +$sqlfields = $sql; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; @@ -851,22 +854,27 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { */ /* The fast and low memory method to get and count full list converts the sql into a sql count */ if ($sall || $search_product_category > 0 || $search_user > 0) { - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords', $sql); } else { - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT( f.rowid) as nbtotalofrecords', $sql); $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid/', '', $sqlforcount); } $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; + if (! $resql) { + dol_print_error($db); + } else { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } - $db->free($resql); } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index aba2e44976f..a2ae5eab08c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -278,6 +278,9 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -369,15 +372,21 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; + + if (!$resql) { + dol_print_error($db); + } else { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } - $db->free($resql); } // Complete request and execute it with limit diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index b230dba10b0..2534b381655 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -500,6 +500,9 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; + +$sqlfields = $sql; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; @@ -585,15 +588,21 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; + + if (! $resql) { + dol_print_error($db); + } else { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } - $db->free($resql); } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 6df36351c53..d40feaa4436 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -215,6 +215,9 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if ( !empty($extrafields->attributes[$object->table_element]['label']) && ($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -294,15 +297,21 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; + + if (!$resql) { + dol_print_error($db); + } else { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } - $db->free($resql); } // Complete request and execute it with limit diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index fe7987f85b3..8bd759928ae 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -355,6 +355,9 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -454,15 +457,21 @@ $sql .= $hookmanager->resPrint; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; + + if (! $resql) { + dol_print_error($db); + } else { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } - $db->free($resql); } // Complete request and execute it with limit From 9bbd285c3a800111ae793f4791f8c1816a016e18 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 2 Dec 2023 15:53:22 +0100 Subject: [PATCH 006/315] fix: feature MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS was broken --- htdocs/core/class/CMailFile.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index d05854d3435..166ae74e28f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -268,7 +268,7 @@ class CMailFile if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) { // Search into the body for amount = price2num($this->solde); + $accline->amount = price2num($balance); $accline->fk_user_author = $user->id; $accline->fk_account = $this->id; $accline->datev = $this->db->idate($this->date_solde); From b53420e64e9846480eb035370981e166fb8d8cd3 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 6 Dec 2023 15:17:29 +0100 Subject: [PATCH 009/315] Refactored & adjusted page head width --- .../supplier_order/doc/pdf_cornas.modules.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 0d2a2f902da..c5d858c9f9e 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1252,7 +1252,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posx = $this->page_largeur - $this->marge_droite - 100; + $w = 110; + + $posx = $this->page_largeur - $this->marge_droite - $w; $posy = $this->marge_haute; $pdf->SetXY($this->marge_gauche, $posy); @@ -1275,12 +1277,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders } else { $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection); } } @@ -1288,7 +1290,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); - $pdf->MultiCell(100, 3, $title, '', 'R'); + $pdf->MultiCell($w, 3, $title, '', 'R'); $posy += 1; if ($object->ref_supplier) { @@ -1296,7 +1298,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', 'B', $default_font_size); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); $posy += 1; } @@ -1320,7 +1322,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } @@ -1328,12 +1330,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); } else { $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(255, 0, 0); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); } $pdf->SetTextColor(0, 0, 60); @@ -1351,7 +1353,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); } // Get contact @@ -1363,7 +1365,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); + $pdf->MultiCell($w, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); } } From f74073f1a3baed7558038b48c43414a40917cca4 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 6 Dec 2023 15:18:25 +0100 Subject: [PATCH 010/315] Added contributor details --- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index c5d858c9f9e..81bcc4d824c 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2023 William Mead * * 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 From bcdb567dd75a592483df6965481cdc5b86aef222 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 6 Dec 2023 16:47:44 +0100 Subject: [PATCH 011/315] Fix PHP7.0 incompatibility (void is introduced in 7.1) --- htdocs/bom/class/api_boms.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 52e6fe90501..2147f7be1ba 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -546,7 +546,7 @@ class Boms extends DolibarrApi * * @return void */ - private function checkRefNumbering(): void + private function checkRefNumbering() { $ref = substr($this->bom->ref, 1, 4); if ($this->bom->status > 0 && $ref == 'PROV') { From 5ced139e3b97679b71db95913b6c298535aad077 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Wed, 6 Dec 2023 17:51:43 +0100 Subject: [PATCH 012/315] FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming --- htdocs/fourn/class/fournisseur.facture.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b60dc531325..75874fbb86a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1872,19 +1872,18 @@ class FactureFournisseur extends CommonInvoice // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); $dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$oldref; - $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref; + $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->newref; if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + // Rename docs starting with $oldref with $this->newref + $listoffiles = dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->newref, 'files', 1, '^'.preg_quote($oldref, '/')); foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $this->newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); From 0756bb5e5d67f5adfa808ca5d57dc4521cd2bc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Wed, 6 Dec 2023 22:44:06 +0100 Subject: [PATCH 013/315] Update fournisseurs.php --- htdocs/product/fournisseurs.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 36e49d8baa5..4c438bc67c3 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -762,7 +762,6 @@ if ($id > 0 || $ref) { }); }); "; - } else { // Price qty min print ''.$langs->trans("PriceQtyMin").''; From c10c419bf6a6e77691301c2f7499a046bbfb6680 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Thu, 7 Dec 2023 09:08:33 +0100 Subject: [PATCH 014/315] fix output --- htdocs/bom/tpl/linkedobjectblock.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index 1765e9a84c1..a5fcfe30acb 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -62,7 +62,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $product_static->getNomUrl(1); } print ''; - echo ''.dol_print_date($objectlink->date_creation, 'day').''; + echo ''.dol_print_date($objectlink->date_creation, 'day').''; echo ''; if ($user->rights->commande->lire) { $total = $total + $objectlink->total_ht; From ea7afeb00735b959d0e6fc1493afa20d7b17f2b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Dec 2023 16:16:22 +0100 Subject: [PATCH 015/315] Fix warning --- htdocs/compta/bank/class/account.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 70f03bc21c8..cf5cabdddf3 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -219,6 +219,20 @@ class Account extends CommonObject */ public $date_solde; + /** + * Balance. Used in Account::create + * @var float + * @deprecated + * @see $balance + */ + public $solde; + + /** + * Balance. Used in Account::create + * @var float + */ + public $balance; + /** * Creditor Identifier CI. Some banks use different ICS for direct debit and bank tranfer * @var string From 9aa1b32c07c0b933eecee950e66dbbebfdcb18dd Mon Sep 17 00:00:00 2001 From: tnegre Date: Mon, 11 Dec 2023 09:52:40 +0100 Subject: [PATCH 016/315] Manage ref_alias for fetch societe --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c61d61b922d..fed0a7a4af0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1729,7 +1729,7 @@ class Societe extends CommonObject global $langs; global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($barcode) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) { + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($barcode) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email) && empty($ref_alias)) { return -1; } From 77a22ea78ef96418c0493632c7a37540f674bd25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Dec 2023 15:01:23 +0100 Subject: [PATCH 017/315] Fix table was renamed --- dev/initdata/purge-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php index d75c9fae8b2..a10ecad1a65 100755 --- a/dev/initdata/purge-data.php +++ b/dev/initdata/purge-data.php @@ -149,7 +149,7 @@ $sqls=array( ), 'project'=>array( // TODO set fk_project to null on object that refer to project - "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))", + "DELETE FROM ".MAIN_DB_PREFIX."llx_element_time WHERE elementtype = 'task' AND fk_element IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))", "DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')", "DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'", ), From 2c23b8db036b87e5813ab9070b691da9bf879147 Mon Sep 17 00:00:00 2001 From: Jonathan Lescaut Date: Tue, 12 Dec 2023 15:11:04 +0100 Subject: [PATCH 018/315] add trad menu left recuitment --- htdocs/langs/en_US/recruitment.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index 686722a48c5..6cdf6cf41b3 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -77,3 +77,4 @@ ExtrafieldsApplication=Complementary attributes (job applications) MakeOffer=Make an offer WeAreRecruiting=We are recruiting. This is a list of open positions to be filled... NoPositionOpen=No positions open at the moment +recruitment=Recruitment \ No newline at end of file From de7d7d8d665033547bfee626f674765fd59a0b5e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Dec 2023 08:50:33 +0100 Subject: [PATCH 019/315] FIX: backport SQL error on global search product --- htdocs/product/list.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 8507026d302..9530bfd3189 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -168,10 +168,10 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'p.ref'=>"Ref", - 'pfp.ref_fourn'=>"RefSupplier", 'p.label'=>"ProductLabel", 'p.description'=>"Description", "p.note"=>"Note", + 'pfp.ref_fourn'=>"RefSupplier", ); // multilang @@ -457,7 +457,21 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); + // Clean $fieldstosearchall + $newfieldstosearchall = $fieldstosearchall; + unset($newfieldstosearchall['pfp.ref_fourn']); + unset($newfieldstosearchall['pfp.barcode']); + + $sql .= ' AND ('; + $sql .= natural_search(array_keys($newfieldstosearchall), $sall, 0, 1); + // Search also into a supplier reference 'pfp.ref_fourn'="RefSupplier" + $sql .= ' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid'; + $sql .= ' AND ('.natural_search('pfp.ref_fourn', $sall, 0, 1); + if (isModEnabled('barcode')) { + // Search also into a supplier barcode 'pfp.barcode'='GencodBuyPrice'; + $sql .= ' OR '.natural_search('pfp.barcode', $sall, 0, 1); + } + $sql .= ')))'; } // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($search_type) && $search_type != '-1') { From ab7b9820d4522d1a9285e77a42a993a8a6f51b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Dec 2023 09:34:25 +0100 Subject: [PATCH 020/315] fix error message --- htdocs/fourn/class/api_supplier_invoices.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index a531667d0e5..2e0efede12c 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -228,7 +228,7 @@ class SupplierInvoices extends DolibarrApi } if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors)); + throw new RestException(500, "Error creating invoice ", array_merge(array($this->invoice->error), $this->invoice->errors)); } return $this->invoice->id; } From bc048cac660b3bdbfc855b209f84a8654fb3e667 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Dec 2023 09:37:45 +0100 Subject: [PATCH 021/315] fix: MAIN_AGENDA_EXPORT_PAST_DELAY is defaulted to 0 to 'not isset' is always false --- htdocs/public/agenda/agendaexport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index e8d9f986f91..a65c9347fe3 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -89,7 +89,7 @@ if (empty($conf->agenda->enabled)) { } // Not older than -if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) { +if (empty($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) { $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; // default limit } From 82c49e62d18fdeb1fe9a61cf8122ee478ec7615b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Dec 2023 11:31:42 +0100 Subject: [PATCH 022/315] add unit test for image in email with src=../media/ or src=base64 --- htdocs/core/class/CMailFile.class.php | 15 ++- test/phpunit/CMailFileTest.php | 182 +++++++++++++++++--------- 2 files changed, 134 insertions(+), 63 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 166ae74e28f..cf4a893fee0 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -263,12 +263,23 @@ class CMailFile // This convert an embedd file with src="/viewimage.php?modulepart... into a cid link // TODO Exclude viewimage used for the read tracker ? $findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias'); + if ($findimg<0) { + dol_syslog("CMailFile::CMailfile: Error on findHtmlImages"); + $this->error = 'ErrorInAddAttachementsImageBAseOnMedia'; + return; + } } if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) { // Search into the body for error = 'ErrorInAddAttachementsImageBAseOnMedia'; + return; + } + $findimg += $resultImageData; } // Set atleastoneimage if there is at least one embedded file (into ->html_images) @@ -1847,7 +1858,7 @@ class CMailFile // We search (into mail body this->html), if we find some strings like "... file=xxx.img" // For example when: - // + // $matches = array(); preg_match_all('/src="data:image\/('.implode('|', $extensions).');base64,([^"]+)"/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 729aa4b4c7f..9d270901dc2 100644 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -23,18 +23,19 @@ * \remarks To run this script as CLI: phpunit filename.php */ -global $conf,$user,$langs,$db; +global $conf, $user, $langs, $db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/class/CMailFile.class.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; $user->fetch(1); $user->getrights(); } -$conf->global->MAIN_DISABLE_ALL_MAILS=1; +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; /** @@ -42,7 +43,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; * * @backupGlobals disabled * @backupStaticAttributes enabled - * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. */ class CMailFileTest extends PHPUnit\Framework\TestCase { @@ -62,13 +63,13 @@ class CMailFileTest extends PHPUnit\Framework\TestCase parent::__construct(); //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + global $conf, $user, $langs, $db; + $this->savconf = $conf; + $this->savuser = $user; + $this->savlangs = $langs; + $this->savdb = $db; - print __METHOD__." db->type=".$db->type." user->id=".$user->id; + print __METHOD__ . " db->type=" . $db->type . " user->id=" . $user->id; //print " - db ".$db->db; print "\n"; } @@ -80,23 +81,23 @@ class CMailFileTest extends PHPUnit\Framework\TestCase */ public static function setUpBeforeClass(): void { - global $conf,$user,$langs,$db; + global $conf, $user, $langs, $db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__ . "\n"; } /** * tearDownAfterClass * - * @return void + * @return void */ public static function tearDownAfterClass(): void { - global $conf,$user,$langs,$db; + global $conf, $user, $langs, $db; $db->rollback(); - print __METHOD__."\n"; + print __METHOD__ . "\n"; } /** @@ -106,24 +107,25 @@ class CMailFileTest extends PHPUnit\Framework\TestCase */ protected function setUp(): void { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf, $user, $langs, $db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; - $conf->global->MAIN_DISABLE_ALL_MAILS=1; // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why. + $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why. - print __METHOD__."\n"; + print __METHOD__ . "\n"; } + /** * End phpunit tests * - * @return void + * @return void */ protected function tearDown(): void { - print __METHOD__."\n"; + print __METHOD__ . "\n"; } /** @@ -133,16 +135,16 @@ class CMailFileTest extends PHPUnit\Framework\TestCase */ public function testCMailFileText() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf, $user, $langs, $db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; - $localobject=new CMailFile('Test', 'test@test.com', 'from@from.com', 'Message txt', array(), array(), array(), '', '', 1, 0); + $localobject = new CMailFile('Test', 'test@test.com', 'from@from.com', 'Message txt', array(), array(), array(), '', '', 1, 0); - $result=$localobject->sendfile(); - print __METHOD__." result=".$result."\n"; + $result = $localobject->sendfile(); + print __METHOD__ . " result=" . $result . "\n"; $this->assertFalse($result); // False because mail send disabled return $result; @@ -155,54 +157,112 @@ class CMailFileTest extends PHPUnit\Framework\TestCase */ public function testCMailFileStatic() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf, $user, $langs, $db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; - $localobject=new CMailFile('', '', '', ''); + $localobject = new CMailFile('', '', '', ''); - $src='John Doe '; - $result=$localobject->getValidAddress($src, 0); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe '; + $result = $localobject->getValidAddress($src, 0); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, 'John Doe '); - $src='John Doe '; - $result=$localobject->getValidAddress($src, 1); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe '; + $result = $localobject->getValidAddress($src, 1); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, ''); - $src='John Doe '; - $result=$localobject->getValidAddress($src, 2); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe '; + $result = $localobject->getValidAddress($src, 2); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, 'john@doe.com'); - $src='John Doe '; - $result=$localobject->getValidAddress($src, 3, 0); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe '; + $result = $localobject->getValidAddress($src, 3, 0); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, '"John Doe" '); - $src='John Doe '; - $result=$localobject->getValidAddress($src, 3, 1); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe '; + $result = $localobject->getValidAddress($src, 3, 1); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, '"=?UTF-8?B?Sm9obiBEb2U=?=" '); - $src='John Doe '; - $result=$localobject->getValidAddress($src, 4); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe '; + $result = $localobject->getValidAddress($src, 4); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, 'John Doe'); - $src='John Doe , John Doe2 , John Doe3 '; - $result=$localobject->getValidAddress($src, 4); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe , John Doe2 , John Doe3 '; + $result = $localobject->getValidAddress($src, 4); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, 'John Doe,John Doe2,John Doe3'); - $src='John Doe , John Doe2 , John Doe3 '; - $result=$localobject->getValidAddress($src, 4, 0, 2); - print __METHOD__." result=".$result."\n"; + $src = 'John Doe , John Doe2 , John Doe3 '; + $result = $localobject->getValidAddress($src, 4, 0, 2); + print __METHOD__ . " result=" . $result . "\n"; $this->assertEquals($result, 'John Doe,John Doe2...'); return $result; } + + public function testCMailFileHTMLWithImage() + { + + global $conf, $user, $langs, $db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; + $conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS = 1; + $conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1; + + dol_delete_dir_recursive(DOL_DATA_ROOT . '/medias/image'); + dol_mkdir(DOL_DATA_ROOT . '/medias/image'); + dol_copy(dirname(__FILE__) . '/img250x20.png', DOL_DATA_ROOT . '/medias/image/img250x20.png'); + + $msg = ''; + $msg .= ''; + $msg .= '

From wikipedia

Red dot'; + $msg .= ''; + + + $localobject = new CMailFile('Test', 'test@test.com', 'from@from.com', $msg, array(), array(), array(), '', '', 0, -1,'','','','','standard','','/tmp'); + + $result = count($localobject->html_images); + print __METHOD__ . " result count image detected in the mail=" . $result . "\n"; + $this->assertEquals($result, 2); + + + foreach ($localobject->html_images as $i => $val) + if ($localobject->html_images[$i]) { + if ($localobject->html_images[$i]['type'] == 'cidfromdata') { + if (preg_match('/img250x20\.png/i',$localobject->html_images[$i]['fullpath'])) { + print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); + + print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl'); + + $fileSize=9744; + print __METHOD__ . " File size must be =" . $fileSize . "\n"; + $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); + } elseif (preg_match('/\.png/i',$localobject->html_images[$i]['fullpath'])) { + print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); + + print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata'); + + $fileSize=85; + print __METHOD__ . " File size must be =" . $fileSize . "\n"; + $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); + } + } + } + + return $result; + } } From 6bb952bf9a98aa427a8772b3af26a4520e360fd9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Dec 2023 11:32:48 +0100 Subject: [PATCH 023/315] typo --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index cf4a893fee0..7c0a7c400ad 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -265,7 +265,7 @@ class CMailFile $findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias'); if ($findimg<0) { dol_syslog("CMailFile::CMailfile: Error on findHtmlImages"); - $this->error = 'ErrorInAddAttachementsImageBAseOnMedia'; + $this->error = 'ErrorInAddAttachementsImageBaseOnMedia'; return; } } From 67ad440381f4fb6996211efefefde65021b7ed2e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Dec 2023 11:33:18 +0100 Subject: [PATCH 024/315] typo --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 7c0a7c400ad..7b0af81a62c 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -276,7 +276,7 @@ class CMailFile $resultImageData = $this->findHtmlImagesIsSrcData($upload_dir_tmp); if ($resultImageData<0) { dol_syslog("CMailFile::CMailfile: Error on findHtmlImagesInSrcData"); - $this->error = 'ErrorInAddAttachementsImageBAseOnMedia'; + $this->error = 'ErrorInAddAttachementsImageBaseOnMedia'; return; } $findimg += $resultImageData; From 8be0970a0c04622846643d174f793606e801df14 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Dec 2023 11:47:25 +0100 Subject: [PATCH 025/315] review test --- test/phpunit/CMailFileTest.php | 42 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 9d270901dc2..96d6e195b41 100644 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -26,9 +26,9 @@ global $conf, $user, $langs, $db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //require_once 'PHPUnit/Autoload.php'; -require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -require_once dirname(__FILE__).'/../../htdocs/core/class/CMailFile.class.php'; -require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; +require_once dirname(__FILE__) . '/../../htdocs/master.inc.php'; +require_once dirname(__FILE__) . '/../../htdocs/core/class/CMailFile.class.php'; +require_once dirname(__FILE__) . '/../../htdocs/core/lib/files.lib.php'; if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; @@ -229,7 +229,7 @@ class CMailFileTest extends PHPUnit\Framework\TestCase $msg .= ''; - $localobject = new CMailFile('Test', 'test@test.com', 'from@from.com', $msg, array(), array(), array(), '', '', 0, -1,'','','','','standard','','/tmp'); + $localobject = new CMailFile('Test', 'test@test.com', 'from@from.com', $msg, array(), array(), array(), '', '', 0, -1, '', '', '', '', 'standard', '', '/tmp'); $result = count($localobject->html_images); print __METHOD__ . " result count image detected in the mail=" . $result . "\n"; @@ -238,28 +238,26 @@ class CMailFileTest extends PHPUnit\Framework\TestCase foreach ($localobject->html_images as $i => $val) if ($localobject->html_images[$i]) { - if ($localobject->html_images[$i]['type'] == 'cidfromdata') { - if (preg_match('/img250x20\.png/i',$localobject->html_images[$i]['fullpath'])) { - print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); + if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) { + print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); - print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl'); + print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl'); - $fileSize=9744; - print __METHOD__ . " File size must be =" . $fileSize . "\n"; - $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); - } elseif (preg_match('/\.png/i',$localobject->html_images[$i]['fullpath'])) { - print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); + $fileSize = 9744; + print __METHOD__ . " File size must be =" . $fileSize . "\n"; + $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); + } elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) { + print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); - print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata'); + print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata'); - $fileSize=85; - print __METHOD__ . " File size must be =" . $fileSize . "\n"; - $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); - } + $fileSize = 85; + print __METHOD__ . " File size must be =" . $fileSize . "\n"; + $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); } } From ddf960e1c4c5fac760acfeb92cebe9fb2fdd740b Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 13 Dec 2023 14:32:58 +0100 Subject: [PATCH 026/315] Add contact to project and tasks : formconfirm get url too long --- htdocs/projet/contact.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index be130572704..e7b18c749ce 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -126,7 +126,7 @@ if ($action == 'addcontact') { $formquestion[] = array('type'=> 'other', 'name'=>'tasksavailable', 'label'=>'', 'value' => ''); } - $formconfirmtoaddtasks = $form->formconfirm($_SERVER['PHP_SELF'] . $url_redirect, $text, '', 'addcontact_confirm', $formquestion, '', 1, 300, 590); + $formconfirmtoaddtasks = $form->formconfirm($_SERVER['PHP_SELF'] . $url_redirect, $text, '', 'addcontact_confirm', $formquestion, '', ((count($formquestion) > 10) ? 0 : 1), 300, 590); $formconfirmtoaddtasks .=' - - -
-

-
'.$this->serviceName.'
- -
'; - return $b; - } - - /** - * serialize the parsed wsdl - * - * @param mixed $debug whether to put debug=1 in endpoint URL - * @return string serialization of WSDL - * @access public - */ - function serialize($debug = 0) - { - $xml = ''; - $xml .= "\nnamespaces as $k => $v) { - $xml .= " xmlns:$k=\"$v\""; - } - // 10.9.02 - add poulter fix for wsdl and tns declarations - if (isset($this->namespaces['wsdl'])) { - $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\""; - } - if (isset($this->namespaces['tns'])) { - $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\""; - } - $xml .= '>'; - // imports - if (sizeof($this->import) > 0) { - foreach($this->import as $ns => $list) { - foreach ($list as $ii) { - if ($ii['location'] != '') { - $xml .= ''; - } else { - $xml .= ''; - } - } - } - } - // types - if (count($this->schemas)>=1) { - $xml .= "\n\n"; - foreach ($this->schemas as $ns => $list) { - foreach ($list as $xs) { - $xml .= $xs->serializeSchema(); - } - } - $xml .= ''; - } - // messages - if (count($this->messages) >= 1) { - foreach($this->messages as $msgName => $msgParts) { - $xml .= "\n'; - if(is_array($msgParts)){ - foreach($msgParts as $partName => $partType) { - // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'
'; - if (strpos($partType, ':')) { - $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); - } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) { - // print 'checking typemap: '.$this->XMLSchemaVersion.'
'; - $typePrefix = 'xsd'; - } else { - foreach($this->typemap as $ns => $types) { - if (isset($types[$partType])) { - $typePrefix = $this->getPrefixFromNamespace($ns); - } - } - if (!isset($typePrefix)) { - die("$partType has no namespace!"); - } - } - $ns = $this->getNamespaceFromPrefix($typePrefix); - $localPart = $this->getLocalPart($partType); - $typeDef = $this->getTypeDef($localPart, $ns); - if ($typeDef['typeClass'] == 'element') { - $elementortype = 'element'; - if (substr($localPart, -1) == '^') { - $localPart = substr($localPart, 0, -1); - } - } else { - $elementortype = 'type'; - } - $xml .= "\n" . ' '; - } - } - $xml .= '
'; - } - } - // bindings & porttypes - if (count($this->bindings) >= 1) { - $binding_xml = ''; - $portType_xml = ''; - foreach($this->bindings as $bindingName => $attrs) { - $binding_xml .= "\n'; - $binding_xml .= "\n" . ' '; - $portType_xml .= "\n'; - foreach($attrs['operations'] as $opName => $opParts) { - $binding_xml .= "\n" . ' '; - $binding_xml .= "\n" . ' '; - if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') { - $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"'; - } else { - $enc_style = ''; - } - $binding_xml .= "\n" . ' '; - if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') { - $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"'; - } else { - $enc_style = ''; - } - $binding_xml .= "\n" . ' '; - $binding_xml .= "\n" . ' '; - $portType_xml .= "\n" . ' ' . htmlspecialchars($opParts['documentation']) . ''; - } - $portType_xml .= "\n" . ' '; - $portType_xml .= "\n" . ' '; - $portType_xml .= "\n" . ' '; - } - $portType_xml .= "\n" . ''; - $binding_xml .= "\n" . ''; - } - $xml .= $portType_xml . $binding_xml; - } - // services - $xml .= "\nserviceName . '">'; - if (count($this->ports) >= 1) { - foreach($this->ports as $pName => $attrs) { - $xml .= "\n" . ' '; - $xml .= "\n" . ' '; - $xml .= "\n" . ' '; - } - } - $xml .= "\n" . ''; - return $xml . "\n"; - } - - /** - * determine whether a set of parameters are unwrapped - * when they are expect to be wrapped, Microsoft-style. - * - * @param string $type the type (element name) of the wrapper - * @param array $parameters the parameter values for the SOAP call - * @return boolean whether they parameters are unwrapped (and should be wrapped) - * @access private - */ - function parametersMatchWrapped($type, &$parameters) { - $this->debug("in parametersMatchWrapped type=$type, parameters="); - $this->appendDebug($this->varDump($parameters)); - - // split type into namespace:unqualified-type - if (strpos($type, ':')) { - $uqType = substr($type, strrpos($type, ':') + 1); - $ns = substr($type, 0, strrpos($type, ':')); - $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns"); - if ($this->getNamespaceFromPrefix($ns)) { - $ns = $this->getNamespaceFromPrefix($ns); - $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns"); - } - } else { - // TODO: should the type be compared to types in XSD, and the namespace - // set to XSD if the type matches? - $this->debug("in parametersMatchWrapped: No namespace for type $type"); - $ns = ''; - $uqType = $type; - } - - // get the type information - if (!$typeDef = $this->getTypeDef($uqType, $ns)) { - $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type."); - return false; - } - $this->debug("in parametersMatchWrapped: found typeDef="); - $this->appendDebug($this->varDump($typeDef)); - if (substr($uqType, -1) == '^') { - $uqType = substr($uqType, 0, -1); - } - $phpType = $typeDef['phpType']; - $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''); - $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType"); - - // we expect a complexType or element of complexType - if ($phpType != 'struct') { - $this->debug("in parametersMatchWrapped: not a struct"); - return false; - } - - // see whether the parameter names match the elements - if (isset($typeDef['elements']) && is_array($typeDef['elements'])) { - $elements = 0; - $matches = 0; - foreach ($typeDef['elements'] as $name => $attrs) { - if (isset($parameters[$name])) { - $this->debug("in parametersMatchWrapped: have parameter named $name"); - $matches++; - } else { - $this->debug("in parametersMatchWrapped: do not have parameter named $name"); - } - $elements++; - } - - $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names"); - if ($matches == 0) { - return false; - } - return true; - } - - // since there are no elements for the type, if the user passed no - // parameters, the parameters match wrapped. - $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType"); - return count($parameters) == 0; - } - - /** - * serialize PHP values according to a WSDL message definition - * contrary to the method name, this is not limited to RPC - * - * TODO - * - multi-ref serialization - * - validate PHP values against type definitions, return errors if invalid - * - * @param string $operation operation name - * @param string $direction (input|output) - * @param mixed $parameters parameter value(s) - * @param string $bindingType (soap|soap12) - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) - * @access public - */ - function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') { - $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType"); - $this->appendDebug('parameters=' . $this->varDump($parameters)); - - if ($direction != 'input' && $direction != 'output') { - $this->debug('The value of the \$direction argument needs to be either "input" or "output"'); - $this->setError('The value of the \$direction argument needs to be either "input" or "output"'); - return false; - } - if (!$opData = $this->getOperationData($operation, $bindingType)) { - $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType); - $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType); - return false; - } - $this->debug('in serializeRPCParameters: opData:'); - $this->appendDebug($this->varDump($opData)); - - // Get encoding style for output and set to current - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) { - $encodingStyle = $opData['output']['encodingStyle']; - $enc_style = $encodingStyle; - } - - // set input params - $xml = ''; - if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) { - $parts = &$opData[$direction]['parts']; - $part_count = sizeof($parts); - $style = $opData['style']; - $use = $opData[$direction]['use']; - $this->debug("have $part_count part(s) to serialize using $style/$use"); - if (is_array($parameters)) { - $parametersArrayType = $this->isArraySimpleOrStruct($parameters); - $parameter_count = count($parameters); - $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize"); - // check for Microsoft-style wrapped parameters - if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) { - $this->debug('check whether the caller has wrapped the parameters'); - if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) { - // TODO: consider checking here for double-wrapping, when - // service function wraps, then NuSOAP wraps again - $this->debug("change simple array to associative with 'parameters' element"); - $parameters['parameters'] = $parameters[0]; - unset($parameters[0]); - } - if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) { - $this->debug('check whether caller\'s parameters match the wrapped ones'); - if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) { - $this->debug('wrap the parameters for the caller'); - $parameters = array('parameters' => $parameters); - $parameter_count = 1; - } - } - } - foreach ($parts as $name => $type) { - $this->debug("serializing part $name of type $type"); - // Track encoding style - if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) { - $encodingStyle = $opData[$direction]['encodingStyle']; - $enc_style = $encodingStyle; - } else { - $enc_style = false; - } - // NOTE: add error handling here - // if serializeType returns false, then catch global error and fault - if ($parametersArrayType == 'arraySimple') { - $p = array_shift($parameters); - $this->debug('calling serializeType w/indexed param'); - $xml .= $this->serializeType($name, $type, $p, $use, $enc_style); - } elseif (isset($parameters[$name])) { - $this->debug('calling serializeType w/named param'); - $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style); - } else { - // TODO: only send nillable - $this->debug('calling serializeType w/null param'); - $xml .= $this->serializeType($name, $type, null, $use, $enc_style); - } - } - } else { - $this->debug('no parameters passed.'); - } - } - $this->debug("serializeRPCParameters returning: $xml"); - return $xml; - } - - /** - * serialize a PHP value according to a WSDL message definition - * - * TODO - * - multi-ref serialization - * - validate PHP values against type definitions, return errors if invalid - * - * @param string $operation operation name - * @param string $direction (input|output) - * @param mixed $parameters parameter value(s) - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) - * @access public - * @deprecated - */ - function serializeParameters($operation, $direction, $parameters) - { - $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion"); - $this->appendDebug('parameters=' . $this->varDump($parameters)); - - if ($direction != 'input' && $direction != 'output') { - $this->debug('The value of the \$direction argument needs to be either "input" or "output"'); - $this->setError('The value of the \$direction argument needs to be either "input" or "output"'); - return false; - } - if (!$opData = $this->getOperationData($operation)) { - $this->debug('Unable to retrieve WSDL data for operation: ' . $operation); - $this->setError('Unable to retrieve WSDL data for operation: ' . $operation); - return false; - } - $this->debug('opData:'); - $this->appendDebug($this->varDump($opData)); - - // Get encoding style for output and set to current - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) { - $encodingStyle = $opData['output']['encodingStyle']; - $enc_style = $encodingStyle; - } - - // set input params - $xml = ''; - if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) { - - $use = $opData[$direction]['use']; - $this->debug("use=$use"); - $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)'); - if (is_array($parameters)) { - $parametersArrayType = $this->isArraySimpleOrStruct($parameters); - $this->debug('have ' . $parametersArrayType . ' parameters'); - foreach($opData[$direction]['parts'] as $name => $type) { - $this->debug('serializing part "'.$name.'" of type "'.$type.'"'); - // Track encoding style - if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) { - $encodingStyle = $opData[$direction]['encodingStyle']; - $enc_style = $encodingStyle; - } else { - $enc_style = false; - } - // NOTE: add error handling here - // if serializeType returns false, then catch global error and fault - if ($parametersArrayType == 'arraySimple') { - $p = array_shift($parameters); - $this->debug('calling serializeType w/indexed param'); - $xml .= $this->serializeType($name, $type, $p, $use, $enc_style); - } elseif (isset($parameters[$name])) { - $this->debug('calling serializeType w/named param'); - $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style); - } else { - // TODO: only send nillable - $this->debug('calling serializeType w/null param'); - $xml .= $this->serializeType($name, $type, null, $use, $enc_style); - } - } - } else { - $this->debug('no parameters passed.'); - } - } - $this->debug("serializeParameters returning: $xml"); - return $xml; - } - - /** - * serializes a PHP value according a given type definition - * - * @param string $name name of value (part or element) - * @param string $type XML schema type of value (type or element) - * @param mixed $value a native PHP value (parameter value) - * @param string $use use for part (encoded|literal) - * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) - * @param boolean $unqualified a kludge for what should be XML namespace form handling - * @return string value serialized as an XML string - * @access private - */ - function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false) - { - $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified")); - $this->appendDebug("value=" . $this->varDump($value)); - if($use == 'encoded' && $encodingStyle) { - $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"'; - } - - // if a soapval has been supplied, let its type override the WSDL - if (is_object($value) && get_class($value) == 'soapval') { - if ($value->type_ns) { - $type = $value->type_ns . ':' . $value->type; - $forceType = true; - $this->debug("in serializeType: soapval overrides type to $type"); - } elseif ($value->type) { - $type = $value->type; - $forceType = true; - $this->debug("in serializeType: soapval overrides type to $type"); - } else { - $forceType = false; - $this->debug("in serializeType: soapval does not override type"); - } - $attrs = $value->attributes; - $value = $value->value; - $this->debug("in serializeType: soapval overrides value to $value"); - if ($attrs) { - if (!is_array($value)) { - $value['!'] = $value; - } - foreach ($attrs as $n => $v) { - $value['!' . $n] = $v; - } - $this->debug("in serializeType: soapval provides attributes"); - } - } else { - $forceType = false; - } - - $xml = ''; - if (strpos($type, ':')) { - $uqType = substr($type, strrpos($type, ':') + 1); - $ns = substr($type, 0, strrpos($type, ':')); - $this->debug("in serializeType: got a prefixed type: $uqType, $ns"); - if ($this->getNamespaceFromPrefix($ns)) { - $ns = $this->getNamespaceFromPrefix($ns); - $this->debug("in serializeType: expanded prefixed type: $uqType, $ns"); - } - - if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){ - $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type'); - if ($unqualified && $use == 'literal') { - $elementNS = " xmlns=\"\""; - } else { - $elementNS = ''; - } - if (is_null($value)) { - if ($use == 'literal') { - // TODO: depends on minOccurs - $xml = "<$name$elementNS/>"; - } else { - // TODO: depends on nillable, which should be checked before calling this method - $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; - } - $this->debug("in serializeType: returning: $xml"); - return $xml; - } - if ($uqType == 'Array') { - // JBoss/Axis does this sometimes - return $this->serialize_val($value, $name, false, false, false, false, $use); - } - if ($uqType == 'boolean') { - if ((is_string($value) && $value == 'false') || (! $value)) { - $value = 'false'; - } else { - $value = 'true'; - } - } - if ($uqType == 'string' && gettype($value) == 'string') { - $value = $this->expandEntities($value); - } - if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') { - $value = sprintf("%.0lf", $value); - } - // it's a scalar - // TODO: what about null/nil values? - // check type isn't a custom type extending xmlschema namespace - if (!$this->getTypeDef($uqType, $ns)) { - if ($use == 'literal') { - if ($forceType) { - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value"; - } else { - $xml = "<$name$elementNS>$value"; - } - } else { - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value"; - } - $this->debug("in serializeType: returning: $xml"); - return $xml; - } - $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)'); - } else if ($ns == 'http://xml.apache.org/xml-soap') { - $this->debug('in serializeType: appears to be Apache SOAP type'); - if ($uqType == 'Map') { - $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap'); - if (! $tt_prefix) { - $this->debug('in serializeType: Add namespace for Apache SOAP type'); - $tt_prefix = 'ns' . rand(1000, 9999); - $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap'; - // force this to be added to usedNamespaces - $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap'); - } - $contents = ''; - foreach($value as $k => $v) { - $this->debug("serializing map element: key $k, value $v"); - $contents .= ''; - $contents .= $this->serialize_val($k,'key',false,false,false,false,$use); - $contents .= $this->serialize_val($v,'value',false,false,false,false,$use); - $contents .= ''; - } - if ($use == 'literal') { - if ($forceType) { - $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents"; - } else { - $xml = "<$name>$contents"; - } - } else { - $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents"; - } - $this->debug("in serializeType: returning: $xml"); - return $xml; - } - $this->debug('in serializeType: Apache SOAP type, but only support Map'); - } - } else { - // TODO: should the type be compared to types in XSD, and the namespace - // set to XSD if the type matches? - $this->debug("in serializeType: No namespace for type $type"); - $ns = ''; - $uqType = $type; - } - if(!$typeDef = $this->getTypeDef($uqType, $ns)){ - $this->setError("$type ($uqType) is not a supported type."); - $this->debug("in serializeType: $type ($uqType) is not a supported type."); - return false; - } else { - $this->debug("in serializeType: found typeDef"); - $this->appendDebug('typeDef=' . $this->varDump($typeDef)); - if (substr($uqType, -1) == '^') { - $uqType = substr($uqType, 0, -1); - } - } - if (!isset($typeDef['phpType'])) { - $this->setError("$type ($uqType) has no phpType."); - $this->debug("in serializeType: $type ($uqType) has no phpType."); - return false; - } - $phpType = $typeDef['phpType']; - $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') ); - // if php type == struct, map value to the element names - if ($phpType == 'struct') { - if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') { - $elementName = $uqType; - if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) { - $elementNS = " xmlns=\"$ns\""; - } else { - $elementNS = " xmlns=\"\""; - } - } else { - $elementName = $name; - if ($unqualified) { - $elementNS = " xmlns=\"\""; - } else { - $elementNS = ''; - } - } - if (is_null($value)) { - if ($use == 'literal') { - // TODO: depends on minOccurs and nillable - $xml = "<$elementName$elementNS/>"; - } else { - $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; - } - $this->debug("in serializeType: returning: $xml"); - return $xml; - } - if (is_object($value)) { - $value = get_object_vars($value); - } - if (is_array($value)) { - $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType); - if ($use == 'literal') { - if ($forceType) { - $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">"; - } else { - $xml = "<$elementName$elementNS$elementAttrs>"; - } - } else { - $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>"; - } - - if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') { - if (isset($value['!'])) { - $xml .= $value['!']; - $this->debug("in serializeType: serialized simpleContent for type $type"); - } else { - $this->debug("in serializeType: no simpleContent to serialize for type $type"); - } - } else { - // complexContent - $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle); - } - $xml .= ""; - } else { - $this->debug("in serializeType: phpType is struct, but value is not an array"); - $this->setError("phpType is struct, but value is not an array: see debug output for details"); - $xml = ''; - } - } elseif ($phpType == 'array') { - if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) { - $elementNS = " xmlns=\"$ns\""; - } else { - if ($unqualified) { - $elementNS = " xmlns=\"\""; - } else { - $elementNS = ''; - } - } - if (is_null($value)) { - if ($use == 'literal') { - // TODO: depends on minOccurs - $xml = "<$name$elementNS/>"; - } else { - $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . - ":Array\" " . - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . - ':arrayType="' . - $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) . - ':' . - $this->getLocalPart($typeDef['arrayType'])."[0]\"/>"; - } - $this->debug("in serializeType: returning: $xml"); - return $xml; - } - if (isset($typeDef['multidimensional'])) { - $nv = array(); - foreach($value as $v) { - $cols = ',' . sizeof($v); - $nv = array_merge($nv, $v); - } - $value = $nv; - } else { - $cols = ''; - } - if (is_array($value) && sizeof($value) >= 1) { - $rows = sizeof($value); - $contents = ''; - foreach($value as $k => $v) { - $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); - //if (strpos($typeDef['arrayType'], ':') ) { - if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) { - $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); - } else { - $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); - } - } - } else { - $rows = 0; - $contents = null; - } - // TODO: for now, an empty value will be serialized as a zero element - // array. Revisit this when coding the handling of null/nil values. - if ($use == 'literal') { - $xml = "<$name$elementNS>" - .$contents - .""; - } else { - $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '. - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') - .':arrayType="' - .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) - .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">" - .$contents - .""; - } - } elseif ($phpType == 'scalar') { - if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) { - $elementNS = " xmlns=\"$ns\""; - } else { - if ($unqualified) { - $elementNS = " xmlns=\"\""; - } else { - $elementNS = ''; - } - } - if ($use == 'literal') { - if ($forceType) { - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value"; - } else { - $xml = "<$name$elementNS>$value"; - } - } else { - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value"; - } - } - $this->debug("in serializeType: returning: $xml"); - return $xml; - } - - /** - * serializes the attributes for a complexType - * - * @param array $typeDef our internal representation of an XML schema type (or element) - * @param mixed $value a native PHP value (parameter value) - * @param string $ns the namespace of the type - * @param string $uqType the local part of the type - * @return string value serialized as an XML string - * @access private - */ - function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) { - $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType"); - $xml = ''; - if (isset($typeDef['extensionBase'])) { - $nsx = $this->getPrefix($typeDef['extensionBase']); - $uqTypex = $this->getLocalPart($typeDef['extensionBase']); - if ($this->getNamespaceFromPrefix($nsx)) { - $nsx = $this->getNamespaceFromPrefix($nsx); - } - if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) { - $this->debug("serialize attributes for extension base $nsx:$uqTypex"); - $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex); - } else { - $this->debug("extension base $nsx:$uqTypex is not a supported type"); - } - } - if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) { - $this->debug("serialize attributes for XML Schema type $ns:$uqType"); - if (is_array($value)) { - $xvalue = $value; - } elseif (is_object($value)) { - $xvalue = get_object_vars($value); - } else { - $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType"); - $xvalue = array(); - } - foreach ($typeDef['attrs'] as $aName => $attrs) { - if (isset($xvalue['!' . $aName])) { - $xname = '!' . $aName; - $this->debug("value provided for attribute $aName with key $xname"); - } elseif (isset($xvalue[$aName])) { - $xname = $aName; - $this->debug("value provided for attribute $aName with key $xname"); - } elseif (isset($attrs['default'])) { - $xname = '!' . $aName; - $xvalue[$xname] = $attrs['default']; - $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName); - } else { - $xname = ''; - $this->debug("no value provided for attribute $aName"); - } - if ($xname) { - $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; - } - } - } else { - $this->debug("no attributes to serialize for XML Schema type $ns:$uqType"); - } - return $xml; - } - - /** - * serializes the elements for a complexType - * - * @param array $typeDef our internal representation of an XML schema type (or element) - * @param mixed $value a native PHP value (parameter value) - * @param string $ns the namespace of the type - * @param string $uqType the local part of the type - * @param string $use use for part (encoded|literal) - * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) - * @return string value serialized as an XML string - * @access private - */ - function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) { - $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType"); - $xml = ''; - if (isset($typeDef['extensionBase'])) { - $nsx = $this->getPrefix($typeDef['extensionBase']); - $uqTypex = $this->getLocalPart($typeDef['extensionBase']); - if ($this->getNamespaceFromPrefix($nsx)) { - $nsx = $this->getNamespaceFromPrefix($nsx); - } - if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) { - $this->debug("serialize elements for extension base $nsx:$uqTypex"); - $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle); - } else { - $this->debug("extension base $nsx:$uqTypex is not a supported type"); - } - } - if (isset($typeDef['elements']) && is_array($typeDef['elements'])) { - $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType"); - if (is_array($value)) { - $xvalue = $value; - } elseif (is_object($value)) { - $xvalue = get_object_vars($value); - } else { - $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType"); - $xvalue = array(); - } - // toggle whether all elements are present - ideally should validate against schema - if (count($typeDef['elements']) != count($xvalue)){ - $optionals = true; - } - foreach ($typeDef['elements'] as $eName => $attrs) { - if (!isset($xvalue[$eName])) { - if (isset($attrs['default'])) { - $xvalue[$eName] = $attrs['default']; - $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName); - } - } - // if user took advantage of a minOccurs=0, then only serialize named parameters - if (isset($optionals) - && (!isset($xvalue[$eName])) - && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') - ){ - if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') { - $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']); - } - // do nothing - $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing"); - } else { - // get value - if (isset($xvalue[$eName])) { - $v = $xvalue[$eName]; - } else { - $v = null; - } - if (isset($attrs['form'])) { - $unqualified = ($attrs['form'] == 'unqualified'); - } else { - $unqualified = false; - } - if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') { - $vv = $v; - foreach ($vv as $k => $v) { - if (isset($attrs['type']) || isset($attrs['ref'])) { - // serialize schema-defined type - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); - } else { - // serialize generic type (can this ever really happen?) - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); - } - } - } else { - if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') { - // do nothing - } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') { - // TODO: serialize a nil correctly, but for now serialize schema-defined type - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); - } elseif (isset($attrs['type']) || isset($attrs['ref'])) { - // serialize schema-defined type - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); - } else { - // serialize generic type (can this ever really happen?) - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); - } - } - } - } - } else { - $this->debug("no elements to serialize for XML Schema type $ns:$uqType"); - } - return $xml; - } - - /** - * adds an XML Schema complex type to the WSDL types - * - * @param string $name - * @param string $typeClass (complexType|simpleType|attribute) - * @param string $phpType currently supported are array and struct (php assoc array) - * @param string $compositor (all|sequence|choice) - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) - * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')) - * @param string $arrayType as namespace:name (xsd:string) - * @see nusoap_xmlschema - * @access public - */ - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') { - if (count($elements) > 0) { - $eElements = array(); - foreach($elements as $n => $e){ - // expand each element - $ee = array(); - foreach ($e as $k => $v) { - $k = strpos($k,':') ? $this->expandQname($k) : $k; - $v = strpos($v,':') ? $this->expandQname($v) : $v; - $ee[$k] = $v; - } - $eElements[$n] = $ee; - } - $elements = $eElements; - } - - if (count($attrs) > 0) { - foreach($attrs as $n => $a){ - // expand each attribute - foreach ($a as $k => $v) { - $k = strpos($k,':') ? $this->expandQname($k) : $k; - $v = strpos($v,':') ? $this->expandQname($v) : $v; - $aa[$k] = $v; - } - $eAttrs[$n] = $aa; - } - $attrs = $eAttrs; - } - - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; - $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType; - - $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; - $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType); - } - - /** - * adds an XML Schema simple type to the WSDL types - * - * @param string $name - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param string $typeClass (should always be simpleType) - * @param string $phpType (should always be scalar) - * @param array $enumeration array of values - * @see nusoap_xmlschema - * @access public - */ - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; - - $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; - $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration); - } - - /** - * adds an element to the WSDL types - * - * @param array $attrs attributes that must include name and type - * @see nusoap_xmlschema - * @access public - */ - function addElement($attrs) { - $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; - $this->schemas[$typens][0]->addElement($attrs); - } - - /** - * register an operation with the server - * - * @param string $name operation (method) name - * @param array $in assoc array of input values: key = param name, value = param type - * @param array $out assoc array of output values: key = param name, value = param type - * @param string $namespace optional The namespace for the operation - * @param string $soapaction optional The soapaction for the operation - * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically - * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) - * @param string $documentation optional The description to include in the WSDL - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) - * @access public - */ - function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){ - if ($use == 'encoded' && $encodingStyle == '') { - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; - } - - if ($style == 'document') { - $elements = array(); - foreach ($in as $n => $t) { - $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified'); - } - $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements); - $this->addElement(array('name' => $name, 'type' => $name . 'RequestType')); - $in = array('parameters' => 'tns:' . $name . '^'); - - $elements = array(); - foreach ($out as $n => $t) { - $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified'); - } - $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements); - $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified')); - $out = array('parameters' => 'tns:' . $name . 'Response' . '^'); - } - - // get binding - $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] = - array( - 'name' => $name, - 'binding' => $this->serviceName . 'Binding', - 'endpoint' => $this->endpoint, - 'soapAction' => $soapaction, - 'style' => $style, - 'input' => array( - 'use' => $use, - 'namespace' => $namespace, - 'encodingStyle' => $encodingStyle, - 'message' => $name . 'Request', - 'parts' => $in), - 'output' => array( - 'use' => $use, - 'namespace' => $namespace, - 'encodingStyle' => $encodingStyle, - 'message' => $name . 'Response', - 'parts' => $out), - 'namespace' => $namespace, - 'transport' => 'http://schemas.xmlsoap.org/soap/http', - 'documentation' => $documentation); - // add portTypes - // add messages - if($in) - { - foreach($in as $pName => $pType) - { - if(strpos($pType,':')) { - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); - } - $this->messages[$name.'Request'][$pName] = $pType; - } - } else { - $this->messages[$name.'Request']= '0'; - } - if($out) - { - foreach($out as $pName => $pType) - { - if(strpos($pType,':')) { - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); - } - $this->messages[$name.'Response'][$pName] = $pType; - } - } else { - $this->messages[$name.'Response']= '0'; - } - return true; - } -} - -?> \ No newline at end of file diff --git a/htdocs/includes/nusoap/lib/class.wsdlcache.php b/htdocs/includes/nusoap/lib/class.wsdlcache.php deleted file mode 100644 index 8468850eb90..00000000000 --- a/htdocs/includes/nusoap/lib/class.wsdlcache.php +++ /dev/null @@ -1,208 +0,0 @@ - -* @author Ingo Fischer -* @access public -*/ -class nusoap_wsdlcache { - /** - * @var resource - * @access private - */ - var $fplock; - /** - * @var integer - * @access private - */ - var $cache_lifetime; - /** - * @var string - * @access private - */ - var $cache_dir; - /** - * @var string - * @access public - */ - var $debug_str = ''; - - /** - * constructor - * - * @param string $cache_dir directory for cache-files - * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited - * @access public - */ - function __construct($cache_dir='.', $cache_lifetime=0) { - $this->fplock = array(); - $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; - $this->cache_lifetime = $cache_lifetime; - } - - /** - * creates the filename used to cache a wsdl instance - * - * @param string $wsdl The URL of the wsdl instance - * @return string The filename used to cache the instance - * @access private - */ - function createFilename($wsdl) { - return $this->cache_dir.'/wsdlcache-' . md5($wsdl); - } - - /** - * adds debug data to the class level debug string - * - * @param string $string debug data - * @access private - */ - function debug($string){ - $this->debug_str .= get_class($this).": $string\n"; - } - - /** - * gets a wsdl instance from the cache - * - * @param string $wsdl The URL of the wsdl instance - * @return object wsdl The cached wsdl instance, null if the instance is not in the cache - * @access public - */ - function get($wsdl) { - $filename = $this->createFilename($wsdl); - if ($this->obtainMutex($filename, "r")) { - // check for expired WSDL that must be removed from the cache - if ($this->cache_lifetime > 0) { - if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { - unlink($filename); - $this->debug("Expired $wsdl ($filename) from cache"); - $this->releaseMutex($filename); - return null; - } - } - // see what there is to return - if (!file_exists($filename)) { - $this->debug("$wsdl ($filename) not in cache (1)"); - $this->releaseMutex($filename); - return null; - } - $fp = @fopen($filename, "r"); - if ($fp) { - $s = implode("", @file($filename)); - fclose($fp); - $this->debug("Got $wsdl ($filename) from cache"); - } else { - $s = null; - $this->debug("$wsdl ($filename) not in cache (2)"); - } - $this->releaseMutex($filename); - return (!is_null($s)) ? unserialize($s) : null; - } else { - $this->debug("Unable to obtain mutex for $filename in get"); - } - return null; - } - - /** - * obtains the local mutex - * - * @param string $filename The Filename of the Cache to lock - * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode - * @return boolean Lock successfully obtained ?! - * @access private - */ - function obtainMutex($filename, $mode) { - if (isset($this->fplock[md5($filename)])) { - $this->debug("Lock for $filename already exists"); - return false; - } - $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); - if ($mode == "r") { - return flock($this->fplock[md5($filename)], LOCK_SH); - } else { - return flock($this->fplock[md5($filename)], LOCK_EX); - } - } - - /** - * adds a wsdl instance to the cache - * - * @param object wsdl $wsdl_instance The wsdl instance to add - * @return boolean WSDL successfully cached - * @access public - */ - function put($wsdl_instance) { - $filename = $this->createFilename($wsdl_instance->wsdl); - $s = serialize($wsdl_instance); - if ($this->obtainMutex($filename, "w")) { - $fp = fopen($filename, "w"); - if (! $fp) { - $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); - $this->releaseMutex($filename); - return false; - } - fputs($fp, $s); - fclose($fp); - $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); - $this->releaseMutex($filename); - return true; - } else { - $this->debug("Unable to obtain mutex for $filename in put"); - } - return false; - } - - /** - * releases the local mutex - * - * @param string $filename The Filename of the Cache to lock - * @return boolean Lock successfully released - * @access private - */ - function releaseMutex($filename) { - $ret = flock($this->fplock[md5($filename)], LOCK_UN); - fclose($this->fplock[md5($filename)]); - unset($this->fplock[md5($filename)]); - if (! $ret) { - $this->debug("Not able to release lock for $filename"); - } - return $ret; - } - - /** - * removes a wsdl instance from the cache - * - * @param string $wsdl The URL of the wsdl instance - * @return boolean Whether there was an instance to remove - * @access public - */ - function remove($wsdl) { - $filename = $this->createFilename($wsdl); - if (!file_exists($filename)) { - $this->debug("$wsdl ($filename) not in cache to be removed"); - return false; - } - // ignore errors obtaining mutex - $this->obtainMutex($filename, "w"); - $ret = unlink($filename); - $this->debug("Removed ($ret) $wsdl ($filename) from cache"); - $this->releaseMutex($filename); - return $ret; - } -} - -/** - * For backward compatibility - */ -class wsdlcache extends nusoap_wsdlcache { -} -?> diff --git a/htdocs/includes/nusoap/lib/class.xmlschema.php b/htdocs/includes/nusoap/lib/class.xmlschema.php deleted file mode 100644 index 3934453f8d2..00000000000 --- a/htdocs/includes/nusoap/lib/class.xmlschema.php +++ /dev/null @@ -1,972 +0,0 @@ - -* @author Scott Nichol -* @access public -*/ -class nusoap_xmlschema extends nusoap_base { - - // files - var $schema = ''; - var $xml = ''; - // namespaces - var $enclosingNamespaces; - // schema info - var $schemaInfo = array(); - var $schemaTargetNamespace = ''; - // types, elements, attributes defined by the schema - var $attributes = array(); - var $complexTypes = array(); - var $complexTypeStack = array(); - var $currentComplexType = null; - var $elements = array(); - var $elementStack = array(); - var $currentElement = null; - var $simpleTypes = array(); - var $simpleTypeStack = array(); - var $currentSimpleType = null; - // imports - var $imports = array(); - // parser vars - var $parser; - var $position = 0; - var $depth = 0; - var $depth_array = array(); - var $message = array(); - var $defaultNamespace = array(); - - /** - * constructor - * - * @param string $schema schema document URI - * @param string $xml xml document URI - * @param string $namespaces namespaces defined in enclosing XML - * @access public - */ - function __construct($schema='',$xml='',$namespaces=array()){ - parent::__construct(); - $this->debug('nusoap_xmlschema class instantiated, inside constructor'); - // files - $this->schema = $schema; - $this->xml = $xml; - - // namespaces - $this->enclosingNamespaces = $namespaces; - $this->namespaces = array_merge($this->namespaces, $namespaces); - - // parse schema file - if($schema != ''){ - $this->debug('initial schema file: '.$schema); - $this->parseFile($schema, 'schema'); - } - - // parse xml file - if($xml != ''){ - $this->debug('initial xml file: '.$xml); - $this->parseFile($xml, 'xml'); - } - - } - - /** - * parse an XML file - * - * @param string $xml path/URL to XML file - * @param string $type (schema | xml) - * @return boolean - * @access public - */ - function parseFile($xml,$type){ - // parse xml file - if($xml != ""){ - $xmlStr = @join("",@file($xml)); - if($xmlStr == ""){ - $msg = 'Error reading XML from '.$xml; - $this->setError($msg); - $this->debug($msg); - return false; - } else { - $this->debug("parsing $xml"); - $this->parseString($xmlStr,$type); - $this->debug("done parsing $xml"); - return true; - } - } - return false; - } - - /** - * parse an XML string - * - * @param string $xml path or URL - * @param string $type (schema|xml) - * @access private - */ - function parseString($xml,$type){ - // parse xml string - if($xml != ""){ - - // Create an XML parser. - $this->parser = xml_parser_create(); - // Set the options for parsing the XML data. - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); - - // Set the object for the parser. - xml_set_object($this->parser, $this); - - // Set the element handlers for the parser. - if($type == "schema"){ - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); - xml_set_character_data_handler($this->parser,'schemaCharacterData'); - } elseif($type == "xml"){ - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); - xml_set_character_data_handler($this->parser,'xmlCharacterData'); - } - - // Parse the XML file. - if(!xml_parse($this->parser,$xml,true)){ - // Display an error message. - $errstr = sprintf('XML error parsing XML schema on line %d: %s', - xml_get_current_line_number($this->parser), - xml_error_string(xml_get_error_code($this->parser)) - ); - $this->debug($errstr); - $this->debug("XML payload:\n" . $xml); - $this->setError($errstr); - } - - xml_parser_free($this->parser); - } else{ - $this->debug('no xml passed to parseString()!!'); - $this->setError('no xml passed to parseString()!!'); - } - } - - /** - * gets a type name for an unnamed type - * - * @param string Element name - * @return string A type name for an unnamed type - * @access private - */ - function CreateTypeName($ename) { - $scope = ''; - for ($i = 0; $i < count($this->complexTypeStack); $i++) { - $scope .= $this->complexTypeStack[$i] . '_'; - } - return $scope . $ename . '_ContainedType'; - } - - /** - * start-element handler - * - * @param string $parser XML parser object - * @param string $name element name - * @param string $attrs associative array of attributes - * @access private - */ - function schemaStartElement($parser, $name, $attrs) { - - // position in the total number of elements, starting from 0 - $pos = $this->position++; - $depth = $this->depth++; - // set self as current value for this depth - $this->depth_array[$depth] = $pos; - $this->message[$pos] = array('cdata' => ''); - if ($depth > 0) { - $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; - } else { - $this->defaultNamespace[$pos] = false; - } - - // get element prefix - if($prefix = $this->getPrefix($name)){ - // get unqualified name - $name = $this->getLocalPart($name); - } else { - $prefix = ''; - } - - // loop thru attributes, expanding, and registering namespace declarations - if(count($attrs) > 0){ - foreach($attrs as $k => $v){ - // if ns declarations, add to class level array of valid namespaces - if(preg_match('/^xmlns/',$k)){ - //$this->xdebug("$k: $v"); - //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); - if($ns_prefix = substr(strrchr($k,':'),1)){ - //$this->xdebug("Add namespace[$ns_prefix] = $v"); - $this->namespaces[$ns_prefix] = $v; - } else { - $this->defaultNamespace[$pos] = $v; - if (! $this->getPrefixFromNamespace($v)) { - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; - } - } - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){ - $this->XMLSchemaVersion = $v; - $this->namespaces['xsi'] = $v.'-instance'; - } - } - } - foreach($attrs as $k => $v){ - // expand each attribute - $k = strpos($k,':') ? $this->expandQname($k) : $k; - $v = strpos($v,':') ? $this->expandQname($v) : $v; - $eAttrs[$k] = $v; - } - $attrs = $eAttrs; - } else { - $attrs = array(); - } - // find status, register data - switch($name){ - case 'all': // (optional) compositor content for a complexType - case 'choice': - case 'group': - case 'sequence': - //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement"); - $this->complexTypes[$this->currentComplexType]['compositor'] = $name; - //if($name == 'all' || $name == 'sequence'){ - // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - //} - break; - case 'attribute': // complexType attribute - //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']); - $this->xdebug("parsing attribute:"); - $this->appendDebug($this->varDump($attrs)); - if (!isset($attrs['form'])) { - // TODO: handle globals - $attrs['form'] = $this->schemaInfo['attributeFormDefault']; - } - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - if (!strpos($v, ':')) { - // no namespace in arrayType attribute value... - if ($this->defaultNamespace[$pos]) { - // ...so use the default - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } - } - } - if(isset($attrs['name'])){ - $this->attributes[$attrs['name']] = $attrs; - $aname = $attrs['name']; - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){ - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { - $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } else { - $aname = ''; - } - } elseif(isset($attrs['ref'])){ - $aname = $attrs['ref']; - $this->attributes[$attrs['ref']] = $attrs; - } - - if($this->currentComplexType){ // This should *always* be - $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; - } - // arrayType attribute - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){ - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - $prefix = $this->getPrefix($aname); - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){ - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } else { - $v = ''; - } - if(strpos($v,'[,]')){ - $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; - } - $v = substr($v,0,strpos($v,'[')); // clip the [] - if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){ - $v = $this->XMLSchemaVersion.':'.$v; - } - $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; - } - break; - case 'complexContent': // (optional) content for a complexType - $this->xdebug("do nothing for element $name"); - break; - case 'complexType': - array_push($this->complexTypeStack, $this->currentComplexType); - if(isset($attrs['name'])){ - // TODO: what is the scope of named complexTypes that appear - // nested within other c complexTypes? - $this->xdebug('processing named complexType '.$attrs['name']); - //$this->currentElement = false; - $this->currentComplexType = $attrs['name']; - $this->complexTypes[$this->currentComplexType] = $attrs; - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; - // This is for constructs like - // - // - // - // - // - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ - $this->xdebug('complexType is unusual array'); - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } else { - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - } - } else { - $name = $this->CreateTypeName($this->currentElement); - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name); - $this->currentComplexType = $name; - //$this->currentElement = false; - $this->complexTypes[$this->currentComplexType] = $attrs; - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; - // This is for constructs like - // - // - // - // - // - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ - $this->xdebug('complexType is unusual array'); - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } else { - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - } - } - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; - break; - case 'element': - array_push($this->elementStack, $this->currentElement); - if (!isset($attrs['form'])) { - if ($this->currentComplexType) { - $attrs['form'] = $this->schemaInfo['elementFormDefault']; - } else { - // global - $attrs['form'] = 'qualified'; - } - } - if(isset($attrs['type'])){ - $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']); - if (! $this->getPrefix($attrs['type'])) { - if ($this->defaultNamespace[$pos]) { - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; - $this->xdebug('used default namespace to make type ' . $attrs['type']); - } - } - // This is for constructs like - // - // - // - // - // - if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') { - $this->xdebug('arrayType for unusual array is ' . $attrs['type']); - $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; - } - $this->currentElement = $attrs['name']; - $ename = $attrs['name']; - } elseif(isset($attrs['ref'])){ - $this->xdebug("processing element as ref to ".$attrs['ref']); - $this->currentElement = "ref to ".$attrs['ref']; - $ename = $this->getLocalPart($attrs['ref']); - } else { - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type); - $this->currentElement = $attrs['name']; - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; - $ename = $attrs['name']; - } - if (isset($ename) && $this->currentComplexType) { - $this->xdebug("add element $ename to complexType $this->currentComplexType"); - $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; - } elseif (!isset($attrs['ref'])) { - $this->xdebug("add element $ename to elements array"); - $this->elements[ $attrs['name'] ] = $attrs; - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; - } - break; - case 'enumeration': // restriction value list member - $this->xdebug('enumeration ' . $attrs['value']); - if ($this->currentSimpleType) { - $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; - } elseif ($this->currentComplexType) { - $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; - } - break; - case 'extension': // simpleContent or complexContent type extension - $this->xdebug('extension ' . $attrs['base']); - if ($this->currentComplexType) { - $ns = $this->getPrefix($attrs['base']); - if ($ns == '') { - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; - } else { - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; - } - } else { - $this->xdebug('no current complexType to set extensionBase'); - } - break; - case 'import': - if (isset($attrs['schemaLocation'])) { - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']); - $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); - } else { - $this->xdebug('import namespace ' . $attrs['namespace']); - $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true); - if (! $this->getPrefixFromNamespace($attrs['namespace'])) { - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; - } - } - break; - case 'include': - if (isset($attrs['schemaLocation'])) { - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']); - $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); - } else { - $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute'); - } - break; - case 'list': // simpleType value list - $this->xdebug("do nothing for element $name"); - break; - case 'restriction': // simpleType, simpleContent or complexContent value restriction - $this->xdebug('restriction ' . $attrs['base']); - if($this->currentSimpleType){ - $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; - } elseif($this->currentComplexType){ - $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; - if(strstr($attrs['base'],':') == ':Array'){ - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } - } - break; - case 'schema': - $this->schemaInfo = $attrs; - $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); - if (isset($attrs['targetNamespace'])) { - $this->schemaTargetNamespace = $attrs['targetNamespace']; - } - if (!isset($attrs['elementFormDefault'])) { - $this->schemaInfo['elementFormDefault'] = 'unqualified'; - } - if (!isset($attrs['attributeFormDefault'])) { - $this->schemaInfo['attributeFormDefault'] = 'unqualified'; - } - break; - case 'simpleContent': // (optional) content for a complexType - if ($this->currentComplexType) { // This should *always* be - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; - } else { - $this->xdebug("do nothing for element $name because there is no current complexType"); - } - break; - case 'simpleType': - array_push($this->simpleTypeStack, $this->currentSimpleType); - if(isset($attrs['name'])){ - $this->xdebug("processing simpleType for name " . $attrs['name']); - $this->currentSimpleType = $attrs['name']; - $this->simpleTypes[ $attrs['name'] ] = $attrs; - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; - } else { - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name); - $this->currentSimpleType = $name; - //$this->currentElement = false; - $this->simpleTypes[$this->currentSimpleType] = $attrs; - $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; - } - break; - case 'union': // simpleType type list - $this->xdebug("do nothing for element $name"); - break; - default: - $this->xdebug("do not have any logic to process element $name"); - } - } - - /** - * end-element handler - * - * @param string $parser XML parser object - * @param string $name element name - * @access private - */ - function schemaEndElement($parser, $name) { - // bring depth down a notch - $this->depth--; - // position of current element is equal to the last value left in depth_array for my depth - if(isset($this->depth_array[$this->depth])){ - $pos = $this->depth_array[$this->depth]; - } - // get element prefix - if ($prefix = $this->getPrefix($name)){ - // get unqualified name - $name = $this->getLocalPart($name); - } else { - $prefix = ''; - } - // move on... - if($name == 'complexType'){ - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)')); - $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); - $this->currentComplexType = array_pop($this->complexTypeStack); - //$this->currentElement = false; - } - if($name == 'element'){ - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)')); - $this->currentElement = array_pop($this->elementStack); - } - if($name == 'simpleType'){ - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)')); - $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); - $this->currentSimpleType = array_pop($this->simpleTypeStack); - } - } - - /** - * element content handler - * - * @param string $parser XML parser object - * @param string $data element content - * @access private - */ - function schemaCharacterData($parser, $data){ - $pos = $this->depth_array[$this->depth - 1]; - $this->message[$pos]['cdata'] .= $data; - } - - /** - * serialize the schema - * - * @access public - */ - function serializeSchema(){ - - $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); - $xml = ''; - // imports - if (sizeof($this->imports) > 0) { - foreach($this->imports as $ns => $list) { - foreach ($list as $ii) { - if ($ii['location'] != '') { - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; - } else { - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; - } - } - } - } - // complex types - foreach($this->complexTypes as $typeName => $attrs){ - $contentStr = ''; - // serialize child elements - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){ - foreach($attrs['elements'] as $element => $eParts){ - if(isset($eParts['ref'])){ - $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; - } else { - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; - foreach ($eParts as $aName => $aValue) { - // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable - if ($aName != 'name' && $aName != 'type') { - $contentStr .= " $aName=\"$aValue\""; - } - } - $contentStr .= "/>\n"; - } - } - // compositor wraps elements - if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) { - $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." \n"; - } - } - // attributes - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){ - foreach($attrs['attrs'] as $attr => $aParts){ - $contentStr .= " <$schemaPrefix:attribute"; - foreach ($aParts as $a => $v) { - if ($a == 'ref' || $a == 'type') { - $contentStr .= " $a=\"".$this->contractQName($v).'"'; - } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') { - $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; - $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; - } else { - $contentStr .= " $a=\"$v\""; - } - } - $contentStr .= "/>\n"; - } - } - // if restriction - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){ - $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." \n"; - // complex or simple content - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){ - $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." \n"; - } - } - // finalize complex type - if($contentStr != ''){ - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." \n"; - } else { - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; - } - $xml .= $contentStr; - } - // simple types - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){ - foreach($this->simpleTypes as $typeName => $eParts){ - $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; - if (isset($eParts['enumeration'])) { - foreach ($eParts['enumeration'] as $e) { - $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; - } - } - $xml .= " \n "; - } - } - // elements - if(isset($this->elements) && count($this->elements) > 0){ - foreach($this->elements as $element => $eParts){ - $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; - } - } - // attributes - if(isset($this->attributes) && count($this->attributes) > 0){ - foreach($this->attributes as $attr => $aParts){ - $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; - } - } - // finish 'er up - $attr = ''; - foreach ($this->schemaInfo as $k => $v) { - if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') { - $attr .= " $k=\"$v\""; - } - } - $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; - foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) { - $el .= " xmlns:$nsp=\"$ns\""; - } - $xml = $el . ">\n".$xml."\n"; - return $xml; - } - - /** - * adds debug data to the clas level debug string - * - * @param string $string debug data - * @access private - */ - function xdebug($string){ - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string); - } - - /** - * get the PHP type of a user defined type in the schema - * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays - * returns false if no type exists, or not w/ the given namespace - * else returns a string that is either a native php type, or 'struct' - * - * @param string $type name of defined type - * @param string $ns namespace of type - * @return mixed - * @access public - * @deprecated - */ - function getPHPType($type,$ns){ - if(isset($this->typemap[$ns][$type])){ - //print "found type '$type' and ns $ns in typemap
"; - return $this->typemap[$ns][$type]; - } elseif(isset($this->complexTypes[$type])){ - //print "getting type '$type' and ns $ns from complexTypes array
"; - return $this->complexTypes[$type]['phpType']; - } - return false; - } - - /** - * returns an associative array of information about a given type - * returns false if no type exists by the given name - * - * For a complexType typeDef = array( - * 'restrictionBase' => '', - * 'phpType' => '', - * 'compositor' => '(sequence|all)', - * 'elements' => array(), // refs to elements array - * 'attrs' => array() // refs to attributes array - * ... and so on (see addComplexType) - * ) - * - * For simpleType or element, the array has different keys. - * - * @param string $type - * @return mixed - * @access public - * @see addComplexType - * @see addSimpleType - * @see addElement - */ - function getTypeDef($type){ - //$this->debug("in getTypeDef for type $type"); - if (substr($type, -1) == '^') { - $is_element = 1; - $type = substr($type, 0, -1); - } else { - $is_element = 0; - } - - if((! $is_element) && isset($this->complexTypes[$type])){ - $this->xdebug("in getTypeDef, found complexType $type"); - return $this->complexTypes[$type]; - } elseif((! $is_element) && isset($this->simpleTypes[$type])){ - $this->xdebug("in getTypeDef, found simpleType $type"); - if (!isset($this->simpleTypes[$type]['phpType'])) { - // get info for type to tack onto the simple type - // TODO: can this ever really apply (i.e. what is a simpleType really?) - $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); - $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); - $etype = $this->getTypeDef($uqType); - if ($etype) { - $this->xdebug("in getTypeDef, found type for simpleType $type:"); - $this->xdebug($this->varDump($etype)); - if (isset($etype['phpType'])) { - $this->simpleTypes[$type]['phpType'] = $etype['phpType']; - } - if (isset($etype['elements'])) { - $this->simpleTypes[$type]['elements'] = $etype['elements']; - } - } - } - return $this->simpleTypes[$type]; - } elseif(isset($this->elements[$type])){ - $this->xdebug("in getTypeDef, found element $type"); - if (!isset($this->elements[$type]['phpType'])) { - // get info for type to tack onto the element - $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); - $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); - $etype = $this->getTypeDef($uqType); - if ($etype) { - $this->xdebug("in getTypeDef, found type for element $type:"); - $this->xdebug($this->varDump($etype)); - if (isset($etype['phpType'])) { - $this->elements[$type]['phpType'] = $etype['phpType']; - } - if (isset($etype['elements'])) { - $this->elements[$type]['elements'] = $etype['elements']; - } - if (isset($etype['extensionBase'])) { - $this->elements[$type]['extensionBase'] = $etype['extensionBase']; - } - } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') { - $this->xdebug("in getTypeDef, element $type is an XSD type"); - $this->elements[$type]['phpType'] = 'scalar'; - } - } - return $this->elements[$type]; - } elseif(isset($this->attributes[$type])){ - $this->xdebug("in getTypeDef, found attribute $type"); - return $this->attributes[$type]; - } elseif (preg_match('/_ContainedType$/', $type)) { - $this->xdebug("in getTypeDef, have an untyped element $type"); - $typeDef['typeClass'] = 'simpleType'; - $typeDef['phpType'] = 'scalar'; - $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; - return $typeDef; - } - $this->xdebug("in getTypeDef, did not find $type"); - return false; - } - - /** - * returns a sample serialization of a given type, or false if no type by the given name - * - * @param string $type name of type - * @return mixed - * @access public - * @deprecated - */ - function serializeTypeDef($type){ - //print "in sTD() for type $type
"; - if($typeDef = $this->getTypeDef($type)){ - $str .= '<'.$type; - if(is_array($typeDef['attrs'])){ - foreach($typeDef['attrs'] as $attName => $data){ - $str .= " $attName=\"{type = ".$data['type']."}\""; - } - } - $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; - if(count($typeDef['elements']) > 0){ - $str .= ">"; - foreach($typeDef['elements'] as $element => $eData){ - $str .= $this->serializeTypeDef($element); - } - $str .= ""; - } elseif($typeDef['typeClass'] == 'element') { - $str .= ">"; - } else { - $str .= "/>"; - } - return $str; - } - return false; - } - - /** - * returns HTML form elements that allow a user - * to enter values for creating an instance of the given type. - * - * @param string $name name for type instance - * @param string $type name of type - * @return string - * @access public - * @deprecated - */ - function typeToForm($name,$type){ - // get typedef - if($typeDef = $this->getTypeDef($type)){ - // if struct - if($typeDef['phpType'] == 'struct'){ - $buffer .= ''; - foreach($typeDef['elements'] as $child => $childDef){ - $buffer .= " - - "; - } - $buffer .= '
$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):
'; - // if array - } elseif($typeDef['phpType'] == 'array'){ - $buffer .= ''; - for($i=0;$i < 3; $i++){ - $buffer .= " - - "; - } - $buffer .= '
array item (type: $typeDef[arrayType]):
'; - // if scalar - } else { - $buffer .= ""; - } - } else { - $buffer .= ""; - } - return $buffer; - } - - /** - * adds a complex type to the schema - * - * example: array - * - * addType( - * 'ArrayOfstring', - * 'complexType', - * 'array', - * '', - * 'SOAP-ENC:Array', - * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), - * 'xsd:string' - * ); - * - * example: PHP associative array ( SOAP Struct ) - * - * addType( - * 'SOAPStruct', - * 'complexType', - * 'struct', - * 'all', - * array('myVar'=> array('name'=>'myVar','type'=>'string') - * ); - * - * @param name - * @param typeClass (complexType|simpleType|attribute) - * @param phpType: currently supported are array and struct (php assoc array) - * @param compositor (all|sequence|choice) - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param elements = array ( name = array(name=>'',type=>'') ) - * @param attrs = array( - * array( - * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", - * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" - * ) - * ) - * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) - * @access public - * @see getTypeDef - */ - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){ - $this->complexTypes[$name] = array( - 'name' => $name, - 'typeClass' => $typeClass, - 'phpType' => $phpType, - 'compositor'=> $compositor, - 'restrictionBase' => $restrictionBase, - 'elements' => $elements, - 'attrs' => $attrs, - 'arrayType' => $arrayType - ); - - $this->xdebug("addComplexType $name:"); - $this->appendDebug($this->varDump($this->complexTypes[$name])); - } - - /** - * adds a simple type to the schema - * - * @param string $name - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param string $typeClass (should always be simpleType) - * @param string $phpType (should always be scalar) - * @param array $enumeration array of values - * @access public - * @see nusoap_xmlschema - * @see getTypeDef - */ - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { - $this->simpleTypes[$name] = array( - 'name' => $name, - 'typeClass' => $typeClass, - 'phpType' => $phpType, - 'type' => $restrictionBase, - 'enumeration' => $enumeration - ); - - $this->xdebug("addSimpleType $name:"); - $this->appendDebug($this->varDump($this->simpleTypes[$name])); - } - - /** - * adds an element to the schema - * - * @param array $attrs attributes that must include name and type - * @see nusoap_xmlschema - * @access public - */ - function addElement($attrs) { - if (! $this->getPrefix($attrs['type'])) { - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; - } - $this->elements[ $attrs['name'] ] = $attrs; - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; - - $this->xdebug("addElement " . $attrs['name']); - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); - } -} - -/** - * Backward compatibility - */ -class XMLSchema extends nusoap_xmlschema { -} - - -?> \ No newline at end of file diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php index 4f6208aa604..b365aac10c0 100644 --- a/htdocs/includes/nusoap/lib/nusoap.php +++ b/htdocs/includes/nusoap/lib/nusoap.php @@ -1,6 +1,7 @@ . +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA The NuSOAP project home is: http://sourceforge.net/projects/nusoap/ @@ -71,822 +73,856 @@ require_once('class.soap_server.php');*/ // cf. http://www.webkreator.com/php/techniques/php-static-class-variables.html $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = 9; + /** -* -* nusoap_base -* -* @author Dietrich Ayala -* @author Scott Nichol -* @access public -*/ -class nusoap_base { - /** - * Identification for HTTP headers. - * - * @var string - * @access private - */ - var $title = 'NuSOAP'; - /** - * Version for HTTP headers. - * - * @var string - * @access private - */ - var $version = '0.9.5'; - /** - * CVS revision for HTTP headers. - * - * @var string - * @access private - */ - var $revision = '1.15'; + * + * nusoap_base + * + * @author Dietrich Ayala + * @author Scott Nichol + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class nusoap_base +{ + /** + * Identification for HTTP headers. + * + * @var string + * @access private + */ + var $title = 'NuSOAP'; + /** + * Version for HTTP headers. + * + * @var string + * @access private + */ + var $version = '0.9.11'; + /** + * CVS revision for HTTP headers. + * + * @var string + * @access private + */ + var $revision = '$Revision: 1.123 $'; /** * Current error string (manipulated by getError/setError) - * - * @var string - * @access private - */ - var $error_str = ''; + * + * @var string + * @access private + */ + var $error_str = ''; /** * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) - * - * @var string - * @access private - */ + * + * @var string + * @access private + */ var $debug_str = ''; /** - * toggles automatic encoding of special characters as entities - * (should always be true, I think) - * - * @var boolean - * @access private - */ - var $charencoding = true; - /** - * the debug level for this instance - * - * @var integer - * @access private - */ - var $debugLevel; + * toggles automatic encoding of special characters as entities + * (should always be true, I think) + * + * @var boolean + * @access private + */ + var $charencoding = true; + /** + * the debug level for this instance + * + * @var integer + * @access private + */ + var $debugLevel; /** - * set schema version - * - * @var string - * @access public - */ - var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; + * set schema version + * + * @var string + * @access public + */ + var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; /** - * charset encoding for outgoing messages - * - * @var string - * @access public - */ + * charset encoding for outgoing messages + * + * @var string + * @access public + */ var $soap_defencoding = 'ISO-8859-1'; - //var $soap_defencoding = 'UTF-8'; + //var $soap_defencoding = 'UTF-8'; - /** - * namespaces in an array of prefix => uri - * - * this is "seeded" by a set of constants, but it may be altered by code - * - * @var array - * @access public - */ - var $namespaces = array( - 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', - 'xsd' => 'http://www.w3.org/2001/XMLSchema', - 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' - ); + /** + * namespaces in an array of prefix => uri + * + * this is "seeded" by a set of constants, but it may be altered by code + * + * @var array + * @access public + */ + var $namespaces = array( + 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', + 'xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' + ); - /** - * namespaces used in the current context, e.g. during serialization - * - * @var array - * @access private - */ - var $usedNamespaces = array(); + /** + * namespaces used in the current context, e.g. during serialization + * + * @var array + * @access private + */ + var $usedNamespaces = array(); - /** - * XML Schema types in an array of uri => (array of xml type => php type) - * is this legacy yet? - * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. - * @var array - * @access public - */ - var $typemap = array( - 'http://www.w3.org/2001/XMLSchema' => array( - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', - // abstract "any" types - 'anyType'=>'string','anySimpleType'=>'string', - // derived datatypes - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), - 'http://www.w3.org/2000/10/XMLSchema' => array( - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', - 'float'=>'double','dateTime'=>'string', - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), - 'http://www.w3.org/1999/XMLSchema' => array( - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', - 'float'=>'double','dateTime'=>'string', - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), - 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), - 'http://xml.apache.org/xml-soap' => array('Map') - ); + /** + * XML Schema types in an array of uri => (array of xml type => php type) + * is this legacy yet? + * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. + * + * @var array + * @access public + */ + var $typemap = array( + 'http://www.w3.org/2001/XMLSchema' => array( + 'string' => 'string', 'boolean' => 'boolean', 'float' => 'double', 'double' => 'double', 'decimal' => 'double', + 'duration' => '', 'dateTime' => 'string', 'time' => 'string', 'date' => 'string', 'gYearMonth' => '', + 'gYear' => '', 'gMonthDay' => '', 'gDay' => '', 'gMonth' => '', 'hexBinary' => 'string', 'base64Binary' => 'string', + // abstract "any" types + 'anyType' => 'string', 'anySimpleType' => 'string', + // derived datatypes + 'normalizedString' => 'string', 'token' => 'string', 'language' => '', 'NMTOKEN' => '', 'NMTOKENS' => '', 'Name' => '', 'NCName' => '', 'ID' => '', + 'IDREF' => '', 'IDREFS' => '', 'ENTITY' => '', 'ENTITIES' => '', 'integer' => 'integer', 'nonPositiveInteger' => 'integer', + 'negativeInteger' => 'integer', 'long' => 'integer', 'int' => 'integer', 'short' => 'integer', 'byte' => 'integer', 'nonNegativeInteger' => 'integer', + 'unsignedLong' => '', 'unsignedInt' => '', 'unsignedShort' => '', 'unsignedByte' => '', 'positiveInteger' => ''), + 'http://www.w3.org/2000/10/XMLSchema' => array( + 'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double', + 'float' => 'double', 'dateTime' => 'string', + 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'), + 'http://www.w3.org/1999/XMLSchema' => array( + 'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double', + 'float' => 'double', 'dateTime' => 'string', + 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'), + 'http://soapinterop.org/xsd' => array('SOAPStruct' => 'struct'), + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64' => 'string', 'array' => 'array', 'Array' => 'array'), + 'http://xml.apache.org/xml-soap' => array('Map') + ); - /** - * XML entities to convert - * - * @var array - * @access public - * @deprecated - * @see expandEntities - */ - var $xmlEntities = array('quot' => '"','amp' => '&', - 'lt' => '<','gt' => '>','apos' => "'"); + /** + * XML entities to convert + * + * @var array + * @access public + * @deprecated + * @see expandEntities + */ + var $xmlEntities = array('quot' => '"', 'amp' => '&', + 'lt' => '<', 'gt' => '>', 'apos' => "'"); - /** - * constructor - * - * @access public - */ - function __construct() { - $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; - } + /** + * HTTP Content-type to be used for SOAP calls and responses + * + * @var string + */ + var $contentType = "text/xml"; - /** - * gets the global debug level, which applies to future instances - * - * @return integer Debug level 0-9, where 0 turns off - * @access public - */ - function getGlobalDebugLevel() { - return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; - } - /** - * sets the global debug level, which applies to future instances - * - * @param int $level Debug level 0-9, where 0 turns off - * @access public - */ - function setGlobalDebugLevel($level) { - $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; - } + /** + * constructor + * + * @access public + */ + function __construct() + { + $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; + } - /** - * gets the debug level for this instance - * - * @return int Debug level 0-9, where 0 turns off - * @access public - */ - function getDebugLevel() { - return $this->debugLevel; - } + /** + * gets the global debug level, which applies to future instances + * + * @return integer Debug level 0-9, where 0 turns off + * @access public + */ + function getGlobalDebugLevel() + { + return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; + } - /** - * sets the debug level for this instance - * - * @param int $level Debug level 0-9, where 0 turns off - * @access public - */ - function setDebugLevel($level) { - $this->debugLevel = $level; - } + /** + * sets the global debug level, which applies to future instances + * + * @param int $level Debug level 0-9, where 0 turns off + * @access public + */ + function setGlobalDebugLevel($level) + { + $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; + } - /** - * adds debug data to the instance debug string with formatting - * - * @param string $string debug data - * @access private - */ - function debug($string){ - if ($this->debugLevel > 0) { - $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); - } - } + /** + * gets the debug level for this instance + * + * @return int Debug level 0-9, where 0 turns off + * @access public + */ + function getDebugLevel() + { + return $this->debugLevel; + } - /** - * adds debug data to the instance debug string without formatting - * - * @param string $string debug data - * @access public - */ - function appendDebug($string){ - if ($this->debugLevel > 0) { - // it would be nice to use a memory stream here to use - // memory more efficiently - $this->debug_str .= $string; - } - } + /** + * sets the debug level for this instance + * + * @param int $level Debug level 0-9, where 0 turns off + * @access public + */ + function setDebugLevel($level) + { + $this->debugLevel = $level; + } - /** - * clears the current debug data for this instance - * - * @access public - */ - function clearDebug() { - // it would be nice to use a memory stream here to use - // memory more efficiently - $this->debug_str = ''; - } + /** + * adds debug data to the instance debug string with formatting + * + * @param string $string debug data + * @access private + */ + function debug($string) + { + if ($this->debugLevel > 0) { + $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n"); + } + } - /** - * gets the current debug data for this instance - * - * @return debug data - * @access public - */ - function &getDebug() { - // it would be nice to use a memory stream here to use - // memory more efficiently - return $this->debug_str; - } + /** + * adds debug data to the instance debug string without formatting + * + * @param string $string debug data + * @access public + */ + function appendDebug($string) + { + if ($this->debugLevel > 0) { + // it would be nice to use a memory stream here to use + // memory more efficiently + $this->debug_str .= $string; + } + } - /** - * gets the current debug data for this instance as an XML comment - * this may change the contents of the debug data - * - * @return debug data as an XML comment - * @access public - */ - function &getDebugAsXMLComment() { - // it would be nice to use a memory stream here to use - // memory more efficiently - while (strpos($this->debug_str, '--')) { - $this->debug_str = str_replace('--', '- -', $this->debug_str); - } - $ret = ""; - return $ret; - } + /** + * clears the current debug data for this instance + * + * @access public + */ + function clearDebug() + { + // it would be nice to use a memory stream here to use + // memory more efficiently + $this->debug_str = ''; + } - /** - * expands entities, e.g. changes '<' to '<'. - * - * @param string $val The string in which to expand entities. - * @access private - */ - function expandEntities($val) { - if ($this->charencoding) { - $val = str_replace('&', '&', $val); - $val = str_replace("'", ''', $val); - $val = str_replace('"', '"', $val); - $val = str_replace('<', '<', $val); - $val = str_replace('>', '>', $val); - } - return $val; - } + /** + * gets the current debug data for this instance + * + * @return string data + * @access public + */ + function &getDebug() + { + // it would be nice to use a memory stream here to use + // memory more efficiently + return $this->debug_str; + } - /** - * returns error string if present - * - * @return mixed error string or false - * @access public - */ - function getError(){ - if($this->error_str != ''){ - return $this->error_str; - } - return false; - } + /** + * gets the current debug data for this instance as an XML comment + * this may change the contents of the debug data + * + * @return string data as an XML comment + * @access public + */ + function &getDebugAsXMLComment() + { + // it would be nice to use a memory stream here to use + // memory more efficiently + while (strpos($this->debug_str, '--')) { + $this->debug_str = str_replace('--', '- -', $this->debug_str); + } + $ret = ""; + return $ret; + } - /** - * sets error string - * - * @return boolean $string error string - * @access private - */ - function setError($str){ - $this->error_str = $str; - } + /** + * expands entities, e.g. changes '<' to '<'. + * + * @param string $val The string in which to expand entities. + * @access private + */ + function expandEntities($val) + { + if ($this->charencoding) { + $val = str_replace('&', '&', $val); + $val = str_replace("'", ''', $val); + $val = str_replace('"', '"', $val); + $val = str_replace('<', '<', $val); + $val = str_replace('>', '>', $val); + } + return $val; + } - /** - * detect if array is a simple array or a struct (associative array) - * - * @param mixed $val The PHP array - * @return string (arraySimple|arrayStruct) - * @access private - */ - function isArraySimpleOrStruct($val) { + /** + * returns error string if present + * + * @return false|string error string or false + * @access public + */ + function getError() + { + if ($this->error_str != '') { + return $this->error_str; + } + return false; + } + + /** + * sets error string + * + * @return void + * @access private + */ + function setError($str) + { + $this->error_str = $str; + } + + /** + * detect if array is a simple array or a struct (associative array) + * + * @param mixed $val The PHP array + * @return string (arraySimple|arrayStruct) + * @access private + */ + function isArraySimpleOrStruct($val) + { $keyList = array_keys($val); - foreach ($keyList as $keyListValue) { - if (!is_int($keyListValue)) { - return 'arrayStruct'; - } - } - return 'arraySimple'; - } - - /** - * serializes PHP values in accordance w/ section 5. Type information is - * not serialized if $use == 'literal'. - * - * @param mixed $val The value to serialize - * @param string $name The name (local part) of the XML element - * @param string $type The XML schema type (local part) for the element - * @param string $name_ns The namespace for the name of the XML element - * @param string $type_ns The namespace for the type of the element - * @param array $attributes The attributes to serialize as name=>value pairs - * @param string $use The WSDL "use" (encoded|literal) - * @param boolean $soapval Whether this is called from soapval. - * @return string The serialized element, possibly with child elements - * @access public - */ - function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { - $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); - $this->appendDebug('value=' . $this->varDump($val)); - $this->appendDebug('attributes=' . $this->varDump($attributes)); - - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { - $this->debug("serialize_val: serialize soapval"); - $xml = $val->serialize($use); - $this->appendDebug($val->getDebug()); - $val->clearDebug(); - $this->debug("serialize_val of soapval returning $xml"); - return $xml; + foreach ($keyList as $keyListValue) { + if (!is_int($keyListValue)) { + return 'arrayStruct'; + } + } + return 'arraySimple'; + } + + /** + * serializes PHP values in accordance w/ section 5. Type information is + * not serialized if $use == 'literal'. + * + * @param mixed $val The value to serialize + * @param string $name The name (local part) of the XML element + * @param string $type The XML schema type (local part) for the element + * @param string $name_ns The namespace for the name of the XML element + * @param string $type_ns The namespace for the type of the element + * @param array $attributes The attributes to serialize as name=>value pairs + * @param string $use The WSDL "use" (encoded|literal) + * @param boolean $soapval Whether this is called from soapval. + * @return string The serialized element, possibly with child elements + * @access public + */ + function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) + { + $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); + $this->appendDebug('value=' . $this->varDump($val)); + $this->appendDebug('attributes=' . $this->varDump($attributes)); + + if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) { + $this->debug("serialize_val: serialize soapval"); + $xml = $val->serialize($use); + $this->appendDebug($val->getDebug()); + $val->clearDebug(); + $this->debug("serialize_val of soapval returning $xml"); + return $xml; + } + // force valid name if necessary + if (is_numeric($name)) { + $name = '__numeric_' . $name; + } elseif (!$name) { + $name = 'noname'; + } + // if name has ns, add ns prefix to name + $xmlns = ''; + if ($name_ns) { + $prefix = 'nu' . rand(1000, 9999); + $name = $prefix . ':' . $name; + $xmlns .= " xmlns:$prefix=\"$name_ns\""; + } + // if type is prefixed, create type prefix + if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) { + // need to fix this. shouldn't default to xsd if no ns specified + // w/o checking against typemap + $type_prefix = 'xsd'; + } elseif ($type_ns) { + $type_prefix = 'ns' . rand(1000, 9999); + $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; + } + // serialize attributes if present + $atts = ''; + if ($attributes) { + foreach ($attributes as $k => $v) { + $atts .= " $k=\"" . $this->expandEntities($v) . '"'; + } + } + // serialize null value + if (is_null($val)) { + $this->debug("serialize_val: serialize null"); + if ($use == 'literal') { + // TODO: depends on minOccurs + $xml = "<$name$xmlns$atts/>"; + } else { + if (isset($type) && isset($type_prefix)) { + $type_str = " xsi:type=\"$type_prefix:$type\""; + } else { + $type_str = ''; + } + $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; + } + $this->debug("serialize_val returning $xml"); + return $xml; } - // force valid name if necessary - if (is_numeric($name)) { - $name = '__numeric_' . $name; - } elseif (! $name) { - $name = 'noname'; - } - // if name has ns, add ns prefix to name - $xmlns = ''; - if($name_ns){ - $prefix = 'nu'.rand(1000,9999); - $name = $prefix.':'.$name; - $xmlns .= " xmlns:$prefix=\"$name_ns\""; - } - // if type is prefixed, create type prefix - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ - // need to fix this. shouldn't default to xsd if no ns specified - // w/o checking against typemap - $type_prefix = 'xsd'; - } elseif($type_ns){ - $type_prefix = 'ns'.rand(1000,9999); - $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; - } - // serialize attributes if present - $atts = ''; - if($attributes){ - foreach($attributes as $k => $v){ - $atts .= " $k=\"".$this->expandEntities($v).'"'; - } - } - // serialize null value - if (is_null($val)) { - $this->debug("serialize_val: serialize null"); - if ($use == 'literal') { - // TODO: depends on minOccurs - $xml = "<$name$xmlns$atts/>"; - $this->debug("serialize_val returning $xml"); - return $xml; - } else { - if (isset($type) && isset($type_prefix)) { - $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = ''; - } - $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; - $this->debug("serialize_val returning $xml"); - return $xml; - } - } // serialize if an xsd built-in primitive type - if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ - $this->debug("serialize_val: serialize xsd built-in primitive type"); - if (is_bool($val)) { - if ($type == 'boolean') { - $val = $val ? 'true' : 'false'; - } elseif (! $val) { - $val = 0; - } - } else if (is_string($val)) { - $val = $this->expandEntities($val); - } - if ($use == 'literal') { - $xml = "<$name$xmlns$atts>$val"; - $this->debug("serialize_val returning $xml"); - return $xml; - } else { - $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val"; - $this->debug("serialize_val returning $xml"); - return $xml; - } + if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) { + $this->debug("serialize_val: serialize xsd built-in primitive type"); + if (is_bool($val)) { + if ($type == 'boolean') { + $val = $val ? 'true' : 'false'; + } elseif (!$val) { + $val = 0; + } + } elseif (is_string($val)) { + $val = $this->expandEntities($val); + } + if ($use == 'literal') { + $xml = "<$name$xmlns$atts>$val"; + } else { + $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val"; + } + $this->debug("serialize_val returning $xml"); + return $xml; } - // detect type and serialize - $xml = ''; - switch(true) { - case (is_bool($val) || $type == 'boolean'): - $this->debug("serialize_val: serialize boolean"); - if ($type == 'boolean') { - $val = $val ? 'true' : 'false'; - } elseif (! $val) { - $val = 0; - } - if ($use == 'literal') { - $xml .= "<$name$xmlns$atts>$val"; - } else { - $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val"; - } - break; - case (is_int($val) || is_long($val) || $type == 'int'): - $this->debug("serialize_val: serialize int"); - if ($use == 'literal') { - $xml .= "<$name$xmlns$atts>$val"; - } else { - $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val"; - } - break; - case (is_float($val)|| is_double($val) || $type == 'float'): - $this->debug("serialize_val: serialize float"); - if ($use == 'literal') { - $xml .= "<$name$xmlns$atts>$val"; - } else { - $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val"; - } - break; - case (is_string($val) || $type == 'string'): - $this->debug("serialize_val: serialize string"); - $val = $this->expandEntities($val); - if ($use == 'literal') { - $xml .= "<$name$xmlns$atts>$val"; - } else { - $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val"; - } - break; - case is_object($val): - $this->debug("serialize_val: serialize object"); - if (get_class($val) == 'soapval') { - $this->debug("serialize_val: serialize soapval object"); - $pXml = $val->serialize($use); - $this->appendDebug($val->getDebug()); - $val->clearDebug(); - } else { - if (! $name) { - $name = get_class($val); - $this->debug("In serialize_val, used class name $name as element name"); - } else { - $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); - } - foreach(get_object_vars($val) as $k => $v){ - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); - } - } - if(isset($type) && isset($type_prefix)){ - $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = ''; - } - if ($use == 'literal') { - $xml .= "<$name$xmlns$atts>$pXml"; - } else { - $xml .= "<$name$xmlns$type_str$atts>$pXml"; - } - break; - break; - case (is_array($val) || $type): - // detect if struct or array - $valueType = $this->isArraySimpleOrStruct($val); - if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ - $this->debug("serialize_val: serialize array"); - $i = 0; - if(is_array($val) && count($val)> 0){ - foreach($val as $v){ - if(is_object($v) && get_class($v) == 'soapval'){ - $tt_ns = $v->type_ns; - $tt = $v->type; - } elseif (is_array($v)) { - $tt = $this->isArraySimpleOrStruct($v); - } else { - $tt = gettype($v); - } - $array_types[$tt] = 1; - // TODO: for literal, the name should be $name - // @CHANGE This is to have tag name with name reported by wsdl and not "item" - //$xml .= $this->serialize_val($v,'item',false,false,false,false,$use); - $tmp=preg_replace('/s$/i','',$name); - $xml .= $this->serialize_val($v,$tmp?$tmp:'item',false,false,false,false,$use); + // detect type and serialize + $xml = ''; + switch (true) { + case (is_bool($val) || $type == 'boolean'): + $this->debug("serialize_val: serialize boolean"); + if ($type == 'boolean') { + $val = $val ? 'true' : 'false'; + } elseif (!$val) { + $val = 0; + } + if ($use == 'literal') { + $xml .= "<$name$xmlns$atts>$val"; + } else { + $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val"; + } + break; + case (is_int($val) || is_long($val) || $type == 'int'): + $this->debug("serialize_val: serialize int"); + if ($use == 'literal') { + $xml .= "<$name$xmlns$atts>$val"; + } else { + $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val"; + } + break; + case (is_float($val) || is_double($val) || $type == 'float'): + $this->debug("serialize_val: serialize float"); + if ($use == 'literal') { + $xml .= "<$name$xmlns$atts>$val"; + } else { + $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val"; + } + break; + case (is_string($val) || $type == 'string'): + $this->debug("serialize_val: serialize string"); + $val = $this->expandEntities($val); + if ($use == 'literal') { + $xml .= "<$name$xmlns$atts>$val"; + } else { + $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val"; + } + break; + case is_object($val): + $this->debug("serialize_val: serialize object"); + $pXml = ""; + if (get_class($val) == 'soapval') { + $this->debug("serialize_val: serialize soapval object"); + $pXml = $val->serialize($use); + $this->appendDebug($val->getDebug()); + $val->clearDebug(); + } else { + if (!$name) { + $name = get_class($val); + $this->debug("In serialize_val, used class name $name as element name"); + } else { + $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); + } + foreach (get_object_vars($val) as $k => $v) { + $pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use); + } + } + if (isset($type) && isset($type_prefix)) { + $type_str = " xsi:type=\"$type_prefix:$type\""; + } else { + $type_str = ''; + } + if ($use == 'literal') { + $xml .= "<$name$xmlns$atts>$pXml"; + } else { + $xml .= "<$name$xmlns$type_str$atts>$pXml"; + } + break; + case (is_array($val) || $type): + // detect if struct or array + $valueType = $this->isArraySimpleOrStruct($val); + if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) { + $this->debug("serialize_val: serialize array"); + $i = 0; + if (is_array($val) && count($val) > 0) { + $array_types = array (); + $tt_ns = ""; + $tt = ""; + foreach ($val as $v) { + if (is_object($v) && get_class($v) == 'soapval') { + $tt_ns = $v->type_ns; + $tt = $v->type; + } elseif (is_array($v)) { + $tt = $this->isArraySimpleOrStruct($v); + } else { + $tt = gettype($v); + } + $array_types[$tt] = 1; + // TODO: for literal, the name should be $name + $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use); ++$i; - } - if(count($array_types) > 1){ - $array_typename = 'xsd:anyType'; - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { - if ($tt == 'integer') { - $tt = 'int'; - } - $array_typename = 'xsd:'.$tt; - } elseif(isset($tt) && $tt == 'arraySimple'){ - $array_typename = 'SOAP-ENC:Array'; - } elseif(isset($tt) && $tt == 'arrayStruct'){ - $array_typename = 'unnamed_struct_use_soapval'; - } else { - // if type is prefixed, create type prefix - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ - $array_typename = 'xsd:' . $tt; - } elseif ($tt_ns) { - $tt_prefix = 'ns' . rand(1000, 9999); - $array_typename = "$tt_prefix:$tt"; - $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; - } else { - $array_typename = $tt; - } - } - $array_type = $i; - if ($use == 'literal') { - $type_str = ''; - } else if (isset($type) && isset($type_prefix)) { - $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; - } - // empty array - } else { - if ($use == 'literal') { - $type_str = ''; - } else if (isset($type) && isset($type_prefix)) { - $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; - } - } - // TODO: for array in literal, there is no wrapper here - $xml = "<$name$xmlns$type_str$atts>".$xml.""; - } else { - // got a struct - $this->debug("serialize_val: serialize struct"); - if(isset($type) && isset($type_prefix)){ - $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = ''; - } - if ($use == 'literal') { - $xml .= "<$name$xmlns$atts>"; - } else { - $xml .= "<$name$xmlns$type_str$atts>"; - } - foreach($val as $k => $v){ - // Apache Map - if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { - $xml .= ''; - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); - $xml .= ''; - } else { - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); - } - } - $xml .= ""; - } - break; - default: - $this->debug("serialize_val: serialize unknown"); - $xml .= 'not detected, got '.gettype($val).' for '.$val; - break; - } - $this->debug("serialize_val returning $xml"); - return $xml; - } + } + if (count($array_types) > 1) { + $array_typename = 'xsd:anyType'; + } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { + if ($tt == 'integer') { + $tt = 'int'; + } + $array_typename = 'xsd:' . $tt; + } elseif (isset($tt) && $tt == 'arraySimple') { + $array_typename = 'SOAP-ENC:Array'; + } elseif (isset($tt) && $tt == 'arrayStruct') { + $array_typename = 'unnamed_struct_use_soapval'; + } else { + // if type is prefixed, create type prefix + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) { + $array_typename = 'xsd:' . $tt; + } elseif ($tt_ns) { + $tt_prefix = 'ns' . rand(1000, 9999); + $array_typename = "$tt_prefix:$tt"; + $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; + } else { + $array_typename = $tt; + } + } + $array_type = $i; + if ($use == 'literal') { + $type_str = ''; + } elseif (isset($type) && isset($type_prefix)) { + $type_str = " xsi:type=\"$type_prefix:$type\""; + } else { + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\""; + } + // empty array + } else { + if ($use == 'literal') { + $type_str = ''; + } elseif (isset($type) && isset($type_prefix)) { + $type_str = " xsi:type=\"$type_prefix:$type\""; + } else { + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; + } + } + // TODO: for array in literal, there is no wrapper here + $xml = "<$name$xmlns$type_str$atts>" . $xml . ""; + } else { + // got a struct + $this->debug("serialize_val: serialize struct"); + if (isset($type) && isset($type_prefix)) { + $type_str = " xsi:type=\"$type_prefix:$type\""; + } else { + $type_str = ''; + } + if ($use == 'literal') { + $xml .= "<$name$xmlns$atts>"; + } else { + $xml .= "<$name$xmlns$type_str$atts>"; + } + foreach ($val as $k => $v) { + // Apache Map + if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { + $xml .= ''; + $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use); + $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use); + $xml .= ''; + } else { + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); + } + } + $xml .= ""; + } + break; + default: + $this->debug("serialize_val: serialize unknown"); + $xml .= 'not detected, got ' . gettype($val) . ' for ' . $val; + break; + } + $this->debug("serialize_val returning $xml"); + return $xml; + } /** - * serializes a message - * - * @param string $body the XML of the SOAP body - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array - * @param array $namespaces optional the namespaces used in generating the body and headers - * @param string $style optional (rpc|document) - * @param string $use optional (encoded|literal) - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) - * @return string the message - * @access public - */ - function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ - // TODO: add an option to automatically run utf8_encode on $body and $headers - // if $this->soap_defencoding is UTF-8. Not doing this automatically allows - // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 + * serializes a message + * + * @param string $body the XML of the SOAP body + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array + * @param array $namespaces optional the namespaces used in generating the body and headers + * @param string $style optional (rpc|document) + * @param string $use optional (encoded|literal) + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) + * @return string the message + * @access public + */ + function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') + { + // TODO: add an option to automatically run utf8_encode on $body and $headers + // if $this->soap_defencoding is UTF-8. Not doing this automatically allows + // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); - $this->debug("headers:"); - $this->appendDebug($this->varDump($headers)); - $this->debug("namespaces:"); - $this->appendDebug($this->varDump($namespaces)); + $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); + $this->debug("headers:"); + $this->appendDebug($this->varDump($headers)); + $this->debug("namespaces:"); + $this->appendDebug($this->varDump($namespaces)); - // serialize namespaces - $ns_string = ''; - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ - $ns_string .= " xmlns:$k=\"$v\""; - } - if($encodingStyle) { - $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; - } + // serialize namespaces + $ns_string = ''; + foreach (array_merge($this->namespaces, $namespaces) as $k => $v) { + $ns_string .= " xmlns:$k=\"$v\""; + } + if ($encodingStyle) { + $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; + } - // serialize headers - if($headers){ - if (is_array($headers)) { - $xml = ''; - foreach ($headers as $k => $v) { - if (is_object($v) && get_class($v) == 'soapval') { - $xml .= $this->serialize_val($v, false, false, false, false, false, $use); - } else { - $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); - } - } - $headers = $xml; - $this->debug("In serializeEnvelope, serialized array of headers to $headers"); - } - $headers = "".$headers.""; - } - // serialize envelope + // serialize headers + if ($headers) { + if (is_array($headers)) { + $xml = ''; + foreach ($headers as $k => $v) { + if (is_object($v) && get_class($v) == 'soapval') { + $xml .= $this->serialize_val($v, false, false, false, false, false, $use); + } else { + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); + } + } + $headers = $xml; + $this->debug("In serializeEnvelope, serialized array of headers to $headers"); + } + $headers = "" . $headers . ""; + } + // serialize envelope + return + 'soap_defencoding . '"?' . ">" . + '" . + $headers . + "" . + $body . + "" . + ""; + } + + /** + * formats a string to be inserted into an HTML stream + * + * @param string $str The string to format + * @return string The formatted string + * @access public + * @deprecated + */ + function formatDump($str) + { + $str = htmlspecialchars($str); + return nl2br($str); + } + + /** + * contracts (changes namespace to prefix) a qualified name + * + * @param string $qname qname + * @return string contracted qname + * @access private + */ + function contractQname($qname) + { + // get element namespace + //$this->xdebug("Contract $qname"); + if (strrpos($qname, ':')) { + // get unqualified name + $name = substr($qname, strrpos($qname, ':') + 1); + // get ns + $ns = substr($qname, 0, strrpos($qname, ':')); + $p = $this->getPrefixFromNamespace($ns); + if ($p) { + return $p . ':' . $name; + } + } + return $qname; + } + + /** + * expands (changes prefix to namespace) a qualified name + * + * @param string $qname qname + * @return string expanded qname + * @access private + */ + function expandQname($qname) + { + // get element prefix + if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) { + // get unqualified name + $name = substr(strstr($qname, ':'), 1); + // get ns prefix + $prefix = substr($qname, 0, strpos($qname, ':')); + if (isset($this->namespaces[$prefix])) { + return $this->namespaces[$prefix] . ':' . $name; + } else { + return $qname; + } + } else { + return $qname; + } + } + + /** + * returns the local part of a prefixed string + * returns the original string, if not prefixed + * + * @param string $str The prefixed string + * @return string The local part + * @access public + */ + function getLocalPart($str) + { + if ($sstr = strrchr($str, ':')) { + // get unqualified name + return substr($sstr, 1); + } else { + return $str; + } + } + + /** + * returns the prefix part of a prefixed string + * returns false, if not prefixed + * + * @param string $str The prefixed string + * @return false|string The prefix or false if there is no prefix + * @access public + */ + function getPrefix($str) + { + if ($pos = strrpos($str, ':')) { + // get prefix + return substr($str, 0, $pos); + } + return false; + } + + /** + * pass it a prefix, it returns a namespace + * + * @param string $prefix The prefix + * @return mixed The namespace, false if no namespace has the specified prefix + * @access public + */ + function getNamespaceFromPrefix($prefix) + { + if (isset($this->namespaces[$prefix])) { + return $this->namespaces[$prefix]; + } + //$this->setError("No namespace registered for prefix '$prefix'"); + return false; + } + + /** + * returns the prefix for a given namespace (or prefix) + * or false if no prefixes registered for the given namespace + * + * @param string $ns The namespace + * @return false|string The prefix, false if the namespace has no prefixes + * @access public + */ + function getPrefixFromNamespace($ns) + { + foreach ($this->namespaces as $p => $n) { + if ($ns == $n || $ns == $p) { + $this->usedNamespaces[$p] = $n; + return $p; + } + } + return false; + } + + /** + * returns the time in ODBC canonical form with microseconds + * + * @return string The time in ODBC canonical form with microseconds + * @access public + */ + function getmicrotime() + { + if (function_exists('gettimeofday')) { + $tod = gettimeofday(); + $sec = $tod['sec']; + $usec = $tod['usec']; + } else { + $sec = time(); + $usec = 0; + } + $dtx = new DateTime("@$sec"); return - 'soap_defencoding .'"?'.">". - '". - $headers. - "". - $body. - "". - ""; + date_format($dtx, 'Y-m-d H:i:s') . '.' . sprintf('%06d', $usec); } - /** - * formats a string to be inserted into an HTML stream - * - * @param string $str The string to format - * @return string The formatted string - * @access public - * @deprecated - */ - function formatDump($str){ - $str = htmlspecialchars($str); - return nl2br($str); - } - - /** - * contracts (changes namespace to prefix) a qualified name - * - * @param string $qname qname - * @return string contracted qname - * @access private - */ - function contractQname($qname){ - // get element namespace - //$this->xdebug("Contract $qname"); - if (strrpos($qname, ':')) { - // get unqualified name - $name = substr($qname, strrpos($qname, ':') + 1); - // get ns - $ns = substr($qname, 0, strrpos($qname, ':')); - $p = $this->getPrefixFromNamespace($ns); - if ($p) { - return $p . ':' . $name; - } - return $qname; - } else { - return $qname; - } - } - - /** - * expands (changes prefix to namespace) a qualified name - * - * @param string $qname qname - * @return string expanded qname - * @access private - */ - function expandQname($qname){ - // get element prefix - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ - // get unqualified name - $name = substr(strstr($qname,':'),1); - // get ns prefix - $prefix = substr($qname,0,strpos($qname,':')); - if(isset($this->namespaces[$prefix])){ - return $this->namespaces[$prefix].':'.$name; - } else { - return $qname; - } - } else { - return $qname; - } - } - /** - * returns the local part of a prefixed string - * returns the original string, if not prefixed - * - * @param string $str The prefixed string - * @return string The local part - * @access public - */ - function getLocalPart($str){ - if($sstr = strrchr($str,':')){ - // get unqualified name - return substr( $sstr, 1 ); - } else { - return $str; - } - } + * Returns a string with the output of var_dump + * + * @param mixed $data The variable to var_dump + * @return string The output of var_dump + * @access public + */ + function varDump($data) + { + ob_start(); + var_dump($data); + $ret_val = ob_get_contents(); + ob_end_clean(); + return $ret_val; + } - /** - * returns the prefix part of a prefixed string - * returns false, if not prefixed - * - * @param string $str The prefixed string - * @return mixed The prefix or false if there is no prefix - * @access public - */ - function getPrefix($str){ - if($pos = strrpos($str,':')){ - // get prefix - return substr($str,0,$pos); - } - return false; - } - - /** - * pass it a prefix, it returns a namespace - * - * @param string $prefix The prefix - * @return mixed The namespace, false if no namespace has the specified prefix - * @access public - */ - function getNamespaceFromPrefix($prefix){ - if (isset($this->namespaces[$prefix])) { - return $this->namespaces[$prefix]; - } - //$this->setError("No namespace registered for prefix '$prefix'"); - return false; - } - - /** - * returns the prefix for a given namespace (or prefix) - * or false if no prefixes registered for the given namespace - * - * @param string $ns The namespace - * @return mixed The prefix, false if the namespace has no prefixes - * @access public - */ - function getPrefixFromNamespace($ns) { - foreach ($this->namespaces as $p => $n) { - if ($ns == $n || $ns == $p) { - $this->usedNamespaces[$p] = $n; - return $p; - } - } - return false; - } - - /** - * returns the time in ODBC canonical form with microseconds - * - * @return string The time in ODBC canonical form with microseconds - * @access public - */ - function getmicrotime() { - if (function_exists('gettimeofday')) { - $tod = gettimeofday(); - $sec = $tod['sec']; - $usec = $tod['usec']; - } else { - $sec = time(); - $usec = 0; - } - return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); - } - - /** - * Returns a string with the output of var_dump - * - * @param mixed $data The variable to var_dump - * @return string The output of var_dump - * @access public - */ - function varDump($data) { - ob_start(); - var_dump($data); - $ret_val = ob_get_contents(); - ob_end_clean(); - return $ret_val; - } - - /** - * represents the object as a string - * - * @return string - * @access public - */ - function __toString() { - return $this->varDump($this); - } + /** + * represents the object as a string + * + * @return string + * @access public + */ + function __toString() + { + return $this->varDump($this); + } } // XML Schema Datatype Helper Functions @@ -894,1441 +930,1460 @@ class nusoap_base { //xsd:dateTime helpers /** -* convert unix timestamp to ISO 8601 compliant date string -* -* @param int $timestamp Unix time stamp -* @param boolean $utc Whether the time stamp is UTC or local -* @return mixed ISO 8601 date string or false -* @access public -*/ -function timestamp_to_iso8601($timestamp,$utc=true){ - $datestr = date('Y-m-d\TH:i:sO',$timestamp); - $pos = strrpos($datestr, "+"); - if ($pos === FALSE) { - $pos = strrpos($datestr, "-"); - } - if ($pos !== FALSE) { - if (strlen($datestr) == $pos + 5) { - $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); - } - } - if($utc){ - $pattern = '/'. - '([0-9]{4})-'. // centuries & years CCYY- - '([0-9]{2})-'. // months MM- - '([0-9]{2})'. // days DD - 'T'. // separator T - '([0-9]{2}):'. // hours hh: - '([0-9]{2}):'. // minutes mm: - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - '/'; + * convert unix timestamp to ISO 8601 compliant date string + * + * @param int $timestamp Unix time stamp + * @param boolean $utc Whether the time stamp is UTC or local + * @return false|string ISO 8601 date string or false + * @access public + */ +function timestamp_to_iso8601($timestamp, $utc = true) +{ + $datestr = date('Y-m-d\TH:i:sO', $timestamp); + $pos = strrpos($datestr, "+"); + if ($pos === false) { + $pos = strrpos($datestr, "-"); + } + if ($pos !== false) { + if (strlen($datestr) == $pos + 5) { + $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); + } + } + if ($utc) { + $pattern = '/' . + '([0-9]{4})-' . // centuries & years CCYY- + '([0-9]{2})-' . // months MM- + '([0-9]{2})' . // days DD + 'T' . // separator T + '([0-9]{2}):' . // hours hh: + '([0-9]{2}):' . // minutes mm: + '([0-9]{2})(\.[0-9]*)?' . // seconds ss.ss... + '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; - if(preg_match($pattern,$datestr,$regs)){ - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); - } - return false; - } else { - return $datestr; - } + if (preg_match($pattern, $datestr, $regs)) { + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]); + } + return false; + } else { + return $datestr; + } } /** -* convert ISO 8601 compliant date string to unix timestamp -* -* @param string $datestr ISO 8601 compliant date string -* @return mixed Unix timestamp (int) or false -* @access public -*/ -function iso8601_to_timestamp($datestr){ - $pattern = '/'. - '([0-9]{4})-'. // centuries & years CCYY- - '([0-9]{2})-'. // months MM- - '([0-9]{2})'. // days DD - 'T'. // separator T - '([0-9]{2}):'. // hours hh: - '([0-9]{2}):'. // minutes mm: - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - '/'; - if(preg_match($pattern,$datestr,$regs)){ - // not utc - if($regs[8] != 'Z'){ - $op = substr($regs[8],0,1); - $h = substr($regs[8],1,2); - $m = substr($regs[8],strlen($regs[8])-2,2); - if($op == '-'){ - $regs[4] = $regs[4] + $h; - $regs[5] = $regs[5] + $m; - } elseif($op == '+'){ - $regs[4] = $regs[4] - $h; - $regs[5] = $regs[5] - $m; - } - } - return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); + * convert ISO 8601 compliant date string to unix timestamp + * + * @param string $datestr ISO 8601 compliant date string + * @return false|int Unix timestamp (int) or false + * @access public + */ +function iso8601_to_timestamp($datestr) +{ + $pattern = '/' . + '([0-9]{4})-' . // centuries & years CCYY- + '([0-9]{2})-' . // months MM- + '([0-9]{2})' . // days DD + 'T' . // separator T + '([0-9]{2}):' . // hours hh: + '([0-9]{2}):' . // minutes mm: + '([0-9]{2})(\.[0-9]+)?' . // seconds ss.ss... + '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + if (preg_match($pattern, $datestr, $regs)) { + // not utc + if ($regs[8] != 'Z') { + $op = substr($regs[8], 0, 1); + $h = substr($regs[8], 1, 2); + $m = substr($regs[8], strlen($regs[8]) - 2, 2); + if ($op == '-') { + $regs[4] = intval ($regs[4]) + intval ($h); + $regs[5] = intval ($regs[5]) + intval ($m); + } elseif ($op == '+') { + $regs[4] = intval ($regs[4]) - intval ($h); + $regs[5] = intval ($regs[5]) - intval ($m); + } + } + return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); - } else { - return false; - } + } else { + return false; + } } /** -* sleeps some number of microseconds -* -* @param string $usec the number of microseconds to sleep -* @access public -* @deprecated -*/ + * sleeps some number of microseconds + * + * @param string $usec the number of microseconds to sleep + * @access public + * @deprecated + */ function usleepWindows($usec) { - $start = gettimeofday(); + $start = gettimeofday(); - do - { - $stop = gettimeofday(); - $timePassed = 1000000 * ($stop['sec'] - $start['sec']) - + $stop['usec'] - $start['usec']; - } - while ($timePassed < $usec); + do { + $stop = gettimeofday(); + $timePassed = 1000000 * ($stop['sec'] - $start['sec']) + + $stop['usec'] - $start['usec']; + } while ($timePassed < $usec); } -?> -* @access public -*/ -class nusoap_fault extends nusoap_base { - /** - * The fault code (client|server) - * @var string - * @access private - */ - var $faultcode; - /** - * The fault actor - * @var string - * @access private - */ - var $faultactor; - /** - * The fault string, a description of the fault - * @var string - * @access private - */ - var $faultstring; - /** - * The fault detail, typically a string or array of string - * @var mixed - * @access private - */ - var $faultdetail; + * Contains information for a SOAP fault. + * Mainly used for returning faults from deployed functions + * in a server instance. + * + * @author Dietrich Ayala + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class nusoap_fault extends nusoap_base +{ + /** + * The fault code (client|server) + * + * @var string + * @access private + */ + var $faultcode; + /** + * The fault actor + * + * @var string + * @access private + */ + var $faultactor; + /** + * The fault string, a description of the fault + * + * @var string + * @access private + */ + var $faultstring; + /** + * The fault detail, typically a string or array of string + * + * @var mixed + * @access private + */ + var $faultdetail; - /** - * constructor - * - * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) - * @param string $faultactor only used when msg routed between multiple actors - * @param string $faultstring human readable error message - * @param mixed $faultdetail detail, typically a string or array of string - */ - function __construct($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ - parent::__construct(); - $this->faultcode = $faultcode; - $this->faultactor = $faultactor; - $this->faultstring = $faultstring; - $this->faultdetail = $faultdetail; - } + /** + * constructor + * + * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) + * @param string $faultactor only used when msg routed between multiple actors + * @param string $faultstring human readable error message + * @param mixed $faultdetail detail, typically a string or array of string + */ + function __construct($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') + { + parent::__construct(); + $this->faultcode = $faultcode; + $this->faultactor = $faultactor; + $this->faultstring = $faultstring; + $this->faultdetail = $faultdetail; + } - /** - * serialize a fault - * - * @return string The serialization of the fault instance. - * @access public - */ - function serialize(){ - $ns_string = ''; - foreach($this->namespaces as $k => $v){ - $ns_string .= "\n xmlns:$k=\"$v\""; - } - $return_msg = - 'soap_defencoding.'"?>'. - '\n". - ''. - ''. - $this->serialize_val($this->faultcode, 'faultcode'). - $this->serialize_val($this->faultactor, 'faultactor'). - $this->serialize_val($this->faultstring, 'faultstring'). - $this->serialize_val($this->faultdetail, 'detail'). - ''. - ''. - ''; - return $return_msg; - } + /** + * serialize a fault + * + * @return string The serialization of the fault instance. + * @access public + */ + function serialize() + { + $ns_string = ''; + foreach ($this->namespaces as $k => $v) { + $ns_string .= "\n xmlns:$k=\"$v\""; + } + + return 'soap_defencoding . '"?>' . + '\n" . + '' . + '' . + $this->serialize_val($this->faultcode, 'faultcode') . + $this->serialize_val($this->faultstring, 'faultstring') . + $this->serialize_val($this->faultactor, 'faultactor') . + $this->serialize_val($this->faultdetail, 'detail') . + '' . + '' . + ''; + } } + /** * Backward compatibility */ -class soap_fault extends nusoap_fault { +class soap_fault extends nusoap_fault +{ } -?> -* @author Scott Nichol -* @access public -*/ -class nusoap_xmlschema extends nusoap_base { + * parses an XML Schema, allows access to it's data, other utility methods. + * imperfect, no validation... yet, but quite functional. + * + * @author Dietrich Ayala + * @author Scott Nichol + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class nusoap_xmlschema extends nusoap_base +{ - // files - var $schema = ''; - var $xml = ''; - // namespaces - var $enclosingNamespaces; - // schema info - var $schemaInfo = array(); - var $schemaTargetNamespace = ''; - // types, elements, attributes defined by the schema - var $attributes = array(); - var $complexTypes = array(); - var $complexTypeStack = array(); - var $currentComplexType = null; - var $elements = array(); - var $elementStack = array(); - var $currentElement = null; - var $simpleTypes = array(); - var $simpleTypeStack = array(); - var $currentSimpleType = null; - // imports - var $imports = array(); - // parser vars - var $parser; - var $position = 0; - var $depth = 0; - var $depth_array = array(); - var $message = array(); - var $defaultNamespace = array(); - - /** - * constructor - * - * @param string $schema schema document URI - * @param string $xml xml document URI - * @param string $namespaces namespaces defined in enclosing XML - * @access public - */ - function __construct($schema='',$xml='',$namespaces=array()){ - parent::__construct(); - $this->debug('nusoap_xmlschema class instantiated, inside constructor'); - // files - $this->schema = $schema; - $this->xml = $xml; - - // namespaces - $this->enclosingNamespaces = $namespaces; - $this->namespaces = array_merge($this->namespaces, $namespaces); - - // parse schema file - if($schema != ''){ - $this->debug('initial schema file: '.$schema); - $this->parseFile($schema, 'schema'); - } - - // parse xml file - if($xml != ''){ - $this->debug('initial xml file: '.$xml); - $this->parseFile($xml, 'xml'); - } - - } + // files + var $schema = ''; + var $xml = ''; + // namespaces + var $enclosingNamespaces; + // schema info + var $schemaInfo = array(); + var $schemaTargetNamespace = ''; + // types, elements, attributes defined by the schema + var $attributes = array(); + var $complexTypes = array(); + var $complexTypeStack = array(); + var $currentComplexType = null; + var $elements = array(); + var $elementStack = array(); + var $currentElement = null; + var $simpleTypes = array(); + var $simpleTypeStack = array(); + var $currentSimpleType = null; + // imports + var $imports = array(); + // parser vars + var $parser; + var $position = 0; + var $depth = 0; + var $depth_array = array(); + var $message = array(); + var $defaultNamespace = array(); /** - * parse an XML file - * - * @param string $xml path/URL to XML file - * @param string $type (schema | xml) - * @return boolean - * @access public - */ - function parseFile($xml,$type){ - // parse xml file - if($xml != ""){ - $xmlStr = @join("",@file($xml)); - if($xmlStr == ""){ - $msg = 'Error reading XML from '.$xml; - $this->setError($msg); - $this->debug($msg); - return false; - } else { - $this->debug("parsing $xml"); - $this->parseString($xmlStr,$type); - $this->debug("done parsing $xml"); - return true; - } - } - return false; - } + * constructor + * + * @param string $schema schema document URI + * @param string $xml xml document URI + * @param string $namespaces namespaces defined in enclosing XML + * @access public + */ + function __construct($schema = '', $xml = '', $namespaces = array()) + { + parent::__construct(); + $this->debug('nusoap_xmlschema class instantiated, inside constructor'); + // files + $this->schema = $schema; + $this->xml = $xml; - /** - * parse an XML string - * - * @param string $xml path or URL - * @param string $type (schema|xml) - * @access private - */ - function parseString($xml,$type){ - // parse xml string - if($xml != ""){ + // namespaces + $this->enclosingNamespaces = $namespaces; + $this->namespaces = array_merge($this->namespaces, $namespaces); - // Create an XML parser. - $this->parser = xml_parser_create(); - // Set the options for parsing the XML data. - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + // parse schema file + if ($schema != '') { + $this->debug('initial schema file: ' . $schema); + $this->parseFile($schema, 'schema'); + } - // Set the object for the parser. - xml_set_object($this->parser, $this); + // parse xml file + if ($xml != '') { + $this->debug('initial xml file: ' . $xml); + $this->parseFile($xml, 'xml'); + } - // Set the element handlers for the parser. - if($type == "schema"){ - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); - xml_set_character_data_handler($this->parser,'schemaCharacterData'); - } elseif($type == "xml"){ - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); - xml_set_character_data_handler($this->parser,'xmlCharacterData'); - } + } - // Parse the XML file. - if(!xml_parse($this->parser,$xml,true)){ - // Display an error message. - $errstr = sprintf('XML error parsing XML schema on line %d: %s', - xml_get_current_line_number($this->parser), - xml_error_string(xml_get_error_code($this->parser)) - ); - $this->debug($errstr); - $this->debug("XML payload:\n" . $xml); - $this->setError($errstr); - } + /** + * parse an XML file + * + * @param string $xml path/URL to XML file + * @param string $type (schema | xml) + * @return boolean + * @access public + */ + function parseFile($xml, $type) + { + // parse xml file + if ($xml != "") { + $xmlStr = @join("", @file($xml)); + if ($xmlStr == "") { + $msg = 'Error reading XML from ' . $xml; + $this->setError($msg); + $this->debug($msg); + return false; + } else { + $this->debug("parsing $xml"); + $this->parseString($xmlStr, $type); + $this->debug("done parsing $xml"); + return true; + } + } + return false; + } - xml_parser_free($this->parser); - } else{ - $this->debug('no xml passed to parseString()!!'); - $this->setError('no xml passed to parseString()!!'); - } - } + /** + * parse an XML string + * + * @param string $xml path or URL + * @param string $type (schema|xml) + * @access private + */ + function parseString($xml, $type) + { + // parse xml string + if ($xml != "") { - /** - * gets a type name for an unnamed type - * - * @param string Element name - * @return string A type name for an unnamed type - * @access private - */ - function CreateTypeName($ename) { - $scope = ''; - for ($i = 0; $i < count($this->complexTypeStack); $i++) { - $scope .= $this->complexTypeStack[$i] . '_'; - } - return $scope . $ename . '_ContainedType'; - } + // Create an XML parser. + $this->parser = xml_parser_create(); + // Set the options for parsing the XML data. + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); - /** - * start-element handler - * - * @param string $parser XML parser object - * @param string $name element name - * @param string $attrs associative array of attributes - * @access private - */ - function schemaStartElement($parser, $name, $attrs) { + // Set the object for the parser. + xml_set_object($this->parser, $this); - // position in the total number of elements, starting from 0 - $pos = $this->position++; - $depth = $this->depth++; - // set self as current value for this depth - $this->depth_array[$depth] = $pos; - $this->message[$pos] = array('cdata' => ''); - if ($depth > 0) { - $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; - } else { - $this->defaultNamespace[$pos] = false; - } + // Set the element handlers for the parser. + if ($type == "schema") { + xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); + xml_set_character_data_handler($this->parser, 'schemaCharacterData'); + } elseif ($type == "xml") { + xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); + xml_set_character_data_handler($this->parser, 'xmlCharacterData'); + } - // get element prefix - if($prefix = $this->getPrefix($name)){ - // get unqualified name - $name = $this->getLocalPart($name); - } else { - $prefix = ''; + libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only for libxml < 2. + + // Parse the XML file. + if (!xml_parse($this->parser, $xml, true)) { + // Display an error message. + $errstr = sprintf('XML error parsing XML schema on line %d: %s', + xml_get_current_line_number($this->parser), + xml_error_string(xml_get_error_code($this->parser)) + ); + $this->debug($errstr); + $this->debug("XML payload:\n" . $xml); + $this->setError($errstr); + } + + xml_parser_free($this->parser); + unset($this->parser); + } else { + $this->debug('no xml passed to parseString()!!'); + $this->setError('no xml passed to parseString()!!'); + } + } + + /** + * gets a type name for an unnamed type + * + * @param string $ename Element name + * @return string A type name for an unnamed type + * @access private + */ + function CreateTypeName($ename) + { + $scope = ''; + for ($i = 0; $i < count($this->complexTypeStack); $i++) { + $scope .= $this->complexTypeStack[$i] . '_'; + } + return $scope . $ename . '_ContainedType'; + } + + /** + * start-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @param array $attrs associative array of attributes + * @access private + */ + function schemaStartElement($parser, $name, $attrs) + { + + // position in the total number of elements, starting from 0 + $pos = $this->position++; + $depth = $this->depth++; + // set self as current value for this depth + $this->depth_array[$depth] = $pos; + $this->message[$pos] = array('cdata' => ''); + if ($depth > 0) { + $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; + } else { + $this->defaultNamespace[$pos] = false; + } + + // get element prefix + if ($prefix = $this->getPrefix($name)) { + // get unqualified name + $name = $this->getLocalPart($name); + } else { + $prefix = ''; } // loop thru attributes, expanding, and registering namespace declarations - if(count($attrs) > 0){ - foreach($attrs as $k => $v){ + if (count($attrs) > 0) { + foreach ($attrs as $k => $v) { // if ns declarations, add to class level array of valid namespaces - if(preg_match('/^xmlns/',$k)){ - //$this->xdebug("$k: $v"); - //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); - if($ns_prefix = substr(strrchr($k,':'),1)){ - //$this->xdebug("Add namespace[$ns_prefix] = $v"); - $this->namespaces[$ns_prefix] = $v; - } else { - $this->defaultNamespace[$pos] = $v; - if (! $this->getPrefixFromNamespace($v)) { - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; - } - } - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){ - $this->XMLSchemaVersion = $v; - $this->namespaces['xsi'] = $v.'-instance'; - } - } - } - foreach($attrs as $k => $v){ + if (preg_match('/^xmlns/', $k)) { + //$this->xdebug("$k: $v"); + //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); + if ($ns_prefix = substr(strrchr($k, ':'), 1)) { + //$this->xdebug("Add namespace[$ns_prefix] = $v"); + $this->namespaces[$ns_prefix] = $v; + } else { + $this->defaultNamespace[$pos] = $v; + if (!$this->getPrefixFromNamespace($v)) { + $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; + } + } + if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { + $this->XMLSchemaVersion = $v; + $this->namespaces['xsi'] = $v . '-instance'; + } + } + } + $eAttrs = array (); + foreach ($attrs as $k => $v) { // expand each attribute - $k = strpos($k,':') ? $this->expandQname($k) : $k; - $v = strpos($v,':') ? $this->expandQname($v) : $v; - $eAttrs[$k] = $v; - } - $attrs = $eAttrs; + $k = strpos($k, ':') ? $this->expandQname($k) : $k; + $v = strpos($v, ':') ? $this->expandQname($v) : $v; + $eAttrs[$k] = $v; + } + $attrs = $eAttrs; } else { - $attrs = array(); + $attrs = array(); } - // find status, register data - switch($name){ - case 'all': // (optional) compositor content for a complexType - case 'choice': - case 'group': - case 'sequence': - //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement"); - $this->complexTypes[$this->currentComplexType]['compositor'] = $name; - //if($name == 'all' || $name == 'sequence'){ - // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - //} - break; - case 'attribute': // complexType attribute - //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']); - $this->xdebug("parsing attribute:"); - $this->appendDebug($this->varDump($attrs)); - if (!isset($attrs['form'])) { - // TODO: handle globals - $attrs['form'] = $this->schemaInfo['attributeFormDefault']; - } - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - if (!strpos($v, ':')) { - // no namespace in arrayType attribute value... - if ($this->defaultNamespace[$pos]) { - // ...so use the default - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } - } - } - if(isset($attrs['name'])){ - $this->attributes[$attrs['name']] = $attrs; - $aname = $attrs['name']; - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){ - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { - $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } else { - $aname = ''; - } - } elseif(isset($attrs['ref'])){ - $aname = $attrs['ref']; + // find status, register data + switch ($name) { + case 'all': // (optional) compositor content for a complexType + case 'choice': + case 'group': + case 'sequence': + //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement"); + $this->complexTypes[$this->currentComplexType]['compositor'] = $name; + //if($name == 'all' || $name == 'sequence'){ + // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; + //} + break; + case 'attribute': // complexType attribute + //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']); + $this->xdebug("parsing attribute:"); + $this->appendDebug($this->varDump($attrs)); + if (!isset($attrs['form'])) { + // TODO: handle globals + $attrs['form'] = $this->schemaInfo['attributeFormDefault']; + } + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; + if (!strpos($v, ':')) { + // no namespace in arrayType attribute value... + if ($this->defaultNamespace[$pos]) { + // ...so use the default + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; + } + } + } + if (isset($attrs['name'])) { + $this->attributes[$attrs['name']] = $attrs; + $aname = $attrs['name']; + } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') { + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { + $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; + } else { + $aname = ''; + } + } elseif (isset($attrs['ref'])) { + $aname = $attrs['ref']; $this->attributes[$attrs['ref']] = $attrs; - } + } else { + $aname = ''; + } - if($this->currentComplexType){ // This should *always* be - $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; - } - // arrayType attribute - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){ - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - $prefix = $this->getPrefix($aname); - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){ - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } else { - $v = ''; - } - if(strpos($v,'[,]')){ + if ($this->currentComplexType) { // This should *always* be + $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; + } + // arrayType attribute + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') { + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; + } else { + $v = ''; + } + if (strpos($v, '[,]')) { $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; } - $v = substr($v,0,strpos($v,'[')); // clip the [] - if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){ - $v = $this->XMLSchemaVersion.':'.$v; + $v = substr($v, 0, strpos($v, '[')); // clip the [] + if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) { + $v = $this->XMLSchemaVersion . ':' . $v; } $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; - } - break; - case 'complexContent': // (optional) content for a complexType - $this->xdebug("do nothing for element $name"); - break; - case 'complexType': - array_push($this->complexTypeStack, $this->currentComplexType); - if(isset($attrs['name'])){ - // TODO: what is the scope of named complexTypes that appear - // nested within other c complexTypes? - $this->xdebug('processing named complexType '.$attrs['name']); - //$this->currentElement = false; - $this->currentComplexType = $attrs['name']; - $this->complexTypes[$this->currentComplexType] = $attrs; - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; - // This is for constructs like - // - // - // - // - // - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ - $this->xdebug('complexType is unusual array'); - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } else { - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - } - } else { - $name = $this->CreateTypeName($this->currentElement); - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name); - $this->currentComplexType = $name; - //$this->currentElement = false; - $this->complexTypes[$this->currentComplexType] = $attrs; - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; - // This is for constructs like - // - // - // - // - // - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ - $this->xdebug('complexType is unusual array'); - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } else { - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - } - } - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; - break; - case 'element': - array_push($this->elementStack, $this->currentElement); - if (!isset($attrs['form'])) { - if ($this->currentComplexType) { - $attrs['form'] = $this->schemaInfo['elementFormDefault']; - } else { - // global - $attrs['form'] = 'qualified'; - } - } - if(isset($attrs['type'])){ - $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']); - if (! $this->getPrefix($attrs['type'])) { - if ($this->defaultNamespace[$pos]) { - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; - $this->xdebug('used default namespace to make type ' . $attrs['type']); - } - } - // This is for constructs like - // - // - // - // - // - if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') { - $this->xdebug('arrayType for unusual array is ' . $attrs['type']); - $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; - } - $this->currentElement = $attrs['name']; - $ename = $attrs['name']; - } elseif(isset($attrs['ref'])){ - $this->xdebug("processing element as ref to ".$attrs['ref']); - $this->currentElement = "ref to ".$attrs['ref']; - $ename = $this->getLocalPart($attrs['ref']); - } else { - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type); - $this->currentElement = $attrs['name']; - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; - $ename = $attrs['name']; - } - if (isset($ename) && $this->currentComplexType) { - $this->xdebug("add element $ename to complexType $this->currentComplexType"); - $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; - } elseif (!isset($attrs['ref'])) { - $this->xdebug("add element $ename to elements array"); - $this->elements[ $attrs['name'] ] = $attrs; - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; - } - break; - case 'enumeration': // restriction value list member - $this->xdebug('enumeration ' . $attrs['value']); - if ($this->currentSimpleType) { - $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; - } elseif ($this->currentComplexType) { - $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; - } - break; - case 'extension': // simpleContent or complexContent type extension - $this->xdebug('extension ' . $attrs['base']); - if ($this->currentComplexType) { - $ns = $this->getPrefix($attrs['base']); - if ($ns == '') { - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; - } else { - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; - } - } else { - $this->xdebug('no current complexType to set extensionBase'); - } - break; - case 'import': - if (isset($attrs['schemaLocation'])) { - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']); + } + break; + case 'complexContent': // (optional) content for a complexType + $this->xdebug("do nothing for element $name"); + break; + case 'complexType': + $this->complexTypeStack[] = $this->currentComplexType; + if (isset($attrs['name'])) { + // TODO: what is the scope of named complexTypes that appear + // nested within other c complexTypes? + $this->xdebug('processing named complexType ' . $attrs['name']); + //$this->currentElement = false; + $this->currentComplexType = $attrs['name']; + } else { + $name = $this->CreateTypeName($this->currentElement); + $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name); + $this->currentComplexType = $name; + //$this->currentElement = false; + } + $this->complexTypes[$this->currentComplexType] = $attrs; + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; + // This is for constructs like + // + // + // + // + // + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) { + $this->xdebug('complexType is unusual array'); + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + } else { + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; + } + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; + break; + case 'element': + $this->elementStack[] = $this->currentElement; + if (!isset($attrs['form'])) { + if ($this->currentComplexType) { + $attrs['form'] = $this->schemaInfo['elementFormDefault']; + } else { + // global + $attrs['form'] = 'qualified'; + } + } + if (isset($attrs['type'])) { + $this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']); + if (!$this->getPrefix($attrs['type'])) { + if ($this->defaultNamespace[$pos]) { + $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; + $this->xdebug('used default namespace to make type ' . $attrs['type']); + } + } + // This is for constructs like + // + // + // + // + // + if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') { + $this->xdebug('arrayType for unusual array is ' . $attrs['type']); + $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; + } + $this->currentElement = $attrs['name']; + $ename = $attrs['name']; + } elseif (isset($attrs['ref'])) { + $this->xdebug("processing element as ref to " . $attrs['ref']); + $this->currentElement = "ref to " . $attrs['ref']; + $ename = $this->getLocalPart($attrs['ref']); + } else { + $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); + $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type); + $this->currentElement = $attrs['name']; + $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; + $ename = $attrs['name']; + } + if (isset($ename) && $this->currentComplexType) { + $this->xdebug("add element $ename to complexType $this->currentComplexType"); + $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; + } elseif (!isset($attrs['ref'])) { + $this->xdebug("add element $ename to elements array"); + $this->elements[$attrs['name']] = $attrs; + $this->elements[$attrs['name']]['typeClass'] = 'element'; + } + break; + case 'enumeration': // restriction value list member + $this->xdebug('enumeration ' . $attrs['value']); + if ($this->currentSimpleType) { + $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; + } elseif ($this->currentComplexType) { + $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; + } + break; + case 'extension': // simpleContent or complexContent type extension + $this->xdebug('extension ' . $attrs['base']); + if ($this->currentComplexType) { + $ns = $this->getPrefix($attrs['base']); + if ($ns == '') { + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; + } else { + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; + } + } else { + $this->xdebug('no current complexType to set extensionBase'); + } + break; + case 'import': + if (isset($attrs['schemaLocation'])) { + $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']); $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); - } else { - $this->xdebug('import namespace ' . $attrs['namespace']); + } else { + $this->xdebug('import namespace ' . $attrs['namespace']); $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true); - if (! $this->getPrefixFromNamespace($attrs['namespace'])) { - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; - } - } - break; - case 'include': - if (isset($attrs['schemaLocation'])) { - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']); + if (!$this->getPrefixFromNamespace($attrs['namespace'])) { + $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace']; + } + } + break; + case 'include': + if (isset($attrs['schemaLocation'])) { + $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']); $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); - } else { - $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute'); - } - break; - case 'list': // simpleType value list - $this->xdebug("do nothing for element $name"); - break; - case 'restriction': // simpleType, simpleContent or complexContent value restriction - $this->xdebug('restriction ' . $attrs['base']); - if($this->currentSimpleType){ - $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; - } elseif($this->currentComplexType){ - $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; - if(strstr($attrs['base'],':') == ':Array'){ - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } - } - break; - case 'schema': - $this->schemaInfo = $attrs; - $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); - if (isset($attrs['targetNamespace'])) { - $this->schemaTargetNamespace = $attrs['targetNamespace']; - } - if (!isset($attrs['elementFormDefault'])) { - $this->schemaInfo['elementFormDefault'] = 'unqualified'; - } - if (!isset($attrs['attributeFormDefault'])) { - $this->schemaInfo['attributeFormDefault'] = 'unqualified'; - } - break; - case 'simpleContent': // (optional) content for a complexType - if ($this->currentComplexType) { // This should *always* be - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; - } else { - $this->xdebug("do nothing for element $name because there is no current complexType"); - } - break; - case 'simpleType': - array_push($this->simpleTypeStack, $this->currentSimpleType); - if(isset($attrs['name'])){ - $this->xdebug("processing simpleType for name " . $attrs['name']); - $this->currentSimpleType = $attrs['name']; - $this->simpleTypes[ $attrs['name'] ] = $attrs; - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; - } else { - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name); - $this->currentSimpleType = $name; - //$this->currentElement = false; - $this->simpleTypes[$this->currentSimpleType] = $attrs; - $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; - } - break; - case 'union': // simpleType type list - $this->xdebug("do nothing for element $name"); - break; - default: - $this->xdebug("do not have any logic to process element $name"); - } - } - - /** - * end-element handler - * - * @param string $parser XML parser object - * @param string $name element name - * @access private - */ - function schemaEndElement($parser, $name) { - // bring depth down a notch - $this->depth--; - // position of current element is equal to the last value left in depth_array for my depth - if(isset($this->depth_array[$this->depth])){ - $pos = $this->depth_array[$this->depth]; + } else { + $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute'); + } + break; + case 'list': // simpleType value list + $this->xdebug("do nothing for element $name"); + break; + case 'restriction': // simpleType, simpleContent or complexContent value restriction + $this->xdebug('restriction ' . $attrs['base']); + if ($this->currentSimpleType) { + $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; + } elseif ($this->currentComplexType) { + $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; + if (strstr($attrs['base'], ':') == ':Array') { + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + } + } + break; + case 'schema': + $this->schemaInfo = $attrs; + $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); + if (isset($attrs['targetNamespace'])) { + $this->schemaTargetNamespace = $attrs['targetNamespace']; + } + if (!isset($attrs['elementFormDefault'])) { + $this->schemaInfo['elementFormDefault'] = 'unqualified'; + } + if (!isset($attrs['attributeFormDefault'])) { + $this->schemaInfo['attributeFormDefault'] = 'unqualified'; + } + break; + case 'simpleContent': // (optional) content for a complexType + if ($this->currentComplexType) { // This should *always* be + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; + } else { + $this->xdebug("do nothing for element $name because there is no current complexType"); + } + break; + case 'simpleType': + $this->simpleTypeStack[] = $this->currentSimpleType; + if (isset($attrs['name'])) { + $this->xdebug("processing simpleType for name " . $attrs['name']); + $this->currentSimpleType = $attrs['name']; + $this->simpleTypes[$attrs['name']] = $attrs; + $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType'; + $this->simpleTypes[$attrs['name']]['phpType'] = 'scalar'; + } else { + $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); + $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name); + $this->currentSimpleType = $name; + //$this->currentElement = false; + $this->simpleTypes[$this->currentSimpleType] = $attrs; + $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; + } + break; + case 'union': // simpleType type list + $this->xdebug("do nothing for element $name"); + break; + default: + $this->xdebug("do not have any logic to process element $name"); } - // get element prefix - if ($prefix = $this->getPrefix($name)){ - // get unqualified name - $name = $this->getLocalPart($name); - } else { - $prefix = ''; - } - // move on... - if($name == 'complexType'){ - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)')); - $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); - $this->currentComplexType = array_pop($this->complexTypeStack); - //$this->currentElement = false; - } - if($name == 'element'){ - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)')); - $this->currentElement = array_pop($this->elementStack); - } - if($name == 'simpleType'){ - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)')); - $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); - $this->currentSimpleType = array_pop($this->simpleTypeStack); - } - } - - /** - * element content handler - * - * @param string $parser XML parser object - * @param string $data element content - * @access private - */ - function schemaCharacterData($parser, $data){ - $pos = $this->depth_array[$this->depth - 1]; - $this->message[$pos]['cdata'] .= $data; - } - - /** - * serialize the schema - * - * @access public - */ - function serializeSchema(){ - - $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); - $xml = ''; - // imports - if (sizeof($this->imports) > 0) { - foreach($this->imports as $ns => $list) { - foreach ($list as $ii) { - if ($ii['location'] != '') { - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; - } else { - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; - } - } - } - } - // complex types - foreach($this->complexTypes as $typeName => $attrs){ - $contentStr = ''; - // serialize child elements - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){ - foreach($attrs['elements'] as $element => $eParts){ - if(isset($eParts['ref'])){ - $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; - } else { - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; - foreach ($eParts as $aName => $aValue) { - // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable - if ($aName != 'name' && $aName != 'type') { - $contentStr .= " $aName=\"$aValue\""; - } - } - $contentStr .= "/>\n"; - } - } - // compositor wraps elements - if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) { - $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." \n"; - } - } - // attributes - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){ - foreach($attrs['attrs'] as $attr => $aParts){ - $contentStr .= " <$schemaPrefix:attribute"; - foreach ($aParts as $a => $v) { - if ($a == 'ref' || $a == 'type') { - $contentStr .= " $a=\"".$this->contractQName($v).'"'; - } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') { - $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; - $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; - } else { - $contentStr .= " $a=\"$v\""; - } - } - $contentStr .= "/>\n"; - } - } - // if restriction - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){ - $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." \n"; - // complex or simple content - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){ - $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." \n"; - } - } - // finalize complex type - if($contentStr != ''){ - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." \n"; - } else { - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; - } - $xml .= $contentStr; - } - // simple types - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){ - foreach($this->simpleTypes as $typeName => $eParts){ - $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; - if (isset($eParts['enumeration'])) { - foreach ($eParts['enumeration'] as $e) { - $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; - } - } - $xml .= " \n "; - } - } - // elements - if(isset($this->elements) && count($this->elements) > 0){ - foreach($this->elements as $element => $eParts){ - $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; - } - } - // attributes - if(isset($this->attributes) && count($this->attributes) > 0){ - foreach($this->attributes as $attr => $aParts){ - $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; - } - } - // finish 'er up - $attr = ''; - foreach ($this->schemaInfo as $k => $v) { - if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') { - $attr .= " $k=\"$v\""; - } - } - $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; - foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) { - $el .= " xmlns:$nsp=\"$ns\""; - } - $xml = $el . ">\n".$xml."\n"; - return $xml; - } - - /** - * adds debug data to the clas level debug string - * - * @param string $string debug data - * @access private - */ - function xdebug($string){ - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string); - } - - /** - * get the PHP type of a user defined type in the schema - * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays - * returns false if no type exists, or not w/ the given namespace - * else returns a string that is either a native php type, or 'struct' - * - * @param string $type name of defined type - * @param string $ns namespace of type - * @return mixed - * @access public - * @deprecated - */ - function getPHPType($type,$ns){ - if(isset($this->typemap[$ns][$type])){ - //print "found type '$type' and ns $ns in typemap
"; - return $this->typemap[$ns][$type]; - } elseif(isset($this->complexTypes[$type])){ - //print "getting type '$type' and ns $ns from complexTypes array
"; - return $this->complexTypes[$type]['phpType']; - } - return false; - } - - /** - * returns an associative array of information about a given type - * returns false if no type exists by the given name - * - * For a complexType typeDef = array( - * 'restrictionBase' => '', - * 'phpType' => '', - * 'compositor' => '(sequence|all)', - * 'elements' => array(), // refs to elements array - * 'attrs' => array() // refs to attributes array - * ... and so on (see addComplexType) - * ) - * - * For simpleType or element, the array has different keys. - * - * @param string $type - * @return mixed - * @access public - * @see addComplexType - * @see addSimpleType - * @see addElement - */ - function getTypeDef($type){ - //$this->debug("in getTypeDef for type $type"); - if (substr($type, -1) == '^') { - $is_element = 1; - $type = substr($type, 0, -1); - } else { - $is_element = 0; - } - - if((! $is_element) && isset($this->complexTypes[$type])){ - $this->xdebug("in getTypeDef, found complexType $type"); - return $this->complexTypes[$type]; - } elseif((! $is_element) && isset($this->simpleTypes[$type])){ - $this->xdebug("in getTypeDef, found simpleType $type"); - if (!isset($this->simpleTypes[$type]['phpType'])) { - // get info for type to tack onto the simple type - // TODO: can this ever really apply (i.e. what is a simpleType really?) - $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); - $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); - $etype = $this->getTypeDef($uqType); - if ($etype) { - $this->xdebug("in getTypeDef, found type for simpleType $type:"); - $this->xdebug($this->varDump($etype)); - if (isset($etype['phpType'])) { - $this->simpleTypes[$type]['phpType'] = $etype['phpType']; - } - if (isset($etype['elements'])) { - $this->simpleTypes[$type]['elements'] = $etype['elements']; - } - } - } - return $this->simpleTypes[$type]; - } elseif(isset($this->elements[$type])){ - $this->xdebug("in getTypeDef, found element $type"); - if (!isset($this->elements[$type]['phpType'])) { - // get info for type to tack onto the element - $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); - $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); - $etype = $this->getTypeDef($uqType); - if ($etype) { - $this->xdebug("in getTypeDef, found type for element $type:"); - $this->xdebug($this->varDump($etype)); - if (isset($etype['phpType'])) { - $this->elements[$type]['phpType'] = $etype['phpType']; - } - if (isset($etype['elements'])) { - $this->elements[$type]['elements'] = $etype['elements']; - } - if (isset($etype['extensionBase'])) { - $this->elements[$type]['extensionBase'] = $etype['extensionBase']; - } - } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') { - $this->xdebug("in getTypeDef, element $type is an XSD type"); - $this->elements[$type]['phpType'] = 'scalar'; - } - } - return $this->elements[$type]; - } elseif(isset($this->attributes[$type])){ - $this->xdebug("in getTypeDef, found attribute $type"); - return $this->attributes[$type]; - } elseif (preg_match('/_ContainedType$/', $type)) { - $this->xdebug("in getTypeDef, have an untyped element $type"); - $typeDef['typeClass'] = 'simpleType'; - $typeDef['phpType'] = 'scalar'; - $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; - return $typeDef; - } - $this->xdebug("in getTypeDef, did not find $type"); - return false; - } - - /** - * returns a sample serialization of a given type, or false if no type by the given name - * - * @param string $type name of type - * @return mixed - * @access public - * @deprecated - */ - function serializeTypeDef($type){ - //print "in sTD() for type $type
"; - if($typeDef = $this->getTypeDef($type)){ - $str .= '<'.$type; - if(is_array($typeDef['attrs'])){ - foreach($typeDef['attrs'] as $attName => $data){ - $str .= " $attName=\"{type = ".$data['type']."}\""; - } - } - $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; - if(count($typeDef['elements']) > 0){ - $str .= ">"; - foreach($typeDef['elements'] as $element => $eData){ - $str .= $this->serializeTypeDef($element); - } - $str .= ""; - } elseif($typeDef['typeClass'] == 'element') { - $str .= ">"; - } else { - $str .= "/>"; - } - return $str; - } - return false; } /** - * returns HTML form elements that allow a user - * to enter values for creating an instance of the given type. - * - * @param string $name name for type instance - * @param string $type name of type - * @return string - * @access public - * @deprecated - */ - function typeToForm($name,$type){ - // get typedef - if($typeDef = $this->getTypeDef($type)){ - // if struct - if($typeDef['phpType'] == 'struct'){ - $buffer .= ''; - foreach($typeDef['elements'] as $child => $childDef){ - $buffer .= " - - "; - } - $buffer .= '
$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):
'; - // if array - } elseif($typeDef['phpType'] == 'array'){ - $buffer .= ''; - for($i=0;$i < 3; $i++){ - $buffer .= " + * end-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @access private + */ + function schemaEndElement($parser, $name) + { + // bring depth down a notch + $this->depth--; + // get element prefix + if ($this->getPrefix($name)) { + // get unqualified name + $name = $this->getLocalPart($name); + } + // move on... + if ($name == 'complexType') { + $this->xdebug('done processing complexType ' . ($this->currentComplexType ?: '(unknown)')); + $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); + $this->currentComplexType = array_pop($this->complexTypeStack); + //$this->currentElement = false; + } + if ($name == 'element') { + $this->xdebug('done processing element ' . ($this->currentElement ?: '(unknown)')); + $this->currentElement = array_pop($this->elementStack); + } + if ($name == 'simpleType') { + $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ?: '(unknown)')); + $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); + $this->currentSimpleType = array_pop($this->simpleTypeStack); + } + } + + /** + * element content handler + * + * @param string $parser XML parser object + * @param string $data element content + * @access private + */ + function schemaCharacterData($parser, $data) + { + $pos = $this->depth_array[$this->depth - 1]; + $this->message[$pos]['cdata'] .= $data; + } + + /** + * serialize the schema + * + * @access public + */ + function serializeSchema() + { + + $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); + $xml = ''; + // imports + if (sizeof($this->imports) > 0) { + foreach ($this->imports as $ns => $list) { + foreach ($list as $ii) { + if ($ii['location'] != '') { + $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; + } else { + $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; + } + } + } + } + // complex types + foreach ($this->complexTypes as $typeName => $attrs) { + $contentStr = ''; + // serialize child elements + if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) { + foreach ($attrs['elements'] as $element => $eParts) { + if (isset($eParts['ref'])) { + $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; + } else { + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; + foreach ($eParts as $aName => $aValue) { + // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable + if ($aName != 'name' && $aName != 'type') { + $contentStr .= " $aName=\"$aValue\""; + } + } + $contentStr .= "/>\n"; + } + } + // compositor wraps elements + if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) { + $contentStr = " <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . " \n"; + } + } + // attributes + if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) { + foreach ($attrs['attrs'] as $aParts) { + $contentStr .= " <$schemaPrefix:attribute"; + foreach ($aParts as $a => $v) { + if ($a == 'ref' || $a == 'type') { + $contentStr .= " $a=\"" . $this->contractQName($v) . '"'; + } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') { + $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; + $contentStr .= ' wsdl:arrayType="' . $this->contractQName($v) . '"'; + } else { + $contentStr .= " $a=\"$v\""; + } + } + $contentStr .= "/>\n"; + } + } + // if restriction + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') { + $contentStr = " <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . " \n"; + // complex or simple content + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) { + $contentStr = " <$schemaPrefix:complexContent>\n" . $contentStr . " \n"; + } + } + // finalize complex type + if ($contentStr != '') { + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " \n"; + } else { + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; + } + $xml .= $contentStr; + } + // simple types + if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) { + foreach ($this->simpleTypes as $typeName => $eParts) { + $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"" . $this->contractQName($eParts['type']) . "\">\n"; + if (isset($eParts['enumeration'])) { + foreach ($eParts['enumeration'] as $e) { + $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; + } + } + $xml .= " \n "; + } + } + // elements + if (isset($this->elements) && count($this->elements) > 0) { + foreach ($this->elements as $element => $eParts) { + $xml .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n"; + } + } + // attributes + if (isset($this->attributes) && count($this->attributes) > 0) { + foreach ($this->attributes as $attr => $aParts) { + $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts['type']) . "\"\n/>"; + } + } + // finish 'er up + $attr = ''; + foreach ($this->schemaInfo as $k => $v) { + if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') { + $attr .= " $k=\"$v\""; + } + } + $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; + foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) { + $el .= " xmlns:$nsp=\"$ns\""; + } + + return $el . ">\n" . $xml . "\n"; + } + + /** + * adds debug data to the clas level debug string + * + * @param string $string debug data + * @access private + */ + function xdebug($string) + { + $this->debug('<' . $this->schemaTargetNamespace . '> ' . $string); + } + + /** + * get the PHP type of a user defined type in the schema + * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays + * returns false if no type exists, or not w/ the given namespace + * else returns a string that is either a native php type, or 'struct' + * + * @param string $type name of defined type + * @param string $ns namespace of type + * @return mixed + * @access public + * @deprecated + */ + function getPHPType($type, $ns) + { + if (isset($this->typemap[$ns][$type])) { + //print "found type '$type' and ns $ns in typemap
"; + return $this->typemap[$ns][$type]; + } elseif (isset($this->complexTypes[$type])) { + //print "getting type '$type' and ns $ns from complexTypes array
"; + return $this->complexTypes[$type]['phpType']; + } + return false; + } + + /** + * returns an associative array of information about a given type + * returns false if no type exists by the given name + * + * For a complexType typeDef = array( + * 'restrictionBase' => '', + * 'phpType' => '', + * 'compositor' => '(sequence|all)', + * 'elements' => array(), // refs to elements array + * 'attrs' => array() // refs to attributes array + * ... and so on (see addComplexType) + * ) + * + * For simpleType or element, the array has different keys. + * + * @param string $type + * @return mixed + * @access public + * @see addComplexType + * @see addSimpleType + * @see addElement + */ + function getTypeDef($type) + { + //$this->debug("in getTypeDef for type $type"); + if (substr($type, -1) == '^') { + $is_element = 1; + $type = substr($type, 0, -1); + } else { + $is_element = 0; + } + + if ((!$is_element) && isset($this->complexTypes[$type])) { + $this->xdebug("in getTypeDef, found complexType $type"); + return $this->complexTypes[$type]; + } elseif ((!$is_element) && isset($this->simpleTypes[$type])) { + $this->xdebug("in getTypeDef, found simpleType $type"); + if (!isset($this->simpleTypes[$type]['phpType'])) { + // get info for type to tack onto the simple type + // TODO: can this ever really apply (i.e. what is a simpleType really?) + $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); + $etype = $this->getTypeDef($uqType); + if ($etype) { + $this->xdebug("in getTypeDef, found type for simpleType $type:"); + $this->xdebug($this->varDump($etype)); + if (isset($etype['phpType'])) { + $this->simpleTypes[$type]['phpType'] = $etype['phpType']; + } + if (isset($etype['elements'])) { + $this->simpleTypes[$type]['elements'] = $etype['elements']; + } + } + } + return $this->simpleTypes[$type]; + } elseif (isset($this->elements[$type])) { + $this->xdebug("in getTypeDef, found element $type"); + if (!isset($this->elements[$type]['phpType'])) { + // get info for type to tack onto the element + $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); + $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); + $etype = $this->getTypeDef($uqType); + if ($etype) { + $this->xdebug("in getTypeDef, found type for element $type:"); + $this->xdebug($this->varDump($etype)); + if (isset($etype['phpType'])) { + $this->elements[$type]['phpType'] = $etype['phpType']; + } + if (isset($etype['elements'])) { + $this->elements[$type]['elements'] = $etype['elements']; + } + if (isset($etype['extensionBase'])) { + $this->elements[$type]['extensionBase'] = $etype['extensionBase']; + } + } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') { + $this->xdebug("in getTypeDef, element $type is an XSD type"); + $this->elements[$type]['phpType'] = 'scalar'; + } + } + return $this->elements[$type]; + } elseif (isset($this->attributes[$type])) { + $this->xdebug("in getTypeDef, found attribute $type"); + return $this->attributes[$type]; + } elseif (preg_match('/_ContainedType$/', $type)) { + $this->xdebug("in getTypeDef, have an untyped element $type"); + $typeDef['typeClass'] = 'simpleType'; + $typeDef['phpType'] = 'scalar'; + $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; + return $typeDef; + } + $this->xdebug("in getTypeDef, did not find $type"); + return false; + } + + /** + * returns a sample serialization of a given type, or false if no type by the given name + * + * @param string $type name of type + * @return false|string + * @access public + */ + function serializeTypeDef($type) + { + $str = ''; + //print "in sTD() for type $type
"; + if ($typeDef = $this->getTypeDef($type)) { + $str .= '<' . $type; + if (is_array($typeDef['attrs'])) { + foreach ($typeDef['attrs'] as $attName => $data) { + $str .= " $attName=\"{type = " . $data['type'] . "}\""; + } + } + $str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\""; + if (count($typeDef['elements']) > 0) { + $str .= ">"; + foreach ($typeDef['elements'] as $element => $eData) { + $str .= $this->serializeTypeDef($element); + } + $str .= ""; + } elseif ($typeDef['typeClass'] == 'element') { + $str .= ">"; + } else { + $str .= "/>"; + } + return $str; + } + return false; + } + + /** + * returns HTML form elements that allow a user + * to enter values for creating an instance of the given type. + * + * @param string $name name for type instance + * @param string $type name of type + * @return string + * @access public + * @deprecated + */ + function typeToForm($name, $type) + { + $buffer = ''; + // get typedef + if ($typeDef = $this->getTypeDef($type)) { + // if struct + if ($typeDef['phpType'] == 'struct') { + $buffer .= '
'; + foreach ($typeDef['elements'] as $childDef) { + $buffer .= " + + "; + } + $buffer .= '
$childDef[name] (type: " . $this->getLocalPart($childDef['type']) . "):
'; + // if array + } elseif ($typeDef['phpType'] == 'array') { + $buffer .= ''; + $buffer .= str_repeat (" - "; - } - $buffer .= '
array item (type: $typeDef[arrayType]):
'; - // if scalar - } else { - $buffer .= ""; - } - } else { - $buffer .= ""; - } - return $buffer; - } + ", 3); + $buffer .= ''; + // if scalar + } else { + $buffer .= ""; + } + } else { + $buffer .= ""; + } + return $buffer; + } - /** - * adds a complex type to the schema - * - * example: array - * - * addType( - * 'ArrayOfstring', - * 'complexType', - * 'array', - * '', - * 'SOAP-ENC:Array', - * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), - * 'xsd:string' - * ); - * - * example: PHP associative array ( SOAP Struct ) - * - * addType( - * 'SOAPStruct', - * 'complexType', - * 'struct', - * 'all', - * array('myVar'=> array('name'=>'myVar','type'=>'string') - * ); - * - * @param name - * @param typeClass (complexType|simpleType|attribute) - * @param phpType: currently supported are array and struct (php assoc array) - * @param compositor (all|sequence|choice) - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param elements = array ( name = array(name=>'',type=>'') ) - * @param attrs = array( - * array( - * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", - * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" - * ) - * ) - * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) - * @access public - * @see getTypeDef - */ - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){ - $this->complexTypes[$name] = array( - 'name' => $name, - 'typeClass' => $typeClass, - 'phpType' => $phpType, - 'compositor'=> $compositor, - 'restrictionBase' => $restrictionBase, - 'elements' => $elements, - 'attrs' => $attrs, - 'arrayType' => $arrayType - ); + /** + * adds a complex type to the schema + * example: array + * addType( + * 'ArrayOfstring', + * 'complexType', + * 'array', + * '', + * 'SOAP-ENC:Array', + * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), + * 'xsd:string' + * ); + * example: PHP associative array ( SOAP Struct ) + * addType( + * 'SOAPStruct', + * 'complexType', + * 'struct', + * 'all', + * array('myVar'=> array('name'=>'myVar','type'=>'string') + * ); + * + * @param string $name + * @param string $typeClass (complexType|simpleType|attribute) + * @param string $phpType : currently supported are array and struct (php assoc array) + * @param string $compositor (all|sequence|choice) + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) + * @param array $elements = array ( name = array(name=>'',type=>'') ) + * @param array $attrs = array( + * array( + * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", + * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" + * ) + * ) + * @param array $arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string) + * + * @access public + * @see getTypeDef + */ + function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') + { + $this->complexTypes[$name] = array( + 'name' => $name, + 'typeClass' => $typeClass, + 'phpType' => $phpType, + 'compositor' => $compositor, + 'restrictionBase' => $restrictionBase, + 'elements' => $elements, + 'attrs' => $attrs, + 'arrayType' => $arrayType + ); - $this->xdebug("addComplexType $name:"); - $this->appendDebug($this->varDump($this->complexTypes[$name])); - } + $this->xdebug("addComplexType $name:"); + $this->appendDebug($this->varDump($this->complexTypes[$name])); + } - /** - * adds a simple type to the schema - * - * @param string $name - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param string $typeClass (should always be simpleType) - * @param string $phpType (should always be scalar) - * @param array $enumeration array of values - * @access public - * @see nusoap_xmlschema - * @see getTypeDef - */ - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { - $this->simpleTypes[$name] = array( - 'name' => $name, - 'typeClass' => $typeClass, - 'phpType' => $phpType, - 'type' => $restrictionBase, - 'enumeration' => $enumeration - ); + /** + * adds a simple type to the schema + * + * @param string $name + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) + * @param string $typeClass (should always be simpleType) + * @param string $phpType (should always be scalar) + * @param array $enumeration array of values + * @access public + * @see nusoap_xmlschema + * @see getTypeDef + */ + function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) + { + $this->simpleTypes[$name] = array( + 'name' => $name, + 'typeClass' => $typeClass, + 'phpType' => $phpType, + 'type' => $restrictionBase, + 'enumeration' => $enumeration + ); - $this->xdebug("addSimpleType $name:"); - $this->appendDebug($this->varDump($this->simpleTypes[$name])); - } + $this->xdebug("addSimpleType $name:"); + $this->appendDebug($this->varDump($this->simpleTypes[$name])); + } - /** - * adds an element to the schema - * - * @param array $attrs attributes that must include name and type - * @see nusoap_xmlschema - * @access public - */ - function addElement($attrs) { - if (! $this->getPrefix($attrs['type'])) { - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; - } - $this->elements[ $attrs['name'] ] = $attrs; - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; + /** + * adds an element to the schema + * + * @param array $attrs attributes that must include name and type + * @see nusoap_xmlschema + * @access public + */ + function addElement($attrs) + { + if (!$this->getPrefix($attrs['type'])) { + $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; + } + $this->elements[$attrs['name']] = $attrs; + $this->elements[$attrs['name']]['typeClass'] = 'element'; - $this->xdebug("addElement " . $attrs['name']); - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); - } + $this->xdebug("addElement " . $attrs['name']); + $this->appendDebug($this->varDump($this->elements[$attrs['name']])); + } } /** * Backward compatibility */ -class XMLSchema extends nusoap_xmlschema { -} - -?> -* @access public -*/ -class soapval extends nusoap_base { - /** - * The XML element name - * - * @var string - * @access private - */ - var $name; - /** - * The XML type name (string or false) - * - * @var mixed - * @access private - */ - var $type; - /** - * The PHP value - * - * @var mixed - * @access private - */ - var $value; - /** - * The XML element namespace (string or false) - * - * @var mixed - * @access private - */ - var $element_ns; - /** - * The XML type namespace (string or false) - * - * @var mixed - * @access private - */ - var $type_ns; - /** - * The XML element attributes (array or false) - * - * @var mixed - * @access private - */ - var $attributes; - - /** - * constructor - * - * @param string $name optional name - * @param mixed $type optional type name - * @param mixed $value optional value - * @param mixed $element_ns optional namespace of value - * @param mixed $type_ns optional namespace of type - * @param mixed $attributes associative array of attributes to add to element serialization - * @access public - */ - function __construct($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) { - parent::__construct(); - $this->name = $name; - $this->type = $type; - $this->value = $value; - $this->element_ns = $element_ns; - $this->type_ns = $type_ns; - $this->attributes = $attributes; - } - - /** - * return serialized value - * - * @param string $use The WSDL use value (encoded|literal) - * @return string XML data - * @access public - */ - function serialize($use='encoded') { - return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); - } - - /** - * decodes a soapval object into a PHP native type - * - * @return mixed - * @access public - */ - function decode(){ - return $this->value; - } +class XMLSchema extends nusoap_xmlschema +{ } +/** + * For creating serializable abstractions of native PHP types. This class + * allows element name/namespace, XSD type, and XML attributes to be + * associated with a value. This is extremely useful when WSDL is not + * used, but is also useful when WSDL is used with polymorphic types, including + * xsd:anyType and user-defined types. + * + * @author Dietrich Ayala + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class soapval extends nusoap_base +{ + /** + * The XML element name + * + * @var string + * @access private + */ + var $name; + /** + * The XML type name (string or false) + * + * @var mixed + * @access private + */ + var $type; + /** + * The PHP value + * + * @var mixed + * @access private + */ + var $value; + /** + * The XML element namespace (string or false) + * + * @var mixed + * @access private + */ + var $element_ns; + /** + * The XML type namespace (string or false) + * + * @var mixed + * @access private + */ + var $type_ns; + /** + * The XML element attributes (array or false) + * + * @var mixed + * @access private + */ + var $attributes; -?>name = $name; + $this->type = $type; + $this->value = $value; + $this->element_ns = $element_ns; + $this->type_ns = $type_ns; + $this->attributes = $attributes; + } + + /** + * return serialized value + * + * @param string $use The WSDL use value (encoded|literal) + * @return string XML data + * @access public + */ + function serialize($use = 'encoded') + { + return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); + } + + /** + * decodes a soapval object into a PHP native type + * + * @return mixed + * @access public + */ + function decode() + { + return $this->value; + } +} /** -* transport class for sending/receiving data via HTTP and HTTPS -* NOTE: PHP must be compiled with the CURL extension for HTTPS support -* -* @author Dietrich Ayala -* @author Scott Nichol -* @access public -*/ -class soap_transport_http extends nusoap_base { + * transport class for sending/receiving data via HTTP and HTTPS + * NOTE: PHP must be compiled with the CURL extension for HTTPS support + * + * @author Dietrich Ayala + * @author Scott Nichol + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class soap_transport_http extends nusoap_base +{ - var $url = ''; - var $uri = ''; - var $digest_uri = ''; - var $scheme = ''; - var $host = ''; - var $port = ''; - var $path = ''; - var $request_method = 'POST'; - var $protocol_version = '1.0'; - var $encoding = ''; - var $outgoing_headers = array(); - var $incoming_headers = array(); - var $incoming_cookies = array(); - var $outgoing_payload = ''; - var $incoming_payload = ''; - var $response_status_line; // HTTP response status line - var $useSOAPAction = true; - var $persistentConnection = false; - var $ch = false; // cURL handle - var $ch_options = array(); // cURL custom options - var $use_curl = false; // force cURL use - var $proxy = null; // proxy information (associative array) - var $username = ''; - var $password = ''; - var $authtype = ''; - var $digestRequest = array(); - var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) - // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' - // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' - // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' - // passphrase: SSL key password/passphrase - // certpassword: SSL certificate password - // verifypeer: default is 1 - // verifyhost: default is 1 + var $query = ''; + var $tryagain = false; + var $url = ''; + var $uri = ''; + var $digest_uri = ''; + var $scheme = ''; + var $host = ''; + var $port = ''; + var $path = ''; + var $request_method = 'POST'; + var $protocol_version = '1.0'; + var $encoding = ''; + var $outgoing_headers = array(); + var $incoming_headers = array(); + var $incoming_cookies = array(); + var $outgoing_payload = ''; + var $incoming_payload = ''; + var $response_status_line; // HTTP response status line + var $useSOAPAction = true; + var $persistentConnection = false; + var $ch = false; // cURL handle + var $ch_options = array(); // cURL custom options + var $use_curl = false; // force cURL use + var $proxy = null; // proxy information (associative array) + var $username = ''; + var $password = ''; + var $authtype = ''; + var $digestRequest = array(); + var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) + // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' + // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' + // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' + // passphrase: SSL key password/passphrase + // certpassword: SSL certificate password + // verifypeer: default is 1 + // verifyhost: default is 1 - /** - * constructor - * - * @param string $url The URL to which to connect - * @param array $curl_options User-specified cURL options - * @param boolean $use_curl Whether to try to force cURL use - * @access public - */ - function __construct($url, $curl_options = NULL, $use_curl = false){ - parent::__construct(); - $this->debug("ctor url=$url use_curl=$use_curl curl_options:"); - $this->appendDebug($this->varDump($curl_options)); - $this->setURL($url); - if (is_array($curl_options)) { - $this->ch_options = $curl_options; - } - $this->use_curl = $use_curl; - preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); - $this->setHeader('User-Agent', $this->title.'/'.$this->version.(isset($rev[1])?' ('.$rev[1].')':'')); - } + /** @var false|resource */ + var $fp; + var $errno; - /** - * sets a cURL option - * - * @param mixed $option The cURL option (always integer?) - * @param mixed $value The cURL option value - * @access private - */ - function setCurlOption($option, $value) { - $this->debug("setCurlOption option=$option, value="); - $this->appendDebug($this->varDump($value)); - curl_setopt($this->ch, $option, $value); - } + /** + * constructor + * + * @param string $url The URL to which to connect + * @param array $curl_options User-specified cURL options + * @param boolean $use_curl Whether to try to force cURL use + * @access public + */ + function __construct($url, $curl_options = null, $use_curl = false) + { + parent::__construct(); + $this->debug("ctor url=$url use_curl=$use_curl curl_options:"); + $this->appendDebug($this->varDump($curl_options)); + $this->setURL($url); + if (is_array($curl_options)) { + $this->ch_options = $curl_options; + } + $this->use_curl = $use_curl; + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); + $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . $rev[1] . ')'); + } - /** - * sets an HTTP header - * - * @param string $name The name of the header - * @param string $value The value of the header - * @access private - */ - function setHeader($name, $value) { - $this->outgoing_headers[$name] = $value; - $this->debug("set header $name: $value"); - } + /** + * sets a cURL option + * + * @param mixed $option The cURL option (always integer?) + * @param mixed $value The cURL option value + * @access private + */ + function setCurlOption($option, $value) + { + $this->debug("setCurlOption option=$option, value="); + $this->appendDebug($this->varDump($value)); + curl_setopt($this->ch, $option, $value); + } - /** - * unsets an HTTP header - * - * @param string $name The name of the header - * @access private - */ - function unsetHeader($name) { - if (isset($this->outgoing_headers[$name])) { - $this->debug("unset header $name"); - unset($this->outgoing_headers[$name]); - } - } + /** + * sets an HTTP header + * + * @param string $name The name of the header + * @param string $value The value of the header + * @access private + */ + function setHeader($name, $value) + { + $this->outgoing_headers[$name] = $value; + $this->debug("set header $name: $value"); + } - /** - * sets the URL to which to connect - * - * @param string $url The URL to which to connect - * @access private - */ - function setURL($url) { - $this->url = $url; + /** + * unsets an HTTP header + * + * @param string $name The name of the header + * @access private + */ + function unsetHeader($name) + { + if (isset($this->outgoing_headers[$name])) { + $this->debug("unset header $name"); + unset($this->outgoing_headers[$name]); + } + } - $u = parse_url($url); - foreach($u as $k => $v){ - $this->debug("parsed URL $k = $v"); - $this->$k = $v; - } + /** + * sets the URL to which to connect + * + * @param string $url The URL to which to connect + * @access private + */ + function setURL($url) + { + $this->url = $url; - // add any GET params to path - if(isset($u['query']) && $u['query'] != ''){ + $u = parse_url($url); + foreach ($u as $k => $v) { + $this->debug("parsed URL $k = $v"); + $this->$k = $v; + } + + // add any GET params to path + if (isset($u['query']) && $u['query'] != '') { $this->path .= '?' . $u['query']; - } + } - // set default port - if(!isset($u['port'])){ - if($u['scheme'] == 'https'){ - $this->port = 443; - } else { - $this->port = 80; - } - } + // set default port + if (!isset($u['port'])) { + if ($u['scheme'] == 'https') { + $this->port = 443; + } else { + $this->port = 80; + } + } - $this->uri = $this->path; - $this->digest_uri = $this->uri; + $this->uri = $this->path; + $this->digest_uri = $this->uri; - // build headers - if (!isset($u['port'])) { - $this->setHeader('Host', $this->host); - } else { - $this->setHeader('Host', $this->host.':'.$this->port); - } + // build headers + if (!isset($u['port'])) { + $this->setHeader('Host', $this->host); + } else { + $this->setHeader('Host', $this->host . ':' . $this->port); + } - if (isset($u['user']) && $u['user'] != '') { - $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : ''); - } - } + if (isset($u['user']) && $u['user'] != '') { + $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : ''); + } + } - /** - * gets the I/O method to use - * - * @return string I/O method to use (socket|curl|unknown) - * @access private - */ - function io_method() { - if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) - return 'curl'; - if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) - return 'socket'; - return 'unknown'; - } + /** + * gets the I/O method to use + * + * @return string I/O method to use (socket|curl|unknown) + * @access private + */ + function io_method() + { + if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) { + return 'curl'; + } + if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) { + return 'socket'; + } + return 'unknown'; + } - /** - * establish an HTTP connection - * - * @param integer $timeout set connection timeout in seconds - * @param integer $response_timeout set response timeout in seconds - * @return boolean true if connected, false if not - * @access private - */ - function connect($connection_timeout=0,$response_timeout=30){ - // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like - // "regular" socket. - // TODO: disabled for now because OpenSSL must be *compiled* in (not just - // loaded), and until PHP5 stream_get_wrappers is not available. + /** + * establish an HTTP connection + * + * @param integer $connection_timeout set connection timeout in seconds + * @param integer $response_timeout set response timeout in seconds + * @return boolean true if connected, false if not + * @access private + */ + function connect($connection_timeout = 0, $response_timeout = 30) + { + // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like + // "regular" socket. + // TODO: disabled for now because OpenSSL must be *compiled* in (not just + // loaded), and until PHP5 stream_get_wrappers is not available. // if ($this->scheme == 'https') { // if (version_compare(phpversion(), '4.3.0') >= 0) { // if (extension_loaded('openssl')) { @@ -2337,2261 +2392,2355 @@ class soap_transport_http extends nusoap_base { // } // } // } - $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port"); - if ($this->io_method() == 'socket') { - if (!is_array($this->proxy)) { - $host = $this->host; - $port = $this->port; - } else { - $host = $this->proxy['host']; - $port = $this->proxy['port']; - } + $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port"); + if ($this->io_method() == 'socket') { + if (!is_array($this->proxy)) { + $host = $this->host; + } else { + $host = $this->proxy['host']; + } - // use persistent connection - if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){ - if (!feof($this->fp)) { - $this->debug('Re-use persistent connection'); - return true; - } - fclose($this->fp); - $this->debug('Closed persistent connection at EOF'); - } + // use persistent connection + if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) { + if (!feof($this->fp)) { + $this->debug('Re-use persistent connection'); + return true; + } + fclose($this->fp); + $this->debug('Closed persistent connection at EOF'); + } - // munge host if using OpenSSL - if ($this->scheme == 'ssl') { - $host = 'ssl://' . $host; - } - $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout); + // munge host if using OpenSSL + if ($this->scheme == 'ssl') { + $host = 'ssl://' . $host; + } + $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout); - // open socket - if($connection_timeout > 0){ - $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout); - } else { - $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str); - } + // open socket + if ($connection_timeout > 0) { + $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout); + } else { + $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str); + } - // test pointer - if(!$this->fp) { - $msg = 'Couldn\'t open socket connection to server ' . $this->url; - if ($this->errno) { - $msg .= ', Error ('.$this->errno.'): '.$this->error_str; - } else { - $msg .= ' prior to connect(). This is often a problem looking up the host name.'; - } - $this->debug($msg); - $this->setError($msg); - return false; - } + // test pointer + if (!$this->fp) { + $msg = 'Couldn\'t open socket connection to server ' . $this->url; + if ($this->errno) { + $msg .= ', Error (' . $this->errno . '): ' . $this->error_str; + } else { + $msg .= ' prior to connect(). This is often a problem looking up the host name.'; + } + $this->debug($msg); + $this->setError($msg); + return false; + } - // set response timeout - $this->debug('set response timeout to ' . $response_timeout); - socket_set_timeout( $this->fp, $response_timeout); + // set response timeout + $this->debug('set response timeout to ' . $response_timeout); + socket_set_timeout($this->fp, $response_timeout, 0); - $this->debug('socket connected'); - return true; - } else if ($this->io_method() == 'curl') { - if (!extension_loaded('curl')) { + $this->debug('socket connected'); + return true; + } elseif ($this->io_method() == 'curl') { + if (!extension_loaded('curl')) { // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); - $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.'); - return false; - } - // Avoid warnings when PHP does not have these options - if (defined('CURLOPT_CONNECTIONTIMEOUT')) - $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT; - else - $CURLOPT_CONNECTIONTIMEOUT = 78; - if (defined('CURLOPT_HTTPAUTH')) - $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH; - else - $CURLOPT_HTTPAUTH = 107; - if (defined('CURLOPT_PROXYAUTH')) - $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH; - else - $CURLOPT_PROXYAUTH = 111; - if (defined('CURLAUTH_BASIC')) - $CURLAUTH_BASIC = CURLAUTH_BASIC; - else - $CURLAUTH_BASIC = 1; - if (defined('CURLAUTH_DIGEST')) - $CURLAUTH_DIGEST = CURLAUTH_DIGEST; - else - $CURLAUTH_DIGEST = 2; - if (defined('CURLAUTH_NTLM')) - $CURLAUTH_NTLM = CURLAUTH_NTLM; - else - $CURLAUTH_NTLM = 8; + $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.'); + return false; + } + // Avoid warnings when PHP does not have these options + if (defined('CURLOPT_CONNECTIONTIMEOUT')) { + $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT; + } else { + $CURLOPT_CONNECTIONTIMEOUT = 78; + } + if (defined('CURLOPT_HTTPAUTH')) { + $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH; + } else { + $CURLOPT_HTTPAUTH = 107; + } + if (defined('CURLOPT_PROXYAUTH')) { + $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH; + } else { + $CURLOPT_PROXYAUTH = 111; + } + if (defined('CURLAUTH_BASIC')) { + $CURLAUTH_BASIC = CURLAUTH_BASIC; + } else { + $CURLAUTH_BASIC = 1; + } + if (defined('CURLAUTH_DIGEST')) { + $CURLAUTH_DIGEST = CURLAUTH_DIGEST; + } else { + $CURLAUTH_DIGEST = 2; + } + if (defined('CURLAUTH_NTLM')) { + $CURLAUTH_NTLM = CURLAUTH_NTLM; + } else { + $CURLAUTH_NTLM = 8; + } - $this->debug('connect using cURL'); - // init CURL - $this->ch = curl_init(); - // set url - $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; - // add path - $hostURL .= $this->path; - $this->setCurlOption(CURLOPT_URL, $hostURL); - // follow location headers (re-directs) - if (ini_get('safe_mode') || ini_get('open_basedir')) { - $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION'); - $this->debug('safe_mode = '); - $this->appendDebug($this->varDump(ini_get('safe_mode'))); - $this->debug('open_basedir = '); - $this->appendDebug($this->varDump(ini_get('open_basedir'))); - } else { - $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1); - } - // ask for headers in the response output - $this->setCurlOption(CURLOPT_HEADER, 1); - // ask for the response output as the return value - $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1); - // encode - // We manage this ourselves through headers and encoding + $this->debug('connect using cURL'); + // init CURL + $this->ch = curl_init(); + // set url + $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; + // add path + $hostURL .= $this->path; + $this->setCurlOption(CURLOPT_URL, $hostURL); + // follow location headers (re-directs) + if (ini_get('safe_mode') || ini_get('open_basedir')) { + $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION'); + $this->debug('safe_mode = '); + $this->appendDebug($this->varDump(ini_get('safe_mode'))); + $this->debug('open_basedir = '); + $this->appendDebug($this->varDump(ini_get('open_basedir'))); + } else { + $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1); + } + // ask for headers in the response output + $this->setCurlOption(CURLOPT_HEADER, 1); + // ask for the response output as the return value + $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1); + // encode + // We manage this ourselves through headers and encoding // if(function_exists('gzuncompress')){ // $this->setCurlOption(CURLOPT_ENCODING, 'deflate'); // } - // persistent connection - if ($this->persistentConnection) { - // I believe the following comment is now bogus, having applied to - // the code when it used CURLOPT_CUSTOMREQUEST to send the request. - // The way we send data, we cannot use persistent connections, since - // there will be some "junk" at the end of our request. - //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true); - $this->persistentConnection = false; - $this->setHeader('Connection', 'close'); - } - // set timeouts - if ($connection_timeout != 0) { - $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout); - } - if ($response_timeout != 0) { - $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout); - } + // persistent connection + if ($this->persistentConnection) { + // I believe the following comment is now bogus, having applied to + // the code when it used CURLOPT_CUSTOMREQUEST to send the request. + // The way we send data, we cannot use persistent connections, since + // there will be some "junk" at the end of our request. + //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true); + $this->persistentConnection = false; + $this->setHeader('Connection', 'close'); + } + // set timeouts + if ($connection_timeout != 0) { + $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout); + } + if ($response_timeout != 0) { + $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout); + } - if ($this->scheme == 'https') { - $this->debug('set cURL SSL verify options'); - // recent versions of cURL turn on peer/host checking by default, - // while PHP binaries are not compiled with a default location for the - // CA cert bundle, so disable peer/host checking. - //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); - $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0); - $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); + if ($this->scheme == 'https') { + $this->debug('set cURL SSL verify options'); + // recent versions of cURL turn on peer/host checking by default, + // while PHP binaries are not compiled with a default location for the + // CA cert bundle, so disable peer/host checking. + //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0); + $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); - // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) - if ($this->authtype == 'certificate') { - $this->debug('set cURL certificate options'); - if (isset($this->certRequest['cainfofile'])) { - $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']); - } - if (isset($this->certRequest['verifypeer'])) { - $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']); - } else { - $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1); - } - if (isset($this->certRequest['verifyhost'])) { - $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']); - } else { - $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1); - } - if (isset($this->certRequest['sslcertfile'])) { - $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']); - } - if (isset($this->certRequest['sslkeyfile'])) { - $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']); - } - if (isset($this->certRequest['passphrase'])) { - $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']); - } - if (isset($this->certRequest['certpassword'])) { - $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']); - } - } - } - if ($this->authtype && ($this->authtype != 'certificate')) { - if ($this->username) { - $this->debug('set cURL username/password'); - $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password"); - } - if ($this->authtype == 'basic') { - $this->debug('set cURL for Basic authentication'); - $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC); - } - if ($this->authtype == 'digest') { - $this->debug('set cURL for digest authentication'); - $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST); - } - if ($this->authtype == 'ntlm') { - $this->debug('set cURL for NTLM authentication'); - $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM); - } - } - if (is_array($this->proxy)) { - $this->debug('set cURL proxy options'); - if ($this->proxy['port'] != '') { - $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']); - } else { - $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']); - } - if ($this->proxy['username'] || $this->proxy['password']) { - $this->debug('set cURL proxy authentication options'); - $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']); - if ($this->proxy['authtype'] == 'basic') { - $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC); - } - if ($this->proxy['authtype'] == 'ntlm') { - $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM); - } - } - } - $this->debug('cURL connection set up'); - return true; - } else { - $this->setError('Unknown scheme ' . $this->scheme); - $this->debug('Unknown scheme ' . $this->scheme); - return false; - } - } + // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) + if ($this->authtype == 'certificate') { + $this->debug('set cURL certificate options'); + if (isset($this->certRequest['cainfofile'])) { + $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']); + } + if (isset($this->certRequest['verifypeer'])) { + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']); + } else { + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1); + } + if (isset($this->certRequest['verifyhost'])) { + $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']); + } else { + $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1); + } + if (isset($this->certRequest['sslcertfile'])) { + $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']); + } + if (isset($this->certRequest['sslkeyfile'])) { + $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']); + } + if (isset($this->certRequest['passphrase'])) { + $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']); + } + if (isset($this->certRequest['certpassword'])) { + $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']); + } + } + } + if ($this->authtype && ($this->authtype != 'certificate')) { + if ($this->username) { + $this->debug('set cURL username/password'); + $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password"); + } + if ($this->authtype == 'basic') { + $this->debug('set cURL for Basic authentication'); + $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC); + } + if ($this->authtype == 'digest') { + $this->debug('set cURL for digest authentication'); + $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST); + } + if ($this->authtype == 'ntlm') { + $this->debug('set cURL for NTLM authentication'); + $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM); + } + } + if (is_array($this->proxy)) { + $this->debug('set cURL proxy options'); + if ($this->proxy['port'] != '') { + $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']); + } else { + $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']); + } + if ($this->proxy['username'] || $this->proxy['password']) { + $this->debug('set cURL proxy authentication options'); + $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']); + if ($this->proxy['authtype'] == 'basic') { + $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC); + } + if ($this->proxy['authtype'] == 'ntlm') { + $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM); + } + } + } + $this->debug('cURL connection set up'); + return true; + } else { + $this->setError('Unknown scheme ' . $this->scheme); + $this->debug('Unknown scheme ' . $this->scheme); + return false; + } + } - /** - * sends the SOAP request and gets the SOAP response via HTTP[S] - * - * @param string $data message data - * @param integer $timeout set connection timeout in seconds - * @param integer $response_timeout set response timeout in seconds - * @param array $cookies cookies to send - * @return string data - * @access public - */ - function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) { + /** + * sends the SOAP request and gets the SOAP response via HTTP[S] + * + * @param string $data message data + * @param integer $timeout set connection timeout in seconds + * @param integer $response_timeout set response timeout in seconds + * @param array $cookies cookies to send + * @return string data + * @access public + */ + function send($data, $timeout = 0, $response_timeout = 30, $cookies = null) + { + $this->debug('entered send() with data of length: ' . strlen($data)); - $this->debug('entered send() with data of length: '.strlen($data)); + $respdata = ""; + $this->tryagain = true; + $tries = 0; + while ($this->tryagain) { + $this->tryagain = false; + if ($tries++ < 2) { + // make connnection + if (!$this->connect($timeout, $response_timeout)) { + return false; + } - $this->tryagain = true; - $tries = 0; - while ($this->tryagain) { - $this->tryagain = false; - if ($tries++ < 2) { - // make connnection - if (!$this->connect($timeout, $response_timeout)){ - return false; - } + // send request + if (!$this->sendRequest($data, $cookies)) { + return false; + } - // send request - if (!$this->sendRequest($data, $cookies)){ - return false; - } - - // get response - $respdata = $this->getResponse(); - } else { - $this->setError("Too many tries to get an OK response ($this->response_status_line)"); - } - } - $this->debug('end of send()'); - return $respdata; - } + // get response + $respdata = $this->getResponse(); + } else { + $this->setError("Too many tries to get an OK response ($this->response_status_line)"); + } + } + $this->debug('end of send()'); + return $respdata; + } - /** - * sends the SOAP request and gets the SOAP response via HTTPS using CURL - * - * @param string $data message data - * @param integer $timeout set connection timeout in seconds - * @param integer $response_timeout set response timeout in seconds - * @param array $cookies cookies to send - * @return string data - * @access public - * @deprecated - */ - function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) { - return $this->send($data, $timeout, $response_timeout, $cookies); - } + /** + * sends the SOAP request and gets the SOAP response via HTTPS using CURL + * + * @param string $data message data + * @param integer $timeout set connection timeout in seconds + * @param integer $response_timeout set response timeout in seconds + * @param array $cookies cookies to send + * @return string data + * @access public + */ + function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies = NULL) + { + return $this->send($data, $timeout, $response_timeout, $cookies); + } - /** - * if authenticating, set user credentials here - * - * @param string $username - * @param string $password - * @param string $authtype (basic|digest|certificate|ntlm) - * @param array $digestRequest (keys must be nonce, nc, realm, qop) - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) - * @access public - */ - function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) { - $this->debug("setCredentials username=$username authtype=$authtype digestRequest="); - $this->appendDebug($this->varDump($digestRequest)); - $this->debug("certRequest="); - $this->appendDebug($this->varDump($certRequest)); - // cf. RFC 2617 - if ($authtype == 'basic') { - $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password)); - } elseif ($authtype == 'digest') { - if (isset($digestRequest['nonce'])) { - $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; + /** + * if authenticating, set user credentials here + * + * @param string $username + * @param string $password + * @param string $authtype (basic|digest|certificate|ntlm) + * @param array $digestRequest (keys must be nonce, nc, realm, qop) + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) + * @access public + */ + function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) + { + $this->debug("setCredentials username=$username authtype=$authtype digestRequest="); + $this->appendDebug($this->varDump($digestRequest)); + $this->debug("certRequest="); + $this->appendDebug($this->varDump($certRequest)); + // cf. RFC 2617 + if ($authtype == 'basic') { + $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password)); + } elseif ($authtype == 'digest') { + if (isset($digestRequest['nonce'])) { + $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; - // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html) + // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html) - // A1 = unq(username-value) ":" unq(realm-value) ":" passwd - $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password; + // A1 = unq(username-value) ":" unq(realm-value) ":" passwd + $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password; - // H(A1) = MD5(A1) - $HA1 = md5($A1); + // H(A1) = MD5(A1) + $HA1 = md5($A1); - // A2 = Method ":" digest-uri-value - $A2 = $this->request_method . ':' . $this->digest_uri; + // A2 = Method ":" digest-uri-value + $A2 = $this->request_method . ':' . $this->digest_uri; - // H(A2) - $HA2 = md5($A2); + // H(A2) + $HA2 = md5($A2); - // KD(secret, data) = H(concat(secret, ":", data)) - // if qop == auth: - // request-digest = <"> < KD ( H(A1), unq(nonce-value) - // ":" nc-value - // ":" unq(cnonce-value) - // ":" unq(qop-value) - // ":" H(A2) - // ) <"> - // if qop is missing, - // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <"> + // KD(secret, data) = H(concat(secret, ":", data)) + // if qop == auth: + // request-digest = <"> < KD ( H(A1), unq(nonce-value) + // ":" nc-value + // ":" unq(cnonce-value) + // ":" unq(qop-value) + // ":" H(A2) + // ) <"> + // if qop is missing, + // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <"> - $unhashedDigest = ''; - $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; - $cnonce = $nonce; - if ($digestRequest['qop'] != '') { - $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2; - } else { - $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; - } + $nonce = $digestRequest['nonce']; + $cnonce = $nonce; + if ($digestRequest['qop'] != '') { + $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2; + } else { + $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; + } - $hashedDigest = md5($unhashedDigest); + $hashedDigest = md5($unhashedDigest); - $opaque = ''; - if (isset($digestRequest['opaque'])) { - $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; - } + $opaque = ''; + if (isset($digestRequest['opaque'])) { + $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; + } - $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"'); - } - } elseif ($authtype == 'certificate') { - $this->certRequest = $certRequest; - $this->debug('Authorization header not set for certificate'); - } elseif ($authtype == 'ntlm') { - // do nothing - $this->debug('Authorization header not set for ntlm'); - } - $this->username = $username; - $this->password = $password; - $this->authtype = $authtype; - $this->digestRequest = $digestRequest; - } + $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"'); + } + } elseif ($authtype == 'certificate') { + $this->certRequest = $certRequest; + $this->debug('Authorization header not set for certificate'); + } elseif ($authtype == 'ntlm') { + // do nothing + $this->debug('Authorization header not set for ntlm'); + } + $this->username = $username; + $this->password = $password; + $this->authtype = $authtype; + $this->digestRequest = $digestRequest; + } - /** - * set the soapaction value - * - * @param string $soapaction - * @access public - */ - function setSOAPAction($soapaction) { - $this->setHeader('SOAPAction', '"' . $soapaction . '"'); - } + /** + * set the soapaction value + * + * @param string $soapaction + * @access public + */ + function setSOAPAction($soapaction) + { + $this->setHeader('SOAPAction', '"' . $soapaction . '"'); + } - /** - * use http encoding - * - * @param string $enc encoding style. supported values: gzip, deflate, or both - * @access public - */ - function setEncoding($enc='gzip, deflate') { - if (function_exists('gzdeflate')) { - $this->protocol_version = '1.1'; - $this->setHeader('Accept-Encoding', $enc); - if (!isset($this->outgoing_headers['Connection'])) { - $this->setHeader('Connection', 'close'); - $this->persistentConnection = false; - } - // deprecated as of PHP 5.3.0 - //set_magic_quotes_runtime(0); - $this->encoding = $enc; - } - } + /** + * use http encoding + * + * @param string $enc encoding style. supported values: gzip, deflate, or both + * @access public + */ + function setEncoding($enc = 'gzip, deflate') + { + if (function_exists('gzdeflate')) { + $this->protocol_version = '1.1'; + $this->setHeader('Accept-Encoding', $enc); + if (!isset($this->outgoing_headers['Connection'])) { + $this->setHeader('Connection', 'close'); + $this->persistentConnection = false; + } + // deprecated as of PHP 5.3.0 + //set_magic_quotes_runtime(0); + $this->encoding = $enc; + } + } - /** - * set proxy info here - * - * @param string $proxyhost use an empty string to remove proxy - * @param string $proxyport - * @param string $proxyusername - * @param string $proxypassword - * @param string $proxyauthtype (basic|ntlm) - * @access public - */ - function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') { - if ($proxyhost) { - $this->proxy = array( - 'host' => $proxyhost, - 'port' => $proxyport, - 'username' => $proxyusername, - 'password' => $proxypassword, - 'authtype' => $proxyauthtype - ); - if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') { - $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword)); - } - } else { - $this->debug('remove proxy'); - $proxy = null; - unsetHeader('Proxy-Authorization'); - } - } + /** + * set proxy info here + * + * @param string $proxyhost use an empty string to remove proxy + * @param string $proxyport + * @param string $proxyusername + * @param string $proxypassword + * @param string $proxyauthtype (basic|ntlm) + * @access public + */ + function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') + { + if ($proxyhost) { + $this->proxy = array( + 'host' => $proxyhost, + 'port' => $proxyport, + 'username' => $proxyusername, + 'password' => $proxypassword, + 'authtype' => $proxyauthtype + ); + if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype == 'basic') { + $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword)); + } + } else { + $this->debug('remove proxy'); + $this->unsetHeader('Proxy-Authorization'); + } + } - /** - * Test if the given string starts with a header that is to be skipped. - * Skippable headers result from chunked transfer and proxy requests. - * - * @param string $data The string to check. - * @returns boolean Whether a skippable header was found. - * @access private - */ - function isSkippableCurlHeader(&$data) { - $skipHeaders = array( 'HTTP/1.1 100', - 'HTTP/1.0 301', - 'HTTP/1.1 301', - 'HTTP/1.0 302', - 'HTTP/1.1 302', - 'HTTP/1.0 401', - 'HTTP/1.1 401', - 'HTTP/1.0 200 Connection established'); - foreach ($skipHeaders as $hd) { - $prefix = substr($data, 0, strlen($hd)); - if ($prefix == $hd) return true; - } + /** + * Test if the given string starts with a header that is to be skipped. + * Skippable headers result from chunked transfer and proxy requests. + * + * @param string $data The string to check. + * @returns boolean Whether a skippable header was found. + * @access private + */ + function isSkippableCurlHeader($data) + { + $skipHeaders = array('HTTP/1.1 100', + 'HTTP/1.0 301', + 'HTTP/1.1 301', + 'HTTP/1.0 302', + 'HTTP/1.1 302', + 'HTTP/1.0 401', + 'HTTP/1.1 401', + 'HTTP/1.0 200 Connection established', + 'HTTP/1.1 200 Connection established'); + foreach ($skipHeaders as $hd) { + $prefix = substr($data, 0, strlen($hd)); + if ($prefix == $hd) { + return true; + } + } - return false; - } + return false; + } - /** - * decode a string that is encoded w/ "chunked' transfer encoding - * as defined in RFC2068 19.4.6 - * - * @param string $buffer - * @param string $lb - * @returns string - * @access public - * @deprecated - */ - function decodeChunked($buffer, $lb){ - // length := 0 - $length = 0; - $new = ''; + /** + * decode a string that is encoded w/ "chunked' transfer encoding + * as defined in RFC2068 19.4.6 + * + * @param string $buffer + * @param string $lb + * @returns string + * @access public + * @deprecated + */ + function decodeChunked($buffer, $lb) + { + $new = ''; - // read chunk-size, chunk-extension (if any) and CRLF - // get the position of the linebreak - $chunkend = strpos($buffer, $lb); - if ($chunkend == FALSE) { - $this->debug('no linebreak found in decodeChunked'); - return $new; - } - $temp = substr($buffer,0,$chunkend); - $chunk_size = hexdec( trim($temp) ); - $chunkstart = $chunkend + strlen($lb); - // while (chunk-size > 0) { - while ($chunk_size > 0) { - $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size"); - $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size); + // read chunk-size, chunk-extension (if any) and CRLF + // get the position of the linebreak + $chunkend = strpos($buffer, $lb); + if (!$chunkend) { + $this->debug('no linebreak found in decodeChunked'); + return $new; + } + $temp = substr($buffer, 0, $chunkend); + $chunk_size = hexdec(trim($temp)); + $chunkstart = $chunkend + strlen($lb); + // while (chunk-size > 0) { + while ($chunk_size > 0) { + $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size"); + $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size); - // Just in case we got a broken connection - if ($chunkend == FALSE) { - $chunk = substr($buffer,$chunkstart); - // append chunk-data to entity-body - $new .= $chunk; - $length += strlen($chunk); - break; - } + // Just in case we got a broken connection + if (!$chunkend) { + $chunk = substr($buffer, $chunkstart); + // append chunk-data to entity-body + $new .= $chunk; + break; + } - // read chunk-data and CRLF - $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); - // append chunk-data to entity-body - $new .= $chunk; - // length := length + chunk-size - $length += strlen($chunk); - // read chunk-size and CRLF - $chunkstart = $chunkend + strlen($lb); + // read chunk-data and CRLF + $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart); + // append chunk-data to entity-body + $new .= $chunk; + // length := length + chunk-size + // read chunk-size and CRLF + $chunkstart = $chunkend + strlen($lb); - $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); - if ($chunkend == FALSE) { - break; //Just in case we got a broken connection - } - $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); - $chunk_size = hexdec( trim($temp) ); - $chunkstart = $chunkend; - } - return $new; - } + $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); + if (!$chunkend) { + break; //Just in case we got a broken connection + } + $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart); + $chunk_size = hexdec(trim($temp)); + $chunkstart = $chunkend; + } + return $new; + } - /** - * Writes the payload, including HTTP headers, to $this->outgoing_payload. - * - * @param string $data HTTP body - * @param string $cookie_str data for HTTP Cookie header - * @return void - * @access private - */ - function buildPayload($data, $cookie_str = '') { - // Note: for cURL connections, $this->outgoing_payload is ignored, - // as is the Content-Length header, but these are still created as - // debugging guides. + /** + * Writes the payload, including HTTP headers, to $this->outgoing_payload. + * + * @param string $data HTTP body + * @param string $cookie_str data for HTTP Cookie header + * @return void + * @access private + */ + function buildPayload($data, $cookie_str = '') + { + // Note: for cURL connections, $this->outgoing_payload is ignored, + // as is the Content-Length header, but these are still created as + // debugging guides. - // add content-length header - if ($this->request_method != 'GET') { - $this->setHeader('Content-Length', strlen($data)); - } + // add content-length header + if ($this->request_method != 'GET') { + $this->setHeader('Content-Length', strlen($data)); + } - // start building outgoing payload: - if ($this->proxy) { - $uri = $this->url; - } else { - $uri = $this->uri; - } - $req = "$this->request_method $uri HTTP/$this->protocol_version"; - $this->debug("HTTP request: $req"); - $this->outgoing_payload = "$req\r\n"; + // start building outgoing payload: + if ($this->proxy) { + $uri = $this->url; + } else { + $uri = $this->uri; + } + $req = "$this->request_method $uri HTTP/$this->protocol_version"; + $this->debug("HTTP request: $req"); + $this->outgoing_payload = "$req\r\n"; - // loop thru headers, serializing - foreach($this->outgoing_headers as $k => $v){ - $hdr = $k.': '.$v; - $this->debug("HTTP header: $hdr"); - $this->outgoing_payload .= "$hdr\r\n"; - } + // loop thru headers, serializing + foreach ($this->outgoing_headers as $k => $v) { + $hdr = $k . ': ' . $v; + $this->debug("HTTP header: $hdr"); + $this->outgoing_payload .= "$hdr\r\n"; + } - // add any cookies - if ($cookie_str != '') { - $hdr = 'Cookie: '.$cookie_str; - $this->debug("HTTP header: $hdr"); - $this->outgoing_payload .= "$hdr\r\n"; - } + // add any cookies + if ($cookie_str != '') { + $hdr = 'Cookie: ' . $cookie_str; + $this->debug("HTTP header: $hdr"); + $this->outgoing_payload .= "$hdr\r\n"; + } - // header/body separator - $this->outgoing_payload .= "\r\n"; + // header/body separator + $this->outgoing_payload .= "\r\n"; - // add data - $this->outgoing_payload .= $data; - } + // add data + $this->outgoing_payload .= $data; + } - /** - * sends the SOAP request via HTTP[S] - * - * @param string $data message data - * @param array $cookies cookies to send - * @return boolean true if OK, false if problem - * @access private - */ - function sendRequest($data, $cookies = NULL) { - // build cookie string - $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); + /** + * sends the SOAP request via HTTP[S] + * + * @param string $data message data + * @param array $cookies cookies to send + * @return boolean true if OK, false if problem + * @access private + */ + function sendRequest($data, $cookies = null) + { + // build cookie string + $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); - // build payload - $this->buildPayload($data, $cookie_str); + // build payload + $this->buildPayload($data, $cookie_str); - if ($this->io_method() == 'socket') { - // send payload - if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { - $this->setError('couldn\'t write message data to socket'); - $this->debug('couldn\'t write message data to socket'); - return false; - } - $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload)); - return true; - } else if ($this->io_method() == 'curl') { - // set payload - // cURL does say this should only be the verb, and in fact it - // turns out that the URI and HTTP version are appended to this, which - // some servers refuse to work with (so we no longer use this method!) - //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); - $curl_headers = array(); - foreach($this->outgoing_headers as $k => $v){ - if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') { - $this->debug("Skip cURL header $k: $v"); - } else { - $curl_headers[] = "$k: $v"; - } - } - if ($cookie_str != '') { - $curl_headers[] = 'Cookie: ' . $cookie_str; - } - $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); - $this->debug('set cURL HTTP headers'); - if ($this->request_method == "POST") { - $this->setCurlOption(CURLOPT_POST, 1); - $this->setCurlOption(CURLOPT_POSTFIELDS, $data); - $this->debug('set cURL POST data'); - } else { - } - // insert custom user-set cURL options - foreach ($this->ch_options as $key => $val) { - $this->setCurlOption($key, $val); - } + if ($this->io_method() == 'socket') { + // send payload + if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { + $this->setError('couldn\'t write message data to socket'); + $this->debug('couldn\'t write message data to socket'); + return false; + } + $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload)); + return true; + } elseif ($this->io_method() == 'curl') { + // set payload + // cURL does say this should only be the verb, and in fact it + // turns out that the URI and HTTP version are appended to this, which + // some servers refuse to work with (so we no longer use this method!) + //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); + $curl_headers = array(); + foreach ($this->outgoing_headers as $k => $v) { + if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') { + $this->debug("Skip cURL header $k: $v"); + } else { + $curl_headers[] = "$k: $v"; + } + } + if ($cookie_str != '') { + $curl_headers[] = 'Cookie: ' . $cookie_str; + } + $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); + $this->debug('set cURL HTTP headers'); + if ($this->request_method == "POST") { + $this->setCurlOption(CURLOPT_POST, 1); + $this->setCurlOption(CURLOPT_POSTFIELDS, $data); + $this->debug('set cURL POST data'); + } + // insert custom user-set cURL options + foreach ($this->ch_options as $key => $val) { + $this->setCurlOption($key, $val); + } - $this->debug('set cURL payload'); - return true; - } - } + $this->debug('set cURL payload'); + return true; + } + return false; + } - /** - * gets the SOAP response via HTTP[S] - * - * @return string the response (also sets member variables like incoming_payload) - * @access private - */ - function getResponse(){ - $this->incoming_payload = ''; + /** + * gets the SOAP response via HTTP[S] + * + * @return string the response (also sets member variables like incoming_payload) + * @access private + */ + function getResponse() + { + $this->incoming_payload = ''; + $header_array = array (); + $data = ''; - if ($this->io_method() == 'socket') { - // loop until headers have been retrieved - $data = ''; - while (!isset($lb)){ + if ($this->io_method() == 'socket') { + // loop until headers have been retrieved + $pos = 0; + while (!isset($lb)) { + // We might EOF during header read. + if (feof($this->fp)) { + $this->incoming_payload = $data; + $this->debug('found no headers before EOF after length ' . strlen($data)); + $this->debug("received before EOF:\n" . $data); + $this->setError('server failed to send headers'); + return false; + } - // We might EOF during header read. - if(feof($this->fp)) { - $this->incoming_payload = $data; - $this->debug('found no headers before EOF after length ' . strlen($data)); - $this->debug("received before EOF:\n" . $data); - $this->setError('server failed to send headers'); - return false; - } + $tmp = fgets($this->fp, 256); + $tmplen = strlen($tmp); + $this->debug("read line of $tmplen bytes: " . trim($tmp)); - $tmp = fgets($this->fp, 256); - $tmplen = strlen($tmp); - $this->debug("read line of $tmplen bytes: " . trim($tmp)); + if ($tmplen == 0) { + $this->incoming_payload = $data; + $this->debug('socket read of headers timed out after length ' . strlen($data)); + $this->debug("read before timeout: " . $data); + $this->setError('socket read of headers timed out'); + return false; + } - if ($tmplen == 0) { - $this->incoming_payload = $data; - $this->debug('socket read of headers timed out after length ' . strlen($data)); - $this->debug("read before timeout: " . $data); - $this->setError('socket read of headers timed out'); - return false; - } + $data .= $tmp; + $pos = strpos($data, "\r\n\r\n"); + if ($pos > 1) { + $lb = "\r\n"; + } else { + $pos = strpos($data, "\n\n"); + if ($pos > 1) { + $lb = "\n"; + } + } + // remove 100 headers + if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) { + unset($lb); + $data = ''; + }// + } + // store header data + $this->incoming_payload .= $data; + $this->debug('found end of headers after length ' . strlen($data)); + // process headers + $header_data = trim(substr($data, 0, $pos)); + $header_array = explode($lb, $header_data); + $this->incoming_headers = array(); + $this->incoming_cookies = array(); + foreach ($header_array as $header_line) { + $arr = explode(':', $header_line, 2); + if (count($arr) > 1) { + $header_name = strtolower(trim($arr[0])); + $this->incoming_headers[$header_name] = trim($arr[1]); + if ($header_name == 'set-cookie') { + // TODO: allow multiple cookies from parseCookie + $cookie = $this->parseCookie(trim($arr[1])); + if ($cookie) { + $this->incoming_cookies[] = $cookie; + $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']); + } else { + $this->debug('did not find cookie in ' . trim($arr[1])); + } + } + } elseif (isset($header_name)) { + // append continuation line to previous header + $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; + } + } - $data .= $tmp; - $pos = strpos($data,"\r\n\r\n"); - if($pos > 1){ - $lb = "\r\n"; - } else { - $pos = strpos($data,"\n\n"); - if($pos > 1){ - $lb = "\n"; - } - } - // remove 100 headers - if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) { - unset($lb); - $data = ''; - }// - } - // store header data - $this->incoming_payload .= $data; - $this->debug('found end of headers after length ' . strlen($data)); - // process headers - $header_data = trim(substr($data,0,$pos)); - $header_array = explode($lb,$header_data); - $this->incoming_headers = array(); - $this->incoming_cookies = array(); - foreach($header_array as $header_line){ - $arr = explode(':',$header_line, 2); - if(count($arr) > 1){ - $header_name = strtolower(trim($arr[0])); - $this->incoming_headers[$header_name] = trim($arr[1]); - if ($header_name == 'set-cookie') { - // TODO: allow multiple cookies from parseCookie - $cookie = $this->parseCookie(trim($arr[1])); - if ($cookie) { - $this->incoming_cookies[] = $cookie; - $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']); - } else { - $this->debug('did not find cookie in ' . trim($arr[1])); - } - } - } else if (isset($header_name)) { - // append continuation line to previous header - $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; - } - } + // loop until msg has been received + if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') { + $content_length = 2147483647; // ignore any content-length header + $chunked = true; + $this->debug("want to read chunked content"); + } elseif (isset($this->incoming_headers['content-length'])) { + $content_length = $this->incoming_headers['content-length']; + $chunked = false; + $this->debug("want to read content of length $content_length"); + } else { + $content_length = 2147483647; + $chunked = false; + $this->debug("want to read content to EOF"); + } + $data = ''; + do { + if ($chunked) { + $tmp = fgets($this->fp, 256); + $tmplen = strlen($tmp); + $this->debug("read chunk line of $tmplen bytes"); + if ($tmplen == 0) { + $this->incoming_payload = $data; + $this->debug('socket read of chunk length timed out after length ' . strlen($data)); + $this->debug("read before timeout:\n" . $data); + $this->setError('socket read of chunk length timed out'); + return false; + } + $content_length = hexdec(trim($tmp)); + $this->debug("chunk length $content_length"); + } + $strlen = 0; + while (($strlen < $content_length) && (!feof($this->fp))) { + $readlen = min(8192, $content_length - $strlen); + $tmp = fread($this->fp, $readlen); + $tmplen = strlen($tmp); + $this->debug("read buffer of $tmplen bytes"); + if (($tmplen == 0) && (!feof($this->fp))) { + $this->incoming_payload = $data; + $this->debug('socket read of body timed out after length ' . strlen($data)); + $this->debug("read before timeout:\n" . $data); + $this->setError('socket read of body timed out'); + return false; + } + $strlen += $tmplen; + $data .= $tmp; + } + if ($chunked && ($content_length > 0)) { + $tmp = fgets($this->fp, 256); + $tmplen = strlen($tmp); + $this->debug("read chunk terminator of $tmplen bytes"); + if ($tmplen == 0) { + $this->incoming_payload = $data; + $this->debug('socket read of chunk terminator timed out after length ' . strlen($data)); + $this->debug("read before timeout:\n" . $data); + $this->setError('socket read of chunk terminator timed out'); + return false; + } + } + } while ($chunked && ($content_length > 0) && (!feof($this->fp))); + if (feof($this->fp)) { + $this->debug('read to EOF'); + } + $this->debug('read body of length ' . strlen($data)); + $this->incoming_payload .= $data; + $this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server'); - // loop until msg has been received - if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') { - $content_length = 2147483647; // ignore any content-length header - $chunked = true; - $this->debug("want to read chunked content"); - } elseif (isset($this->incoming_headers['content-length'])) { - $content_length = $this->incoming_headers['content-length']; - $chunked = false; - $this->debug("want to read content of length $content_length"); - } else { - $content_length = 2147483647; - $chunked = false; - $this->debug("want to read content to EOF"); - } - $data = ''; - do { - if ($chunked) { - $tmp = fgets($this->fp, 256); - $tmplen = strlen($tmp); - $this->debug("read chunk line of $tmplen bytes"); - if ($tmplen == 0) { - $this->incoming_payload = $data; - $this->debug('socket read of chunk length timed out after length ' . strlen($data)); - $this->debug("read before timeout:\n" . $data); - $this->setError('socket read of chunk length timed out'); - return false; - } - $content_length = hexdec(trim($tmp)); - $this->debug("chunk length $content_length"); - } - $strlen = 0; - while (($strlen < $content_length) && (!feof($this->fp))) { - $readlen = min(8192, $content_length - $strlen); - $tmp = fread($this->fp, $readlen); - $tmplen = strlen($tmp); - $this->debug("read buffer of $tmplen bytes"); - if (($tmplen == 0) && (!feof($this->fp))) { - $this->incoming_payload = $data; - $this->debug('socket read of body timed out after length ' . strlen($data)); - $this->debug("read before timeout:\n" . $data); - $this->setError('socket read of body timed out'); - return false; - } - $strlen += $tmplen; - $data .= $tmp; - } - if ($chunked && ($content_length > 0)) { - $tmp = fgets($this->fp, 256); - $tmplen = strlen($tmp); - $this->debug("read chunk terminator of $tmplen bytes"); - if ($tmplen == 0) { - $this->incoming_payload = $data; - $this->debug('socket read of chunk terminator timed out after length ' . strlen($data)); - $this->debug("read before timeout:\n" . $data); - $this->setError('socket read of chunk terminator timed out'); - return false; - } - } - } while ($chunked && ($content_length > 0) && (!feof($this->fp))); - if (feof($this->fp)) { - $this->debug('read to EOF'); - } - $this->debug('read body of length ' . strlen($data)); - $this->incoming_payload .= $data; - $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server'); + // close filepointer + if ( + (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || + (!$this->persistentConnection) || feof($this->fp) + ) { + fclose($this->fp); + $this->fp = false; + $this->debug('closed socket'); + } - // close filepointer - if( - (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || - (! $this->persistentConnection) || feof($this->fp)){ - fclose($this->fp); - $this->fp = false; - $this->debug('closed socket'); - } + // connection was closed unexpectedly + if ($this->incoming_payload == '') { + $this->setError('no response from server'); + return false; + } - // connection was closed unexpectedly - if($this->incoming_payload == ''){ - $this->setError('no response from server'); - return false; - } - - // decode transfer-encoding + // decode transfer-encoding // if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){ // if(!$data = $this->decodeChunked($data, $lb)){ // $this->setError('Decoding of chunked data failed'); // return false; // } - //print "
\nde-chunked:\n---------------\n$data\n\n---------------\n
"; - // set decoded payload + //print "
\nde-chunked:\n---------------\n$data\n\n---------------\n
"; + // set decoded payload // $this->incoming_payload = $header_data.$lb.$lb.$data; // } - } else if ($this->io_method() == 'curl') { - // send and receive - $this->debug('send and receive with cURL'); - $this->incoming_payload = curl_exec($this->ch); - $data = $this->incoming_payload; + } elseif ($this->io_method() == 'curl') { + // send and receive + $this->debug('send and receive with cURL'); + $this->incoming_payload = curl_exec($this->ch); + $data = $this->incoming_payload; - $cErr = curl_error($this->ch); - if ($cErr != '') { - $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'
'; - // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE - foreach(curl_getinfo($this->ch) as $k => $v){ - $err .= "$k: $v
"; - } - $this->debug($err); - $this->setError($err); - curl_close($this->ch); - return false; - } else { - //echo '
';
-			//var_dump(curl_getinfo($this->ch));
-			//echo '
'; - } - // close curl - $this->debug('No cURL error, closing cURL'); - curl_close($this->ch); + $cErr = curl_error($this->ch); + if ($cErr != '') { + $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '
'; + // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE + foreach (curl_getinfo($this->ch) as $k => $v) { + if (is_array($v)) { + $this->debug("$k: " . json_encode($v)); + } else { + $this->debug("$k: $v
"); + } + } + $this->debug($err); + $this->setError($err); + curl_close($this->ch); + return false; + } + // close curl + $this->debug('No cURL error, closing cURL'); + curl_close($this->ch); - // try removing skippable headers - $savedata = $data; - while ($this->isSkippableCurlHeader($data)) { - $this->debug("Found HTTP header to skip"); - if ($pos = strpos($data,"\r\n\r\n")) { - $data = ltrim(substr($data,$pos)); - } elseif($pos = strpos($data,"\n\n") ) { - $data = ltrim(substr($data,$pos)); - } - } + // try removing skippable headers + $savedata = $data; + while ($this->isSkippableCurlHeader($data)) { + $this->debug("Found HTTP header to skip"); + if ($pos = strpos($data, "\r\n\r\n")) { + $data = ltrim(substr($data, $pos)); + } elseif ($pos = strpos($data, "\n\n")) { + $data = ltrim(substr($data, $pos)); + } + } - if ($data == '') { - // have nothing left; just remove 100 header(s) - $data = $savedata; - while (preg_match('/^HTTP\/1.1 100/',$data)) { - if ($pos = strpos($data,"\r\n\r\n")) { - $data = ltrim(substr($data,$pos)); - } elseif($pos = strpos($data,"\n\n") ) { - $data = ltrim(substr($data,$pos)); - } - } - } + if ($data == '') { + // have nothing left; just remove 100 header(s) + $data = $savedata; + while (preg_match('/^HTTP\/1.1 100/', $data)) { + if ($pos = strpos($data, "\r\n\r\n")) { + $data = ltrim(substr($data, $pos)); + } elseif ($pos = strpos($data, "\n\n")) { + $data = ltrim(substr($data, $pos)); + } + } + } - // separate content from HTTP headers - if ($pos = strpos($data,"\r\n\r\n")) { - $lb = "\r\n"; - } elseif( $pos = strpos($data,"\n\n")) { - $lb = "\n"; - } else { - $this->debug('no proper separation of headers and document'); - $this->setError('no proper separation of headers and document'); - return false; - } - $header_data = trim(substr($data,0,$pos)); - $header_array = explode($lb,$header_data); - $data = ltrim(substr($data,$pos)); - $this->debug('found proper separation of headers and document'); - $this->debug('cleaned data, stringlen: '.strlen($data)); - // clean headers - foreach ($header_array as $header_line) { - $arr = explode(':',$header_line,2); - if(count($arr) > 1){ - $header_name = strtolower(trim($arr[0])); - $this->incoming_headers[$header_name] = trim($arr[1]); - if ($header_name == 'set-cookie') { - // TODO: allow multiple cookies from parseCookie - $cookie = $this->parseCookie(trim($arr[1])); - if ($cookie) { - $this->incoming_cookies[] = $cookie; - $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']); - } else { - $this->debug('did not find cookie in ' . trim($arr[1])); - } - } - } else if (isset($header_name)) { - // append continuation line to previous header - $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; - } - } - } + // separate content from HTTP headers + if ($pos = strpos($data, "\r\n\r\n")) { + $lb = "\r\n"; + } elseif ($pos = strpos($data, "\n\n")) { + $lb = "\n"; + } else { + $this->debug('no proper separation of headers and document'); + $this->setError('no proper separation of headers and document'); + return false; + } + $header_data = trim(substr($data, 0, $pos)); + $header_array = explode($lb, $header_data); + $data = ltrim(substr($data, $pos)); + $this->debug('found proper separation of headers and document'); + $this->debug('cleaned data, stringlen: ' . strlen($data)); + // clean headers + foreach ($header_array as $header_line) { + $arr = explode(':', $header_line, 2); + if (count($arr) > 1) { + $header_name = strtolower(trim($arr[0])); + $this->incoming_headers[$header_name] = trim($arr[1]); + if ($header_name == 'set-cookie') { + // TODO: allow multiple cookies from parseCookie + $cookie = $this->parseCookie(trim($arr[1])); + if ($cookie) { + $this->incoming_cookies[] = $cookie; + $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']); + } else { + $this->debug('did not find cookie in ' . trim($arr[1])); + } + } + } elseif (isset($header_name)) { + // append continuation line to previous header + $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; + } + } + } - $this->response_status_line = $header_array[0]; - $arr = explode(' ', $this->response_status_line, 3); - $http_version = $arr[0]; - $http_status = intval($arr[1]); - $http_reason = count($arr) > 2 ? $arr[2] : ''; + $this->response_status_line = $header_array[0]; + $arr = explode(' ', $this->response_status_line, 3); + $http_status = intval($arr[1]); + $http_reason = count($arr) > 2 ? $arr[2] : ''; - // see if we need to resend the request with http digest authentication - if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) { - $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']); - $this->setURL($this->incoming_headers['location']); - $this->tryagain = true; - return false; - } + // see if we need to resend the request with http digest authentication + if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) { + $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']); + $this->setURL($this->incoming_headers['location']); + $this->tryagain = true; + return false; + } - // see if we need to resend the request with http digest authentication - if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) { - $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']); - if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) { - $this->debug('Server wants digest authentication'); - // remove "Digest " from our elements - $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']); + // see if we need to resend the request with http digest authentication + if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) { + $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']); + if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) { + $this->debug('Server wants digest authentication'); + // remove "Digest " from our elements + $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']); - // parse elements into array - $digestElements = explode(',', $digestString); - foreach ($digestElements as $val) { - $tempElement = explode('=', trim($val), 2); - $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]); - } + // parse elements into array + $digestElements = explode(',', $digestString); + foreach ($digestElements as $val) { + $tempElement = explode('=', trim($val), 2); + $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]); + } - // should have (at least) qop, realm, nonce - if (isset($digestRequest['nonce'])) { - $this->setCredentials($this->username, $this->password, 'digest', $digestRequest); - $this->tryagain = true; - return false; - } - } - $this->debug('HTTP authentication failed'); - $this->setError('HTTP authentication failed'); - return false; - } + // should have (at least) qop, realm, nonce + if (isset($digestRequest['nonce'])) { + $this->setCredentials($this->username, $this->password, 'digest', $digestRequest); + $this->tryagain = true; + return false; + } + } + $this->debug('HTTP authentication failed'); + $this->setError('HTTP authentication failed'); + return false; + } - if ( - ($http_status >= 300 && $http_status <= 307) || - ($http_status >= 400 && $http_status <= 417) || - ($http_status >= 501 && $http_status <= 505) - ) { - $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)"); - return false; - } + if ( + ($http_status >= 300 && $http_status <= 307) || + ($http_status >= 400 && $http_status <= 417) || + ($http_status >= 501 && $http_status <= 505) + ) { + $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)"); + return false; + } - // decode content-encoding - if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){ - if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){ - // if decoding works, use it. else assume data wasn't gzencoded - if(function_exists('gzinflate')){ - //$timer->setMarker('starting decoding of gzip/deflated content'); - // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress) - // this means there are no Zlib headers, although there should be - $this->debug('The gzinflate function exists'); - $datalen = strlen($data); - if ($this->incoming_headers['content-encoding'] == 'deflate') { - if ($degzdata = @gzinflate($data)) { - $data = $degzdata; - $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes'); - if (strlen($data) < $datalen) { - // test for the case that the payload has been compressed twice - $this->debug('The inflated payload is smaller than the gzipped one; try again'); - if ($degzdata = @gzinflate($data)) { - $data = $degzdata; - $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes'); - } - } - } else { - $this->debug('Error using gzinflate to inflate the payload'); - $this->setError('Error using gzinflate to inflate the payload'); - } - } elseif ($this->incoming_headers['content-encoding'] == 'gzip') { - if ($degzdata = @gzinflate(substr($data, 10))) { // do our best - $data = $degzdata; - $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes'); - if (strlen($data) < $datalen) { - // test for the case that the payload has been compressed twice - $this->debug('The un-gzipped payload is smaller than the gzipped one; try again'); - if ($degzdata = @gzinflate(substr($data, 10))) { - $data = $degzdata; - $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes'); - } - } - } else { - $this->debug('Error using gzinflate to un-gzip the payload'); - $this->setError('Error using gzinflate to un-gzip the payload'); - } - } - //$timer->setMarker('finished decoding of gzip/deflated content'); - //print "\nde-inflated:\n---------------\n$data\n-------------\n"; - // set decoded payload - $this->incoming_payload = $header_data.$lb.$lb.$data; - } else { - $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.'); - $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.'); - } - } else { - $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']); - $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']); - } - } else { - $this->debug('No Content-Encoding header'); - } + // decode content-encoding + if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') { + if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') { + $header_data = ""; + // if decoding works, use it. else assume data wasn't gzencoded + if (function_exists('gzinflate')) { + //$timer->setMarker('starting decoding of gzip/deflated content'); + // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress) + // this means there are no Zlib headers, although there should be + $this->debug('The gzinflate function exists'); + $datalen = strlen($data); + if ($this->incoming_headers['content-encoding'] == 'deflate') { + if ($degzdata = @gzinflate($data)) { + $data = $degzdata; + $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes'); + if (strlen($data) < $datalen) { + // test for the case that the payload has been compressed twice + $this->debug('The inflated payload is smaller than the gzipped one; try again'); + if ($degzdata = @gzinflate($data)) { + $data = $degzdata; + $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes'); + } + } + } else { + $this->debug('Error using gzinflate to inflate the payload'); + $this->setError('Error using gzinflate to inflate the payload'); + } + } elseif ($this->incoming_headers['content-encoding'] == 'gzip') { + if ($degzdata = @gzinflate(substr($data, 10))) { // do our best + $data = $degzdata; + $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes'); + if (strlen($data) < $datalen) { + // test for the case that the payload has been compressed twice + $this->debug('The un-gzipped payload is smaller than the gzipped one; try again'); + if ($degzdata = @gzinflate(substr($data, 10))) { + $data = $degzdata; + $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes'); + } + } + } else { + $this->debug('Error using gzinflate to un-gzip the payload'); + $this->setError('Error using gzinflate to un-gzip the payload'); + } + } + //$timer->setMarker('finished decoding of gzip/deflated content'); + //print "\nde-inflated:\n---------------\n$data\n-------------\n"; + // set decoded payload + $this->incoming_payload = $header_data . (isset ($lb) ? $lb : "") . (isset ($lb) ? $lb : "") . $data; + } else { + $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.'); + $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.'); + } + } else { + $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']); + $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']); + } + } else { + $this->debug('No Content-Encoding header'); + } - if(strlen($data) == 0){ - $this->debug('no data after headers!'); - $this->setError('no data present after HTTP headers'); - return false; - } + if (strlen($data) == 0) { + $this->debug('no data after headers!'); + $this->setError('no data present after HTTP headers'); + return false; + } - return $data; - } + return $data; + } - /** - * sets the content-type for the SOAP message to be sent - * - * @param string $type the content type, MIME style - * @param mixed $charset character set used for encoding (or false) - * @access public - */ - function setContentType($type, $charset = false) { - $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : '')); - } + /** + * sets the content-type for the SOAP message to be sent + * + * @param string $type the content type, MIME style + * @param mixed $charset character set used for encoding (or false) + * @access public + */ + function setContentType($type, $charset = false) + { + $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : '')); + } - /** - * specifies that an HTTP persistent connection should be used - * - * @return boolean whether the request was honored by this method. - * @access public - */ - function usePersistentConnection(){ - if (isset($this->outgoing_headers['Accept-Encoding'])) { - return false; - } - $this->protocol_version = '1.1'; - $this->persistentConnection = true; - $this->setHeader('Connection', 'Keep-Alive'); - return true; - } + /** + * specifies that an HTTP persistent connection should be used + * + * @return boolean whether the request was honored by this method. + * @access public + */ + function usePersistentConnection() + { + if (isset($this->outgoing_headers['Accept-Encoding'])) { + return false; + } + $this->protocol_version = '1.1'; + $this->persistentConnection = true; + $this->setHeader('Connection', 'Keep-Alive'); + return true; + } - /** - * parse an incoming Cookie into it's parts - * - * @param string $cookie_str content of cookie - * @return array with data of that cookie - * @access private - */ - /* + /** + * parse an incoming Cookie into it's parts + * + * @param string $cookie_str content of cookie + * @return array with data of that cookie + * @access private + */ + /* * TODO: allow a Set-Cookie string to be parsed into multiple cookies */ - function parseCookie($cookie_str) { - $cookie_str = str_replace('; ', ';', $cookie_str) . ';'; - $data = preg_split('/;/', $cookie_str); - $value_str = $data[0]; + function parseCookie($cookie_str) + { + $cookie_str = str_replace('; ', ';', $cookie_str) . ';'; + $data = explode (';', $cookie_str); + $value_str = $data[0]; - $cookie_param = 'domain='; - $start = strpos($cookie_str, $cookie_param); - if ($start > 0) { - $domain = substr($cookie_str, $start + strlen($cookie_param)); - $domain = substr($domain, 0, strpos($domain, ';')); - } else { - $domain = ''; - } + $cookie_param = 'domain='; + $start = strpos($cookie_str, $cookie_param); + if ($start > 0) { + $domain = substr($cookie_str, $start + strlen($cookie_param)); + $domain = substr($domain, 0, strpos($domain, ';')); + } else { + $domain = ''; + } - $cookie_param = 'expires='; - $start = strpos($cookie_str, $cookie_param); - if ($start > 0) { - $expires = substr($cookie_str, $start + strlen($cookie_param)); - $expires = substr($expires, 0, strpos($expires, ';')); - } else { - $expires = ''; - } + $cookie_param = 'expires='; + $start = strpos($cookie_str, $cookie_param); + if ($start > 0) { + $expires = substr($cookie_str, $start + strlen($cookie_param)); + $expires = substr($expires, 0, strpos($expires, ';')); + } else { + $expires = ''; + } - $cookie_param = 'path='; - $start = strpos($cookie_str, $cookie_param); - if ( $start > 0 ) { - $path = substr($cookie_str, $start + strlen($cookie_param)); - $path = substr($path, 0, strpos($path, ';')); - } else { - $path = '/'; - } + $cookie_param = 'path='; + $start = strpos($cookie_str, $cookie_param); + if ($start > 0) { + $path = substr($cookie_str, $start + strlen($cookie_param)); + $path = substr($path, 0, strpos($path, ';')); + } else { + $path = '/'; + } - $cookie_param = ';secure;'; - if (strpos($cookie_str, $cookie_param) !== FALSE) { - $secure = true; - } else { - $secure = false; - } + $cookie_param = ';secure;'; + if (strpos($cookie_str, $cookie_param) !== false) { + $secure = true; + } else { + $secure = false; + } - $sep_pos = strpos($value_str, '='); + $sep_pos = strpos($value_str, '='); - if ($sep_pos) { - $name = substr($value_str, 0, $sep_pos); - $value = substr($value_str, $sep_pos + 1); - $cookie= array( 'name' => $name, - 'value' => $value, - 'domain' => $domain, - 'path' => $path, - 'expires' => $expires, - 'secure' => $secure - ); - return $cookie; - } - return false; - } + if ($sep_pos) { + $name = substr($value_str, 0, $sep_pos); + $value = substr($value_str, $sep_pos + 1); - /** - * sort out cookies for the current request - * - * @param array $cookies array with all cookies - * @param boolean $secure is the send-content secure or not? - * @return string for Cookie-HTTP-Header - * @access private - */ - function getCookiesForRequest($cookies, $secure=false) { - $cookie_str = ''; - if ((! is_null($cookies)) && (is_array($cookies))) { - foreach ($cookies as $cookie) { - if (! is_array($cookie)) { - continue; - } - $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']); - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) { - if (strtotime($cookie['expires']) <= time()) { - $this->debug('cookie has expired'); - continue; - } - } - if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) { - $domain = preg_quote($cookie['domain']); - if (! preg_match("'.*$domain$'i", $this->host)) { - $this->debug('cookie has different domain'); - continue; - } - } - if ((isset($cookie['path'])) && (! empty($cookie['path']))) { - $path = preg_quote($cookie['path']); - if (! preg_match("'^$path.*'i", $this->path)) { - $this->debug('cookie is for a different path'); - continue; - } - } - if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) { - $this->debug('cookie is secure, transport is not'); - continue; - } - $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; '; - $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']); - } - } - return $cookie_str; - } + return array('name' => $name, + 'value' => $value, + 'domain' => $domain, + 'path' => $path, + 'expires' => $expires, + 'secure' => $secure + ); + } + return array (); + } + + /** + * sort out cookies for the current request + * + * @param array $cookies array with all cookies + * @param boolean $secure is the send-content secure or not? + * @return string for Cookie-HTTP-Header + * @access private + */ + function getCookiesForRequest($cookies, $secure = false) + { + $cookie_str = ''; + if ((is_array($cookies))) { + foreach ($cookies as $cookie) { + if (!is_array($cookie)) { + continue; + } + $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']); + if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) { + if (strtotime($cookie['expires']) <= time()) { + $this->debug('cookie has expired'); + continue; + } + } + if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) { + $domain = preg_quote($cookie['domain'], "'"); + if (!preg_match("'.*$domain$'i", $this->host)) { + $this->debug('cookie has different domain'); + continue; + } + } + if ((isset($cookie['path'])) && (!empty($cookie['path']))) { + $path = preg_quote($cookie['path'], "'"); + if (!preg_match("'^$path.*'i", $this->path)) { + $this->debug('cookie is for a different path'); + continue; + } + } + if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) { + $this->debug('cookie is secure, transport is not'); + continue; + } + $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; '; + $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']); + } + } + return $cookie_str; + } } -?> -* @author Scott Nichol -* @access public -*/ -class nusoap_server extends nusoap_base { - /** - * HTTP headers of request - * @var array - * @access private - */ - var $headers = array(); - /** - * HTTP request - * @var string - * @access private - */ - var $request = ''; - /** - * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text) - * @var string - * @access public - */ - var $requestHeaders = ''; - /** - * SOAP Headers from request (parsed) - * @var mixed - * @access public - */ - var $requestHeader = NULL; - /** - * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text) - * @var string - * @access public - */ - var $document = ''; - /** - * SOAP payload for request (text) - * @var string - * @access public - */ - var $requestSOAP = ''; - /** - * requested method namespace URI - * @var string - * @access private - */ - var $methodURI = ''; - /** - * name of method requested - * @var string - * @access private - */ - var $methodname = ''; - /** - * method parameters from request - * @var array - * @access private - */ - var $methodparams = array(); - /** - * SOAP Action from request - * @var string - * @access private - */ - var $SOAPAction = ''; - /** - * character set encoding of incoming (request) messages - * @var string - * @access public - */ - var $xml_encoding = ''; - /** - * toggles whether the parser decodes element content w/ utf8_decode() - * @var boolean - * @access public - */ + * + * nusoap_server allows the user to create a SOAP server + * that is capable of receiving messages and returning responses + * + * @author Dietrich Ayala + * @author Scott Nichol + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class nusoap_server extends nusoap_base +{ + /** + * HTTP headers of request + * + * @var array + * @access private + */ + var $headers = array(); + /** + * HTTP request + * + * @var string + * @access private + */ + var $request = ''; + /** + * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text) + * + * @var string + * @access public + */ + var $requestHeaders = ''; + /** + * SOAP Headers from request (parsed) + * + * @var mixed + * @access public + */ + var $requestHeader = null; + /** + * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text) + * + * @var string + * @access public + */ + var $document = ''; + /** + * SOAP payload for request (text) + * + * @var string + * @access public + */ + var $requestSOAP = ''; + /** + * requested method namespace URI + * + * @var string + * @access private + */ + var $methodURI = ''; + /** + * name of method requested + * + * @var string + * @access private + */ + var $methodname = ''; + /** + * name of the response tag name + * + * @var string + * @access private + */ + var $responseTagName = ''; + /** + * method parameters from request + * + * @var array + * @access private + */ + var $methodparams = array(); + /** + * SOAP Action from request + * + * @var string + * @access private + */ + var $SOAPAction = ''; + /** + * character set encoding of incoming (request) messages + * + * @var string + * @access public + */ + var $xml_encoding = ''; + /** + * toggles whether the parser decodes element content w/ utf8_decode() + * + * @var boolean + * @access public + */ var $decode_utf8 = true; - /** - * HTTP headers of response - * @var array - * @access public - */ - var $outgoing_headers = array(); - /** - * HTTP response - * @var string - * @access private - */ - var $response = ''; - /** - * SOAP headers for response (text or array of soapval or associative array) - * @var mixed - * @access public - */ - var $responseHeaders = ''; - /** - * SOAP payload for response (text) - * @var string - * @access private - */ - var $responseSOAP = ''; - /** - * method return value to place in response - * @var mixed - * @access private - */ - var $methodreturn = false; - /** - * whether $methodreturn is a string of literal XML - * @var boolean - * @access public - */ - var $methodreturnisliteralxml = false; - /** - * SOAP fault for response (or false) - * @var mixed - * @access private - */ - var $fault = false; - /** - * text indication of result (for debugging) - * @var string - * @access private - */ - var $result = 'successful'; - - /** - * assoc array of operations => opData; operations are added by the register() - * method or by parsing an external WSDL definition - * @var array - * @access private - */ - var $operations = array(); - /** - * wsdl instance (if one) - * @var mixed - * @access private - */ - var $wsdl = false; - /** - * URL for WSDL (if one) - * @var mixed - * @access private - */ - var $externalWSDLURL = false; - /** - * whether to append debug to response as XML comment - * @var boolean - * @access public - */ - var $debug_flag = false; - - - /** - * constructor - * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to. - * - * @param mixed $wsdl file path or URL (string), or wsdl instance (object) - * @access public - */ - function __construct($wsdl=false) { - parent::__construct(); - // turn on debugging? - global $debug; - global $HTTP_SERVER_VARS; - - if (isset($_SERVER)) { - $this->debug("_SERVER is defined:"); - $this->appendDebug($this->varDump($_SERVER)); - } elseif (isset($HTTP_SERVER_VARS)) { - $this->debug("HTTP_SERVER_VARS is defined:"); - $this->appendDebug($this->varDump($HTTP_SERVER_VARS)); - } else { - $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined."); - } - - if (isset($debug)) { - $this->debug("In nusoap_server, set debug_flag=$debug based on global flag"); - $this->debug_flag = $debug; - } elseif (isset($_SERVER['QUERY_STRING'])) { - $qs = explode('&', $_SERVER['QUERY_STRING']); - foreach ($qs as $v) { - if (substr($v, 0, 6) == 'debug=') { - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1"); - $this->debug_flag = substr($v, 6); - } - } - } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { - $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); - foreach ($qs as $v) { - if (substr($v, 0, 6) == 'debug=') { - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2"); - $this->debug_flag = substr($v, 6); - } - } - } - - // wsdl - if($wsdl){ - $this->debug("In nusoap_server, WSDL is specified"); - if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) { - $this->wsdl = $wsdl; - $this->externalWSDLURL = $this->wsdl->wsdl; - $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL); - } else { - $this->debug('Create wsdl from ' . $wsdl); - $this->wsdl = new wsdl($wsdl); - $this->externalWSDLURL = $wsdl; - } - $this->appendDebug($this->wsdl->getDebug()); - $this->wsdl->clearDebug(); - if($err = $this->wsdl->getError()){ - die('WSDL ERROR: '.$err); - } - } - } - - /** - * processes request and returns response - * - * @param string $data usually is the value of $HTTP_RAW_POST_DATA - * @access public - */ - function service($data){ - global $HTTP_SERVER_VARS; - - if (isset($_SERVER['REQUEST_METHOD'])) { - $rm = $_SERVER['REQUEST_METHOD']; - } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) { - $rm = $HTTP_SERVER_VARS['REQUEST_METHOD']; - } else { - $rm = ''; - } - - if (isset($_SERVER['QUERY_STRING'])) { - $qs = $_SERVER['QUERY_STRING']; - } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { - $qs = $HTTP_SERVER_VARS['QUERY_STRING']; - } else { - $qs = ''; - } - $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data)); - - if ($rm == 'POST') { - $this->debug("In service, invoke the request"); - $this->parse_request($data); - if (! $this->fault) { - $this->invoke_method(); - } - if (! $this->fault) { - $this->serialize_return(); - } - $this->send_response(); - } elseif (preg_match('/wsdl/', $qs) ){ - $this->debug("In service, this is a request for WSDL"); - if ($this->externalWSDLURL){ - if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL - $this->debug("In service, re-direct for WSDL"); - header('Location: '.$this->externalWSDLURL); - } else { // assume file - $this->debug("In service, use file passthru for WSDL"); - header("Content-Type: text/xml\r\n"); - $pos = strpos($this->externalWSDLURL, "file://"); - if ($pos === false) { - $filename = $this->externalWSDLURL; - } else { - $filename = substr($this->externalWSDLURL, $pos + 7); - } - $fp = fopen($this->externalWSDLURL, 'r'); - fpassthru($fp); - } - } elseif ($this->wsdl) { - $this->debug("In service, serialize WSDL"); - header("Content-Type: text/xml; charset=ISO-8859-1\r\n"); - print $this->wsdl->serialize($this->debug_flag); - if ($this->debug_flag) { - $this->debug('wsdl:'); - $this->appendDebug($this->varDump($this->wsdl)); - print $this->getDebugAsXMLComment(); - } - } else { - $this->debug("In service, there is no WSDL"); - header("Content-Type: text/html; charset=ISO-8859-1\r\n"); - print "This service does not provide WSDL"; - } - } elseif ($this->wsdl) { - $this->debug("In service, return Web description"); - print $this->wsdl->webDescription(); - } else { - $this->debug("In service, no Web description"); - header("Content-Type: text/html; charset=ISO-8859-1\r\n"); - print "This service does not provide a Web description"; - } - } - - /** - * parses HTTP request headers. - * - * The following fields are set by this function (when successful) - * - * headers - * request - * xml_encoding - * SOAPAction - * - * @access private - */ - function parse_http_headers() { - global $HTTP_SERVER_VARS; - - $this->request = ''; - $this->SOAPAction = ''; - if(function_exists('getallheaders')){ - $this->debug("In parse_http_headers, use getallheaders"); - $headers = getallheaders(); - foreach($headers as $k=>$v){ - $k = strtolower($k); - $this->headers[$k] = $v; - $this->request .= "$k: $v\r\n"; - $this->debug("$k: $v"); - } - // get SOAPAction header - if(isset($this->headers['soapaction'])){ - $this->SOAPAction = str_replace('"','',$this->headers['soapaction']); - } - // get the character encoding of the incoming request - if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ - $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ - $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; - } - } else { - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 - $this->xml_encoding = 'ISO-8859-1'; - } - } elseif(isset($_SERVER) && is_array($_SERVER)){ - $this->debug("In parse_http_headers, use _SERVER"); - foreach ($_SERVER as $k => $v) { - if (substr($k, 0, 5) == 'HTTP_') { - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); - } else { - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); - } - if ($k == 'soapaction') { - // get SOAPAction header - $k = 'SOAPAction'; - $v = str_replace('"', '', $v); - $v = str_replace('\\', '', $v); - $this->SOAPAction = $v; - } else if ($k == 'content-type') { - // get the character encoding of the incoming request - if (strpos($v, '=')) { - $enc = substr(strstr($v, '='), 1); - $enc = str_replace('"', '', $enc); - $enc = str_replace('\\', '', $enc); - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { - $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; - } - } else { - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 - $this->xml_encoding = 'ISO-8859-1'; - } - } - $this->headers[$k] = $v; - $this->request .= "$k: $v\r\n"; - $this->debug("$k: $v"); - } - } elseif (is_array($HTTP_SERVER_VARS)) { - $this->debug("In parse_http_headers, use HTTP_SERVER_VARS"); - foreach ($HTTP_SERVER_VARS as $k => $v) { - if (substr($k, 0, 5) == 'HTTP_') { - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5)); - } else { - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k); - } - if ($k == 'soapaction') { - // get SOAPAction header - $k = 'SOAPAction'; - $v = str_replace('"', '', $v); - $v = str_replace('\\', '', $v); - $this->SOAPAction = $v; - } else if ($k == 'content-type') { - // get the character encoding of the incoming request - if (strpos($v, '=')) { - $enc = substr(strstr($v, '='), 1); - $enc = str_replace('"', '', $enc); - $enc = str_replace('\\', '', $enc); - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { - $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; - } - } else { - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 - $this->xml_encoding = 'ISO-8859-1'; - } - } - $this->headers[$k] = $v; - $this->request .= "$k: $v\r\n"; - $this->debug("$k: $v"); - } - } else { - $this->debug("In parse_http_headers, HTTP headers not accessible"); - $this->setError("HTTP headers not accessible"); - } - } - - /** - * parses a request - * - * The following fields are set by this function (when successful) - * - * headers - * request - * xml_encoding - * SOAPAction - * request - * requestSOAP - * methodURI - * methodname - * methodparams - * requestHeaders - * document - * - * This sets the fault field on error - * - * @param string $data XML string - * @access private - */ - function parse_request($data='') { - $this->debug('entering parse_request()'); - $this->parse_http_headers(); - $this->debug('got character encoding: '.$this->xml_encoding); - // uncompress if necessary - if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') { - $this->debug('got content encoding: ' . $this->headers['content-encoding']); - if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') { - // if decoding works, use it. else assume data wasn't gzencoded - if (function_exists('gzuncompress')) { - if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { - $data = $degzdata; - } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) { - $data = $degzdata; - } else { - $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data'); - return; - } - } else { - $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data'); - return; - } - } - } - $this->request .= "\r\n".$data; - $data = $this->parseRequest($this->headers, $data); - $this->requestSOAP = $data; - $this->debug('leaving parse_request'); - } - - /** - * invokes a PHP function for the requested SOAP method - * - * The following fields are set by this function (when successful) - * - * methodreturn - * - * Note that the PHP function that is called may also set the following - * fields to affect the response sent to the client - * - * responseHeaders - * outgoing_headers - * - * This sets the fault field on error - * - * @access private - */ - function invoke_method() { - $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction); - - // - // if you are debugging in this area of the code, your service uses a class to implement methods, - // you use SOAP RPC, and the client is .NET, please be aware of the following... - // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the - // method name. that is fine for naming the .NET methods. it is not fine for properly constructing - // the XML request and reading the XML response. you need to add the RequestElementName and - // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe - // generates for the method. these parameters are used to specify the correct XML element names - // for .NET to use, i.e. the names with the '.' in them. - // - $orig_methodname = $this->methodname; - if ($this->wsdl) { - if ($this->opData = $this->wsdl->getOperationData($this->methodname)) { - $this->debug('in invoke_method, found WSDL operation=' . $this->methodname); - $this->appendDebug('opData=' . $this->varDump($this->opData)); - } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) { - // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element - $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']); - $this->appendDebug('opData=' . $this->varDump($this->opData)); - $this->methodname = $this->opData['name']; - } else { - $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname); - $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service"); - return; - } - } else { - $this->debug('in invoke_method, no WSDL to validate method'); - } - - // if a . is present in $this->methodname, we see if there is a class in scope, - // which could be referred to. We will also distinguish between two deliminators, - // to allow methods to be called a the class or an instance - if (strpos($this->methodname, '..') > 0) { - $delim = '..'; - } else if (strpos($this->methodname, '.') > 0) { - $delim = '.'; - } else { - $delim = ''; - } - $this->debug("in invoke_method, delim=$delim"); - - $class = ''; - $method = ''; - if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) { - $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim)); - if (class_exists($try_class)) { - // get the class and method name - $class = $try_class; - $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim)); - $this->debug("in invoke_method, class=$class method=$method delim=$delim"); - } else { - $this->debug("in invoke_method, class=$try_class not found"); - } - } else { - $try_class = ''; - $this->debug("in invoke_method, no class to try"); - } - - // does method exist? - if ($class == '') { - if (!function_exists($this->methodname)) { - $this->debug("in invoke_method, function '$this->methodname' not found!"); - $this->result = 'fault: method not found'; - $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')"); - return; - } - } else { - $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method; - if (!in_array($method_to_compare, get_class_methods($class))) { - $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!"); - $this->result = 'fault: method not found'; - $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')"); - return; - } - } - - // evaluate message, getting back parameters - // verify that request parameters match the method's signature - if(! $this->verify_method($this->methodname,$this->methodparams)){ - // debug - $this->debug('ERROR: request not verified against method signature'); - $this->result = 'fault: request failed validation against method signature'; - // return fault - $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service."); - return; - } - - // if there are parameters to pass - $this->debug('in invoke_method, params:'); - $this->appendDebug($this->varDump($this->methodparams)); - $this->debug("in invoke_method, calling '$this->methodname'"); - if (!function_exists('call_user_func_array')) { - if ($class == '') { - $this->debug('in invoke_method, calling function using eval()'); - $funcCall = "\$this->methodreturn = $this->methodname("; - } else { - if ($delim == '..') { - $this->debug('in invoke_method, calling class method using eval()'); - $funcCall = "\$this->methodreturn = ".$class."::".$method."("; - } else { - $this->debug('in invoke_method, calling instance method using eval()'); - // generate unique instance name - $instname = "\$inst_".time(); - $funcCall = $instname." = new ".$class."(); "; - $funcCall .= "\$this->methodreturn = ".$instname."->".$method."("; - } - } - if ($this->methodparams) { - foreach ($this->methodparams as $param) { - if (is_array($param) || is_object($param)) { - $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available'); - return; - } - $funcCall .= "\"$param\","; - } - $funcCall = substr($funcCall, 0, -1); - } - $funcCall .= ');'; - $this->debug('in invoke_method, function call: '.$funcCall); - @eval($funcCall); - } else { - if ($class == '') { - $this->debug('in invoke_method, calling function using call_user_func_array()'); - $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() - } elseif ($delim == '..') { - $this->debug('in invoke_method, calling class method using call_user_func_array()'); - $call_arg = array ($class, $method); - } else { - $this->debug('in invoke_method, calling instance method using call_user_func_array()'); - $instance = new $class (); - $call_arg = array(&$instance, $method); - } - if (is_array($this->methodparams)) { - $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams)); - } else { - $this->methodreturn = call_user_func_array($call_arg, array()); - } - } - $this->debug('in invoke_method, methodreturn:'); - $this->appendDebug($this->varDump($this->methodreturn)); - $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn)); - } - - /** - * serializes the return value from a PHP function into a full SOAP Envelope - * - * The following fields are set by this function (when successful) - * - * responseSOAP - * - * This sets the fault field on error - * - * @access private - */ - function serialize_return() { - $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); - // if fault - if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) { - $this->debug('got a fault object from method'); - $this->fault = $this->methodreturn; - return; - } elseif ($this->methodreturnisliteralxml) { - $return_val = $this->methodreturn; - // returned value(s) - } else { - $this->debug('got a(n) '.gettype($this->methodreturn).' from method'); - $this->debug('serializing return value'); - if($this->wsdl){ - if (sizeof($this->opData['output']['parts']) > 1) { - $this->debug('more than one output part, so use the method return unchanged'); - $opParams = $this->methodreturn; - } elseif (sizeof($this->opData['output']['parts']) == 1) { - $this->debug('exactly one output part, so wrap the method return in a simple array'); - // TODO: verify that it is not already wrapped! - //foreach ($this->opData['output']['parts'] as $name => $type) { - // $this->debug('wrap in element named ' . $name); - //} - $opParams = array($this->methodreturn); - } - $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams); - $this->appendDebug($this->wsdl->getDebug()); - $this->wsdl->clearDebug(); - if($errstr = $this->wsdl->getError()){ - $this->debug('got wsdl error: '.$errstr); - $this->fault('SOAP-ENV:Server', 'unable to serialize result'); - return; - } - } else { - if (isset($this->methodreturn)) { - $return_val = $this->serialize_val($this->methodreturn, 'return'); - } else { - $return_val = ''; - $this->debug('in absence of WSDL, assume void return for backward compatibility'); - } - } - } - $this->debug('return value:'); - $this->appendDebug($this->varDump($return_val)); - - $this->debug('serializing response'); - if ($this->wsdl) { - $this->debug('have WSDL for serialization: style is ' . $this->opData['style']); - if ($this->opData['style'] == 'rpc') { - $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']); - if ($this->opData['output']['use'] == 'literal') { - // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace - if ($this->methodURI) { - $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>"; - } else { - $payload = '<'.$this->methodname.'Response>'.$return_val.'methodname.'Response>'; - } - } else { - if ($this->methodURI) { - $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>"; - } else { - $payload = '<'.$this->methodname.'Response>'.$return_val.'methodname.'Response>'; - } - } - } else { - $this->debug('style is not rpc for serialization: assume document'); - $payload = $return_val; - } - } else { - $this->debug('do not have WSDL for serialization: assume rpc/encoded'); - $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>"; - } - $this->result = 'successful'; - if($this->wsdl){ - //if($this->debug_flag){ - $this->appendDebug($this->wsdl->getDebug()); - // } - if (isset($this->opData['output']['encodingStyle'])) { - $encodingStyle = $this->opData['output']['encodingStyle']; - } else { - $encodingStyle = ''; - } - // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces. - $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle); - } else { - $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders); - } - $this->debug("Leaving serialize_return"); - } - - /** - * sends an HTTP response - * - * The following fields are set by this function (when successful) - * - * outgoing_headers - * response - * - * @access private - */ - function send_response() { - $this->debug('Enter send_response'); - if ($this->fault) { - $payload = $this->fault->serialize(); - $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error"; - $this->outgoing_headers[] = "Status: 500 Internal Server Error"; - } else { - $payload = $this->responseSOAP; - // Some combinations of PHP+Web server allow the Status - // to come through as a header. Since OK is the default - // just do nothing. - // $this->outgoing_headers[] = "HTTP/1.0 200 OK"; - // $this->outgoing_headers[] = "Status: 200 OK"; - } - // add debug data if in debug mode - if(isset($this->debug_flag) && $this->debug_flag){ - $payload .= $this->getDebugAsXMLComment(); - } - $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; - // @CHANGE Fix for php8 - $rev = array(); - preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev); - $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")"; - // Let the Web server decide about this - //$this->outgoing_headers[] = "Connection: Close\r\n"; - $payload = $this->getHTTPBody($payload); - $type = $this->getHTTPContentType(); - $charset = $this->getHTTPContentTypeCharset(); - $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : ''); - //begin code to compress payload - by John - // NOTE: there is no way to know whether the Web server will also compress - // this data. - if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) { - if (strstr($this->headers['accept-encoding'], 'gzip')) { - if (function_exists('gzencode')) { - if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; - } - $this->outgoing_headers[] = "Content-Encoding: gzip"; - $payload = gzencode($payload); - } else { - if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; - } - } - } elseif (strstr($this->headers['accept-encoding'], 'deflate')) { - // Note: MSIE requires gzdeflate output (no Zlib header and checksum), - // instead of gzcompress output, - // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5) - if (function_exists('gzdeflate')) { - if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; - } - $this->outgoing_headers[] = "Content-Encoding: deflate"; - $payload = gzdeflate($payload); - } else { - if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; - } - } - } - } - //end code - $this->outgoing_headers[] = "Content-Length: ".strlen($payload); - reset($this->outgoing_headers); - foreach($this->outgoing_headers as $hdr){ - header($hdr, false); - } - print $payload; - $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload; - } - - /** - * takes the value that was created by parsing the request - * and compares to the method's signature, if available. - * - * @param string $operation The operation to be invoked - * @param array $request The array of parameter values - * @return boolean Whether the operation was found - * @access private - */ - function verify_method($operation,$request){ - if(isset($this->wsdl) && is_object($this->wsdl)){ - if($this->wsdl->getOperationData($operation)){ - return true; - } - } elseif(isset($this->operations[$operation])){ - return true; - } - return false; - } - - /** - * processes SOAP message received from client - * - * @param array $headers The HTTP headers - * @param string $data unprocessed request data from client - * @return mixed value of the message, decoded into a PHP type - * @access private - */ - function parseRequest($headers, $data) { - $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:'); - $this->appendDebug($this->varDump($headers)); - if (!isset($headers['content-type'])) { - $this->setError('Request not of type text/xml (no content-type header)'); - return false; - } - if (!strstr($headers['content-type'], 'text/xml')) { - $this->setError('Request not of type text/xml'); - return false; - } - if (strpos($headers['content-type'], '=')) { - $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); - $this->debug('Got response encoding: ' . $enc); - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ - $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; - } - } else { - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 - $this->xml_encoding = 'ISO-8859-1'; - } - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser'); - // parse response, get soap parser obj - $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8); - // parser debug - $this->debug("parser debug: \n".$parser->getDebug()); - // if fault occurred during message parsing - if($err = $parser->getError()){ - $this->result = 'fault: error in msg parsing: '.$err; - $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err); - // else successfully parsed request into soapval object - } else { - // get/set methodname - $this->methodURI = $parser->root_struct_namespace; - $this->methodname = $parser->root_struct_name; - $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI); - $this->debug('calling parser->get_soapbody()'); - $this->methodparams = $parser->get_soapbody(); - // get SOAP headers - $this->requestHeaders = $parser->getHeaders(); - // get SOAP Header - $this->requestHeader = $parser->get_soapheader(); - // add document for doclit support - $this->document = $parser->document; - } - } - - /** - * gets the HTTP body for the current response. - * - * @param string $soapmsg The SOAP payload - * @return string The HTTP body, which includes the SOAP payload - * @access private - */ - function getHTTPBody($soapmsg) { - return $soapmsg; - } - - /** - * gets the HTTP content type for the current response. - * - * Note: getHTTPBody must be called before this. - * - * @return string the HTTP content type for the current response. - * @access private - */ - function getHTTPContentType() { - return 'text/xml'; - } - - /** - * gets the HTTP content type charset for the current response. - * returns false for non-text content types. - * - * Note: getHTTPBody must be called before this. - * - * @return string the HTTP content type charset for the current response. - * @access private - */ - function getHTTPContentTypeCharset() { - return $this->soap_defencoding; - } - - /** - * add a method to the dispatch map (this has been replaced by the register method) - * - * @param string $methodname - * @param string $in array of input values - * @param string $out array of output values - * @access public - * @deprecated - */ - function add_to_map($methodname,$in,$out){ - $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out); - } - - /** - * register a service function with the server - * - * @param string $name the name of the PHP function, class.method or class..method - * @param array $in assoc array of input values: key = param name, value = param type - * @param array $out assoc array of output values: key = param name, value = param type - * @param mixed $namespace the element namespace for the method or false - * @param mixed $soapaction the soapaction for the method or false - * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically - * @param mixed $use optional (encoded|literal) or false - * @param string $documentation optional Description to include in WSDL - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) - * @access public - */ - function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){ - global $HTTP_SERVER_VARS; - - if($this->externalWSDLURL){ - die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.'); - } - if (! $name) { - die('You must specify a name when you register an operation'); - } - if (!is_array($in)) { - die('You must provide an array for operation inputs'); - } - if (!is_array($out)) { - die('You must provide an array for operation outputs'); - } - if(false == $namespace) { - } - if(false == $soapaction) { - if (isset($_SERVER)) { - $SERVER_NAME = $_SERVER['SERVER_NAME']; - $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; - $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); - } elseif (isset($HTTP_SERVER_VARS)) { - $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; - $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; - $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; - } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); - } - if ($HTTPS == '1' || $HTTPS == 'on') { - $SCHEME = 'https'; - } else { - $SCHEME = 'http'; - } - $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; - } - if(false == $style) { - $style = "rpc"; - } - if(false == $use) { - $use = "encoded"; - } - if ($use == 'encoded' && $encodingStyle == '') { - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; - } - - $this->operations[$name] = array( - 'name' => $name, - 'in' => $in, - 'out' => $out, - 'namespace' => $namespace, - 'soapaction' => $soapaction, - 'style' => $style); - if($this->wsdl){ - $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle); - } - return true; - } - - /** - * Specify a fault to be returned to the client. - * This also acts as a flag to the server that a fault has occured. - * - * @param string $faultcode - * @param string $faultstring - * @param string $faultactor - * @param string $faultdetail - * @access public - */ - function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){ - if ($faultdetail == '' && $this->debug_flag) { - $faultdetail = $this->getDebug(); - } - $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail); - $this->fault->soap_defencoding = $this->soap_defencoding; - } + /** + * HTTP headers of response + * + * @var array + * @access public + */ + var $outgoing_headers = array(); + /** + * HTTP response + * + * @var string + * @access private + */ + var $response = ''; + /** + * SOAP headers for response (text or array of soapval or associative array) + * + * @var mixed + * @access public + */ + var $responseHeaders = ''; + /** + * SOAP payload for response (text) + * + * @var string + * @access private + */ + var $responseSOAP = ''; + /** + * SOAP attachments in response + * + * @var string + * @access private + */ + var $attachments= ''; + /** + * method return value to place in response + * + * @var mixed + * @access private + */ + var $methodreturn = false; + /** + * whether $methodreturn is a string of literal XML + * + * @var boolean + * @access public + */ + var $methodreturnisliteralxml = false; + /** + * SOAP fault for response (or false) + * + * @var mixed + * @access private + */ + var $fault = false; + /** + * text indication of result (for debugging) + * + * @var string + * @access private + */ + var $result = 'successful'; /** - * Sets up wsdl object. - * Acts as a flag to enable internal WSDL generation - * - * @param string $serviceName, name of the service - * @param mixed $namespace optional 'tns' service namespace or false - * @param mixed $endpoint optional URL of service endpoint or false - * @param string $style optional (rpc|document) WSDL style (also specified by operation) - * @param string $transport optional SOAP transport - * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false - */ - function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) - { - global $HTTP_SERVER_VARS; + * assoc array of operations => opData; operations are added by the register() + * method or by parsing an external WSDL definition + * + * @var array + * @access private + */ + var $operations = array(); + /** + * wsdl instance (if one) + * + * @var mixed + * @access private + */ + var $wsdl = false; + /** + * URL for WSDL (if one) + * + * @var mixed + * @access private + */ + var $externalWSDLURL = false; + /** + * whether to append debug to response as XML comment + * + * @var boolean + * @access public + */ + var $debug_flag = false; - if (isset($_SERVER)) { - $SERVER_NAME = $_SERVER['SERVER_NAME']; - $SERVER_PORT = $_SERVER['SERVER_PORT']; - $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; - $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); - } elseif (isset($HTTP_SERVER_VARS)) { - $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; - $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT']; - $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; - $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; - } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); - } - // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) - $colon = strpos($SERVER_NAME,":"); - if ($colon) { - $SERVER_NAME = substr($SERVER_NAME, 0, $colon); - } - if ($SERVER_PORT == 80) { - $SERVER_PORT = ''; - } else { - $SERVER_PORT = ':' . $SERVER_PORT; - } - if(false == $namespace) { + /** @var array */ + var $opData; + + + /** + * constructor + * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to. + * + * @param mixed $wsdl file path or URL (string), or wsdl instance (object) + * @access public + */ + function __construct($wsdl = false) + { + parent::__construct(); + // turn on debugging? + global $debug; + global $HTTP_SERVER_VARS; + + if (isset($_SERVER)) { + $this->debug("_SERVER is defined:"); + $this->appendDebug($this->varDump($_SERVER)); + } elseif (isset($HTTP_SERVER_VARS)) { + $this->debug("HTTP_SERVER_VARS is defined:"); + $this->appendDebug($this->varDump($HTTP_SERVER_VARS)); + } else { + $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined."); + } + + if (isset($debug)) { + $this->debug("In nusoap_server, set debug_flag=$debug based on global flag"); + $this->debug_flag = $debug; + } elseif (isset($_SERVER['QUERY_STRING'])) { + $qs = explode('&', $_SERVER['QUERY_STRING']); + foreach ($qs as $v) { + if (substr($v, 0, 6) == 'debug=') { + $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1"); + $this->debug_flag = substr($v, 6); + } + } + } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { + $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); + foreach ($qs as $v) { + if (substr($v, 0, 6) == 'debug=') { + $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2"); + $this->debug_flag = substr($v, 6); + } + } + } + + // wsdl + if ($wsdl) { + $this->debug("In nusoap_server, WSDL is specified"); + if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) { + $this->wsdl = $wsdl; + $this->externalWSDLURL = $this->wsdl->wsdl; + $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL); + } else { + $this->debug('Create wsdl from ' . $wsdl); + $this->wsdl = new wsdl($wsdl); + $this->externalWSDLURL = $wsdl; + } + $this->appendDebug($this->wsdl->getDebug()); + $this->wsdl->clearDebug(); + if ($err = $this->wsdl->getError()) { + die('WSDL ERROR: ' . $err); + } + } + } + + /** + * processes request and returns response + * + * @param string $data usually is the value of $HTTP_RAW_POST_DATA + * @access public + */ + function service($data) + { + global $HTTP_SERVER_VARS; + + if (isset($_SERVER['REQUEST_METHOD'])) { + $rm = $_SERVER['REQUEST_METHOD']; + } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) { + $rm = $HTTP_SERVER_VARS['REQUEST_METHOD']; + } else { + $rm = ''; + } + + if (isset($_SERVER['QUERY_STRING'])) { + $qs = $_SERVER['QUERY_STRING']; + } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { + $qs = $HTTP_SERVER_VARS['QUERY_STRING']; + } else { + $qs = ''; + } + $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data)); + + if ($rm == 'POST') { + $this->debug("In service, invoke the request"); + $this->parse_request($data); + if (!$this->fault) { + $this->invoke_method(); + } + if (!$this->fault) { + $this->serialize_return(); + } + $this->send_response(); + } elseif (preg_match('/wsdl/', $qs)) { + $this->debug("In service, this is a request for WSDL"); + if ($this->externalWSDLURL) { + if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL + $this->debug("In service, re-direct for WSDL"); + header('Location: ' . $this->externalWSDLURL); + } else { // assume file + $this->debug("In service, use file passthru for WSDL"); + header("Content-Type: text/xml\r\n"); + $fp = fopen($this->externalWSDLURL, 'r'); + fpassthru($fp); + } + } elseif ($this->wsdl) { + $this->debug("In service, serialize WSDL"); + header("Content-Type: text/xml; charset=ISO-8859-1\r\n"); + print $this->wsdl->serialize($this->debug_flag); + if ($this->debug_flag) { + $this->debug('wsdl:'); + $this->appendDebug($this->varDump($this->wsdl)); + print $this->getDebugAsXMLComment(); + } + } else { + $this->debug("In service, there is no WSDL"); + header("Content-Type: text/html; charset=ISO-8859-1\r\n"); + print "This service does not provide WSDL"; + } + } elseif ($this->wsdl) { + $this->debug("In service, return Web description"); + print $this->wsdl->webDescription(); + } else { + $this->debug("In service, no Web description"); + header("Content-Type: text/html; charset=ISO-8859-1\r\n"); + print "This service does not provide a Web description"; + } + } + + /** + * parses HTTP request headers. + * + * The following fields are set by this function (when successful) + * + * headers + * request + * xml_encoding + * SOAPAction + * + * @access private + */ + function parse_http_headers() + { + global $HTTP_SERVER_VARS; + + $this->request = ''; + $this->SOAPAction = ''; + if (function_exists('getallheaders')) { + $this->debug("In parse_http_headers, use getallheaders"); + $headers = getallheaders(); + foreach ($headers as $k => $v) { + $k = strtolower($k); + $this->headers[$k] = $v; + $this->request .= "$k: $v\r\n"; + $this->debug("$k: $v"); + } + // get SOAPAction header + if (isset($this->headers['soapaction'])) { + $this->SOAPAction = str_replace('"', '', $this->headers['soapaction']); + } + // get the character encoding of the incoming request + if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) { + $enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1)); + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; + } + } else { + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 + $this->xml_encoding = 'ISO-8859-1'; + } + } elseif (isset($_SERVER) && is_array($_SERVER)) { + $this->debug("In parse_http_headers, use _SERVER"); + foreach ($_SERVER as $k => $v) { + if (substr($k, 0, 5) == 'HTTP_') { + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); + } else { + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); + } + if ($k == 'soapaction') { + // get SOAPAction header + $k = 'SOAPAction'; + $v = str_replace('"', '', $v); + $v = str_replace('\\', '', $v); + $this->SOAPAction = $v; + } elseif ($k == 'content-type') { + // get the character encoding of the incoming request + if (strpos($v, '=')) { + $enc = substr(strstr($v, '='), 1); + $enc = str_replace('"', '', $enc); + $enc = str_replace('\\', '', $enc); + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; + } + } else { + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 + $this->xml_encoding = 'ISO-8859-1'; + } + } + $this->headers[$k] = $v; + if (is_array($v)) { + $this->request .= "$k: " . json_encode($v) . "\r\n"; + $this->debug("$k: " . json_encode($v)); + } else { + $this->request .= "$k: $v\r\n"; + $this->debug("$k: $v"); + } + } + } elseif (is_array($HTTP_SERVER_VARS)) { + $this->debug("In parse_http_headers, use HTTP_SERVER_VARS"); + foreach ($HTTP_SERVER_VARS as $k => $v) { + if (substr($k, 0, 5) == 'HTTP_') { + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); + $k = strtolower(substr($k, 5)); + } else { + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); + $k = strtolower($k); + } + if ($k == 'soapaction') { + // get SOAPAction header + $k = 'SOAPAction'; + $v = str_replace('"', '', $v); + $v = str_replace('\\', '', $v); + $this->SOAPAction = $v; + } elseif ($k == 'content-type') { + // get the character encoding of the incoming request + if (strpos($v, '=')) { + $enc = substr(strstr($v, '='), 1); + $enc = str_replace('"', '', $enc); + $enc = str_replace('\\', '', $enc); + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; + } + } else { + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 + $this->xml_encoding = 'ISO-8859-1'; + } + } + $this->headers[$k] = $v; + $this->request .= "$k: $v\r\n"; + $this->debug("$k: $v"); + } + } else { + $this->debug("In parse_http_headers, HTTP headers not accessible"); + $this->setError("HTTP headers not accessible"); + } + } + + /** + * parses a request + * + * The following fields are set by this function (when successful) + * + * headers + * request + * xml_encoding + * SOAPAction + * request + * requestSOAP + * methodURI + * methodname + * methodparams + * requestHeaders + * document + * + * This sets the fault field on error + * + * @param string $data XML string + * @access private + */ + function parse_request($data = '') + { + $this->debug('entering parse_request()'); + $this->parse_http_headers(); + $this->debug('got character encoding: ' . $this->xml_encoding); + // uncompress if necessary + if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') { + $this->debug('got content encoding: ' . $this->headers['content-encoding']); + if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') { + // if decoding works, use it. else assume data wasn't gzencoded + if (function_exists('gzuncompress')) { + if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { + $data = $degzdata; + } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) { + $data = $degzdata; + } else { + $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data'); + return; + } + } else { + $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data'); + return; + } + } + } + $this->request .= "\r\n" . $data; + $data = $this->parseRequest($this->headers, $data); + $this->requestSOAP = $data; + $this->debug('leaving parse_request'); + } + + /** + * invokes a PHP function for the requested SOAP method + * + * The following fields are set by this function (when successful) + * + * methodreturn + * + * Note that the PHP function that is called may also set the following + * fields to affect the response sent to the client + * + * responseHeaders + * outgoing_headers + * + * This sets the fault field on error + * + * @access private + */ + function invoke_method() + { + $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction); + + // + // if you are debugging in this area of the code, your service uses a class to implement methods, + // you use SOAP RPC, and the client is .NET, please be aware of the following... + // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the + // method name. that is fine for naming the .NET methods. it is not fine for properly constructing + // the XML request and reading the XML response. you need to add the RequestElementName and + // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe + // generates for the method. these parameters are used to specify the correct XML element names + // for .NET to use, i.e. the names with the '.' in them. + // + $orig_methodname = $this->methodname; + if ($this->wsdl) { + if ($this->opData = $this->wsdl->getOperationData($this->methodname)) { + $this->debug('in invoke_method, found WSDL operation=' . $this->methodname); + $this->appendDebug('opData=' . $this->varDump($this->opData)); + } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) { + // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element + $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']); + $this->appendDebug('opData=' . $this->varDump($this->opData)); + $this->methodname = $this->opData['name']; + } else { + $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname); + $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service"); + return; + } + } else { + $this->debug('in invoke_method, no WSDL to validate method'); + } + + // if a . is present in $this->methodname, we see if there is a class in scope, + // which could be referred to. We will also distinguish between two deliminators, + // to allow methods to be called a the class or an instance + if (strpos($this->methodname, '..') > 0) { + $delim = '..'; + } elseif (strpos($this->methodname, '.') > 0) { + $delim = '.'; + } else { + $delim = ''; + } + $this->debug("in invoke_method, delim=$delim"); + + $class = ''; + $method = ''; + $try_class = ''; + if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) { + $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim)); + if (class_exists($try_class)) { + // get the class and method name + $class = $try_class; + $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim)); + $this->debug("in invoke_method, class=$class method=$method delim=$delim"); + } else { + $this->debug("in invoke_method, class=$try_class not found"); + } + } elseif (strlen($delim) > 0 && substr_count($this->methodname, $delim) > 1) { + $split = explode($delim, $this->methodname); + $method = array_pop($split); + $class = implode('\\', $split); + } else { + $this->debug("in invoke_method, no class to try"); + } + + // does method exist? + if ($class == '') { + if (!function_exists($this->methodname)) { + $this->debug("in invoke_method, function '$this->methodname' not found!"); + $this->result = 'fault: method not found'; + $this->fault('SOAP-ENV:Client', "method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')"); + return; + } + } else { + $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method; + if (!in_array($method_to_compare, get_class_methods($class))) { + $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!"); + $this->result = 'fault: method not found'; + $this->fault('SOAP-ENV:Client', "method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')"); + return; + } + } + + // evaluate message, getting back parameters + // verify that request parameters match the method's signature + if (!$this->verify_method($this->methodname, $this->methodparams)) { + // debug + $this->debug('ERROR: request not verified against method signature'); + $this->result = 'fault: request failed validation against method signature'; + // return fault + $this->fault('SOAP-ENV:Client', "Operation '$this->methodname' not defined in service."); + return; + } + + // if there are parameters to pass + $this->debug('in invoke_method, params:'); + $this->appendDebug($this->varDump($this->methodparams)); + $this->debug("in invoke_method, calling '$this->methodname'"); + if (!function_exists('call_user_func_array')) { + if ($class == '') { + $this->debug('in invoke_method, calling function using eval()'); + $funcCall = "\$this->methodreturn = $this->methodname("; + } else { + if ($delim == '..') { + $this->debug('in invoke_method, calling class method using eval()'); + $funcCall = "\$this->methodreturn = " . $class . "::" . $method . "("; + } else { + $this->debug('in invoke_method, calling instance method using eval()'); + // generate unique instance name + $instname = "\$inst_" . time(); + $funcCall = $instname . " = new " . $class . "(); "; + $funcCall .= "\$this->methodreturn = " . $instname . "->" . $method . "("; + } + } + if ($this->methodparams) { + foreach ($this->methodparams as $param) { + if (is_array($param) || is_object($param)) { + $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available'); + return; + } + $funcCall .= "\"$param\","; + } + $funcCall = substr($funcCall, 0, -1); + } + $funcCall .= ');'; + $this->debug('in invoke_method, function call: ' . $funcCall); + @eval($funcCall); + } else { + if ($class == '') { + $this->debug('in invoke_method, calling function using call_user_func_array()'); + $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() + } elseif ($delim == '..') { + $this->debug('in invoke_method, calling class method using call_user_func_array()'); + $call_arg = array($class, $method); + } else { + $this->debug('in invoke_method, calling instance method using call_user_func_array()'); + $instance = new $class (); + $call_arg = array(&$instance, $method); + } + if (is_array($this->methodparams)) { + $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams)); + } else { + $this->methodreturn = call_user_func_array($call_arg, array()); + } + } + $this->debug('in invoke_method, methodreturn:'); + $this->appendDebug($this->varDump($this->methodreturn)); + $this->debug("in invoke_method, called method $this->methodname, received data of type " . gettype($this->methodreturn)); + } + + /** + * serializes the return value from a PHP function into a full SOAP Envelope + * + * The following fields are set by this function (when successful) + * + * responseSOAP + * + * This sets the fault field on error + * + * @access private + */ + function serialize_return() + { + $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); + // if fault + if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) { + $this->debug('got a fault object from method'); + $this->fault = $this->methodreturn; + return; + } elseif ($this->methodreturnisliteralxml) { + $return_val = $this->methodreturn; + // returned value(s) + } else { + $this->debug('got a(n) ' . gettype($this->methodreturn) . ' from method'); + $this->debug('serializing return value'); + if ($this->wsdl) { + if (sizeof($this->opData['output']['parts']) > 1) { + $this->debug('more than one output part, so use the method return unchanged'); + $opParams = $this->methodreturn; + } elseif (sizeof($this->opData['output']['parts']) == 1) { + $this->debug('exactly one output part, so wrap the method return in a simple array'); + // TODO: verify that it is not already wrapped! + //foreach ($this->opData['output']['parts'] as $name => $type) { + // $this->debug('wrap in element named ' . $name); + //} + $opParams = array($this->methodreturn); + } + $opParams = isset($opParams) ? $opParams : []; + $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams); + $this->appendDebug($this->wsdl->getDebug()); + $this->wsdl->clearDebug(); + if ($errstr = $this->wsdl->getError()) { + $this->debug('got wsdl error: ' . $errstr); + $this->fault('SOAP-ENV:Server', 'unable to serialize result'); + return; + } + } else { + if (isset($this->methodreturn)) { + $return_val = $this->serialize_val($this->methodreturn, 'return'); + } else { + $return_val = ''; + $this->debug('in absence of WSDL, assume void return for backward compatibility'); + } + } + } + $this->debug('return value:'); + $this->appendDebug($this->varDump($return_val)); + + $this->debug('serializing response'); + if ($this->wsdl) { + $this->debug('have WSDL for serialization: style is ' . $this->opData['style']); + if ($this->opData['style'] == 'rpc') { + $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']); + if ($this->opData['output']['use'] == 'literal') { + // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace + if ($this->methodURI) { + $payload = 'responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'responseTagName . ">"; + } else { + $payload = '<' . $this->responseTagName . '>' . $return_val . 'responseTagName . 'Response>'; + } + } else { + if ($this->methodURI) { + $payload = 'responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'responseTagName . ">"; + } else { + $payload = '<' . $this->responseTagName . '>' . $return_val . 'responseTagName . '>'; + } + } + } else { + $this->debug('style is not rpc for serialization: assume document'); + $payload = $return_val; + } + } else { + $this->debug('do not have WSDL for serialization: assume rpc/encoded'); + $payload = 'responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'responseTagName . ">"; + } + $this->result = 'successful'; + if ($this->wsdl) { + //if($this->debug_flag){ + $this->appendDebug($this->wsdl->getDebug()); + // } + if (isset($this->opData['output']['encodingStyle'])) { + $encodingStyle = $this->opData['output']['encodingStyle']; + } else { + $encodingStyle = ''; + } + // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces. + $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle); + } else { + $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders); + } + $this->debug("Leaving serialize_return"); + } + + /** + * sends an HTTP response + * + * The following fields are set by this function (when successful) + * + * outgoing_headers + * response + * + * @access private + */ + function send_response() + { + $this->debug('Enter send_response'); + if ($this->fault) { + $payload = $this->fault->serialize(); + $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error"; + $this->outgoing_headers[] = "Status: 500 Internal Server Error"; + } else { + $payload = $this->responseSOAP; + // Some combinations of PHP+Web server allow the Status + // to come through as a header. Since OK is the default + // just do nothing. + // $this->outgoing_headers[] = "HTTP/1.0 200 OK"; + // $this->outgoing_headers[] = "Status: 200 OK"; + } + // add debug data if in debug mode + if (isset($this->debug_flag) && $this->debug_flag) { + $payload .= $this->getDebugAsXMLComment(); + } + $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; + $rev = array(); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); + $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . (isset($rev[1]) ? $rev[1] : '') . ")"; + // Let the Web server decide about this + //$this->outgoing_headers[] = "Connection: Close\r\n"; + $payload = $this->getHTTPBody($payload); + $type = $this->getHTTPContentType(); + $charset = $this->getHTTPContentTypeCharset(); + $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : ''); + //begin code to compress payload - by John + // NOTE: there is no way to know whether the Web server will also compress + // this data. + if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) { + if (strstr($this->headers['accept-encoding'], 'gzip')) { + if (function_exists('gzencode')) { + if (isset($this->debug_flag) && $this->debug_flag) { + $payload .= ""; + } + $this->outgoing_headers[] = "Content-Encoding: gzip"; + $payload = gzencode($payload); + } else { + if (isset($this->debug_flag) && $this->debug_flag) { + $payload .= ""; + } + } + } elseif (strstr($this->headers['accept-encoding'], 'deflate')) { + // Note: MSIE requires gzdeflate output (no Zlib header and checksum), + // instead of gzcompress output, + // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5) + if (function_exists('gzdeflate')) { + if (isset($this->debug_flag) && $this->debug_flag) { + $payload .= ""; + } + $this->outgoing_headers[] = "Content-Encoding: deflate"; + $payload = gzdeflate($payload); + } else { + if (isset($this->debug_flag) && $this->debug_flag) { + $payload .= ""; + } + } + } + } + //end code + $this->outgoing_headers[] = "Content-Length: " . strlen($payload); + reset($this->outgoing_headers); + foreach ($this->outgoing_headers as $hdr) { + header($hdr, false); + } + print $payload; + $this->response = join("\r\n", $this->outgoing_headers) . "\r\n\r\n" . $payload; + } + + /** + * takes the value that was created by parsing the request + * and compares to the method's signature, if available. + * + * @param string $operation The operation to be invoked + * @param array $request The array of parameter values + * @return boolean Whether the operation was found + * @access private + */ + function verify_method($operation, $request) + { + if (isset($this->wsdl) && is_object($this->wsdl)) { + if ($this->wsdl->getOperationData($operation)) { + return true; + } + } elseif (isset($this->operations[$operation])) { + return true; + } + return false; + } + + /** + * processes SOAP message received from client + * + * @param array $headers The HTTP headers + * @param string $data unprocessed request data from client + * @return false|void void or false on error + * @access private + */ + function parseRequest($headers, $data) + { + $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:'); + $this->appendDebug($this->varDump($headers)); + if (!isset($headers['content-type'])) { + $this->setError('Request not of type '.$this->contentType.' (no content-type header)'); + return false; + } + if (!strstr($headers['content-type'], $this->contentType)) { + $this->setError('Request not of type '.$this->contentType.': ' . $headers['content-type']); + return false; + } + if (strpos($headers['content-type'], '=')) { + $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); + $this->debug('Got response encoding: ' . $enc); + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; + } + } else { + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 + $this->xml_encoding = 'ISO-8859-1'; + } + $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser'); + // parse response, get soap parser obj + $parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8); + // parser debug + $this->debug("parser debug: \n" . $parser->getDebug()); + // if fault occurred during message parsing + if ($err = $parser->getError()) { + $this->result = 'fault: error in msg parsing: ' . $err; + $this->fault('SOAP-ENV:Client', "error in msg parsing:\n" . $err); + // else successfully parsed request into soapval object + } else { + // get/set methodname + $this->methodURI = $parser->root_struct_namespace; + $this->methodname = $parser->root_struct_name; + $this->debug('methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); + + // get/set custom response tag name + $outputMessage = $this->wsdl->getOperationData($this->methodname)['output']['message']; + $this->responseTagName = $outputMessage; + $this->debug('responseTagName: ' . $this->responseTagName . ' methodURI: ' . $this->methodURI); + + $this->debug('calling parser->get_soapbody()'); + $this->methodparams = $parser->get_soapbody(); + // get SOAP headers + $this->requestHeaders = $parser->getHeaders(); + // get SOAP Header + $this->requestHeader = $parser->get_soapheader(); + // add document for doclit support + $this->document = $parser->document; + } + } + + /** + * gets the HTTP body for the current response. + * + * @param string $soapmsg The SOAP payload + * @return string The HTTP body, which includes the SOAP payload + * @access private + */ + function getHTTPBody($soapmsg) + { + return $soapmsg; + } + + /** + * gets the HTTP content type for the current response. + * + * Note: getHTTPBody must be called before this. + * + * @return string the HTTP content type for the current response. + * @access private + */ + function getHTTPContentType() + { + return 'text/xml'; + } + + /** + * gets the HTTP content type charset for the current response. + * returns false for non-text content types. + * + * Note: getHTTPBody must be called before this. + * + * @return string the HTTP content type charset for the current response. + * @access private + */ + function getHTTPContentTypeCharset() + { + return $this->soap_defencoding; + } + + /** + * add a method to the dispatch map (this has been replaced by the register method) + * + * @param string $methodname + * @param string $in array of input values + * @param string $out array of output values + * @access public + * @deprecated + */ + function add_to_map($methodname, $in, $out) + { + $this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out); + } + + /** + * register a service function with the server + * + * @param string $name the name of the PHP function, class.method or class..method + * @param array $in assoc array of input values: key = param name, value = param type + * @param array $out assoc array of output values: key = param name, value = param type + * @param mixed $namespace the element namespace for the method or false + * @param mixed $soapaction the soapaction for the method or false + * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically + * @param mixed $use optional (encoded|literal) or false + * @param string $documentation optional Description to include in WSDL + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) + * @param string $customResponseTagName optional Name of the outgoing response, default $name . 'Response' + * @access public + */ + function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '', $customResponseTagName = '') + { + global $HTTP_SERVER_VARS; + + if ($this->externalWSDLURL) { + die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.'); + } + if (!$name) { + die('You must specify a name when you register an operation'); + } + if (!is_array($in)) { + die('You must provide an array for operation inputs'); + } + if (!is_array($out)) { + die('You must provide an array for operation outputs'); + } + if (!$soapaction) { + if (isset($_SERVER)) { + $SERVER_NAME = $_SERVER['SERVER_NAME']; + $SCRIPT_NAME = $_SERVER['SCRIPT_NAME']; + $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); + } elseif (isset($HTTP_SERVER_VARS)) { + $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; + $SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME']; + $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; + } else { + $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $HTTPS = ''; + $SERVER_NAME = ''; + $SCRIPT_NAME = ''; + } + if ($HTTPS == '1' || $HTTPS == 'on') { + $SCHEME = 'https'; + } else { + $SCHEME = 'http'; + } + $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; + } + if (!$style) { + $style = "rpc"; + } + if (!$use) { + $use = "encoded"; + } + if ($use == 'encoded' && $encodingStyle == '') { + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; + } + if (!$customResponseTagName) { + $customResponseTagName = $name . 'Response'; + } + + $this->operations[$name] = array( + 'name' => $name, + 'in' => $in, + 'out' => $out, + 'namespace' => $namespace, + 'soapaction' => $soapaction, + 'style' => $style, + 'outputMessage' => $customResponseTagName, + ); + if ($this->wsdl) { + $this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle, $customResponseTagName); + } + return true; + } + + /** + * Specify a fault to be returned to the client. + * This also acts as a flag to the server that a fault has occured. + * + * @param string $faultcode + * @param string $faultstring + * @param string $faultactor + * @param string $faultdetail + * @access public + */ + function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') + { + if ($faultdetail == '' && $this->debug_flag) { + $faultdetail = $this->getDebug(); + } + $this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail); + $this->fault->soap_defencoding = $this->soap_defencoding; + } + + /** + * Sets up wsdl object. + * Acts as a flag to enable internal WSDL generation + * + * @param string $serviceName , name of the service + * @param mixed $namespace optional 'tns' service namespace or false + * @param mixed $endpoint optional URL of service endpoint or false + * @param string $style optional (rpc|document) WSDL style (also specified by operation) + * @param string $transport optional SOAP transport + * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false + */ + function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) + { + global $HTTP_SERVER_VARS; + + if (isset($_SERVER)) { + $SERVER_NAME = $_SERVER['SERVER_NAME']; + $SERVER_PORT = $_SERVER['SERVER_PORT']; + $SCRIPT_NAME = $_SERVER['SCRIPT_NAME']; + $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); + } elseif (isset($HTTP_SERVER_VARS)) { + $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; + $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT']; + $SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME']; + $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; + } else { + $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $SERVER_PORT = ''; + $SERVER_NAME = ''; + $SCRIPT_NAME = ''; + $HTTPS = ''; + } + // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) + $colon = strpos($SERVER_NAME, ":"); + if ($colon) { + $SERVER_NAME = substr($SERVER_NAME, 0, $colon); + } + if ($SERVER_PORT == 80) { + $SERVER_PORT = ''; + } else { + $SERVER_PORT = ':' . $SERVER_PORT; + } + if (!$namespace) { $namespace = "http://$SERVER_NAME/soap/$serviceName"; } - if(false == $endpoint) { - if ($HTTPS == '1' || $HTTPS == 'on') { - $SCHEME = 'https'; - } else { - $SCHEME = 'http'; - } + if (!$endpoint) { + if ($HTTPS == '1' || $HTTPS == 'on') { + $SCHEME = 'https'; + } else { + $SCHEME = 'http'; + } $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME"; } - if(false == $schemaTargetNamespace) { + if (!$schemaTargetNamespace) { $schemaTargetNamespace = $namespace; } - $this->wsdl = new wsdl; - $this->wsdl->serviceName = $serviceName; + $this->wsdl = new wsdl; + $this->wsdl->serviceName = $serviceName; $this->wsdl->endpoint = $endpoint; - $this->wsdl->namespaces['tns'] = $namespace; - $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/'; - $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/'; - if ($schemaTargetNamespace != $namespace) { - $this->wsdl->namespaces['types'] = $schemaTargetNamespace; - } + $this->wsdl->namespaces['tns'] = $namespace; + $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/'; + $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/'; + if ($schemaTargetNamespace != $namespace) { + $this->wsdl->namespaces['types'] = $schemaTargetNamespace; + } $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces); if ($style == 'document') { - $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; + $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; } $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace; $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true); $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true); - $this->wsdl->bindings[$serviceName.'Binding'] = array( - 'name'=>$serviceName.'Binding', - 'style'=>$style, - 'transport'=>$transport, - 'portType'=>$serviceName.'PortType'); - $this->wsdl->ports[$serviceName.'Port'] = array( - 'binding'=>$serviceName.'Binding', - 'location'=>$endpoint, - 'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/'); + $this->wsdl->bindings[$serviceName . 'Binding'] = array( + 'name' => $serviceName . 'Binding', + 'style' => $style, + 'transport' => $transport, + 'portType' => $serviceName . 'PortType'); + $this->wsdl->ports[$serviceName . 'Port'] = array( + 'binding' => $serviceName . 'Binding', + 'location' => $endpoint, + 'bindingType' => 'http://schemas.xmlsoap.org/wsdl/soap/'); } } /** * Backward compatibility */ -class soap_server extends nusoap_server { +class soap_server extends nusoap_server +{ } -?> -* @author Scott Nichol -* @access public -*/ -class wsdl extends nusoap_base { - // URL or filename of the root of this WSDL + * parses a WSDL file, allows access to it's data, other utility methods. + * also builds WSDL structures programmatically. + * + * @author Dietrich Ayala + * @author Scott Nichol + * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ + * @access public + */ +class wsdl extends nusoap_base +{ + // URL or filename of the root of this WSDL var $wsdl; // define internal arrays of bindings, ports, operations, messages, etc. var $schemas = array(); @@ -4618,151 +4767,162 @@ class wsdl extends nusoap_base { var $position = 0; var $depth = 0; var $depth_array = array(); - // for getting wsdl - var $proxyhost = ''; + // for getting wsdl + var $proxyhost = ''; var $proxyport = ''; - var $proxyusername = ''; - var $proxypassword = ''; - var $timeout = 0; - var $response_timeout = 30; - var $curl_options = array(); // User-specified cURL options - var $use_curl = false; // whether to always try to use cURL - // for HTTP authentication - var $username = ''; // Username for HTTP authentication - var $password = ''; // Password for HTTP authentication - var $authtype = ''; // Type of HTTP authentication - var $certRequest = array(); // Certificate for HTTP SSL authentication + var $proxyusername = ''; + var $proxypassword = ''; + var $timeout = 0; + var $response_timeout = 30; + var $curl_options = array(); // User-specified cURL options + var $use_curl = false; // whether to always try to use cURL + // for HTTP authentication + var $username = ''; // Username for HTTP authentication + var $password = ''; // Password for HTTP authentication + var $authtype = ''; // Type of HTTP authentication + var $certRequest = array(); // Certificate for HTTP SSL authentication + + /** @var mixed */ + var $currentPortOperation; + /** @var string */ + var $opStatus; + /** @var mixed */ + var $serviceName; + var $wsdl_info; /** * constructor * * @param string $wsdl WSDL document URL - * @param string $proxyhost - * @param string $proxyport - * @param string $proxyusername - * @param string $proxypassword - * @param integer $timeout set the connection timeout - * @param integer $response_timeout set the response timeout - * @param array $curl_options user-specified cURL options - * @param boolean $use_curl try to use cURL + * @param string $proxyhost + * @param string $proxyport + * @param string $proxyusername + * @param string $proxypassword + * @param integer $timeout set the connection timeout + * @param integer $response_timeout set the response timeout + * @param array $curl_options user-specified cURL options + * @param boolean $use_curl try to use cURL * @access public */ - function __construct($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ - parent::__construct(); - $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); + function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) + { + parent::__construct(); + $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); $this->proxyhost = $proxyhost; $this->proxyport = $proxyport; - $this->proxyusername = $proxyusername; - $this->proxypassword = $proxypassword; - $this->timeout = $timeout; - $this->response_timeout = $response_timeout; - if (is_array($curl_options)) - $this->curl_options = $curl_options; - $this->use_curl = $use_curl; - $this->fetchWSDL($wsdl); + $this->proxyusername = $proxyusername; + $this->proxypassword = $proxypassword; + $this->timeout = $timeout; + $this->response_timeout = $response_timeout; + if (is_array($curl_options)) { + $this->curl_options = $curl_options; + } + $this->use_curl = $use_curl; + $this->fetchWSDL($wsdl); } - /** - * fetches the WSDL document and parses it - * - * @access public - */ - function fetchWSDL($wsdl) { - $this->debug("parse and process WSDL path=$wsdl"); - $this->wsdl = $wsdl; + /** + * fetches the WSDL document and parses it + * + * @access public + */ + function fetchWSDL($wsdl) + { + $this->debug("parse and process WSDL path=$wsdl"); + $this->wsdl = $wsdl; // parse wsdl file if ($this->wsdl != "") { $this->parseWSDL($this->wsdl); } // imports // TODO: handle imports more properly, grabbing them in-line and nesting them - $imported_urls = array(); - $imported = 1; - while ($imported > 0) { - $imported = 0; - // Schema imports - foreach ($this->schemas as $ns => $list) { - foreach ($list as $xs) { - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! - foreach ($xs->imports as $ns2 => $list2) { - for ($ii = 0; $ii < count($list2); $ii++) { - if (! $list2[$ii]['loaded']) { - $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true; - $url = $list2[$ii]['location']; - if ($url != '') { - $urlparts = parse_url($url); - if (!isset($urlparts['host'])) { - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') . - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; - } - if (! in_array($url, $imported_urls)) { - $this->parseWSDL($url); - $imported++; - $imported_urls[] = $url; - } - } else { - $this->debug("Unexpected scenario: empty URL for unloaded import"); - } - } - } - } - } - } - // WSDL imports - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! + $imported_urls = array(); + $imported = 1; + while ($imported > 0) { + $imported = 0; + // Schema imports + foreach ($this->schemas as $ns => $list) { + foreach ($list as $xsKey => $xs) { + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! + foreach ($xs->imports as $ns2 => $list2) { + for ($ii = 0; $ii < count($list2); $ii++) { + if (array_key_exists($ii, $list2) && (!isset($list2[$ii]['loaded']) || !$list2[$ii]['loaded'])) { + @$this->schemas[$ns][$xsKey]->imports[$ns2][$ii]['loaded'] = true; + $url = $list2[$ii]['location']; + if ($url != '') { + $urlparts = parse_url($url); + if (!isset($urlparts['host'])) { + $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . + substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path']; + } + if (!in_array($url, $imported_urls)) { + $this->parseWSDL($url); + $imported++; + $imported_urls[] = $url; + } + } else { + $this->debug("Unexpected scenario: empty URL for unloaded import"); + } + } + } + } + } + } + // WSDL imports + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! foreach ($this->import as $ns => $list) { for ($ii = 0; $ii < count($list); $ii++) { - if (! $list[$ii]['loaded']) { - $this->import[$ns][$ii]['loaded'] = true; - $url = $list[$ii]['location']; - if ($url != '') { - $urlparts = parse_url($url); - if (!isset($urlparts['host'])) { - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; - } - if (! in_array($url, $imported_urls)) { - $this->parseWSDL($url); - $imported++; - $imported_urls[] = $url; - } - } else { - $this->debug("Unexpected scenario: empty URL for unloaded import"); - } - } - } + if (!$list[$ii]['loaded']) { + $this->import[$ns][$ii]['loaded'] = true; + $url = $list[$ii]['location']; + if ($url != '') { + $urlparts = parse_url($url); + if (!isset($urlparts['host'])) { + $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . + substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path']; + } + if (!in_array($url, $imported_urls)) { + $this->parseWSDL($url); + $imported++; + $imported_urls[] = $url; + } + } else { + $this->debug("Unexpected scenario: empty URL for unloaded import"); + } + } + } } - } + } // add new data to operation data - foreach($this->bindings as $binding => $bindingData) { + foreach ($this->bindings as $binding => $bindingData) { if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { - foreach($bindingData['operations'] as $operation => $data) { + foreach ($bindingData['operations'] as $operation => $data) { $this->debug('post-parse data gathering for ' . $operation); $this->bindings[$binding]['operations'][$operation]['input'] = - isset($this->bindings[$binding]['operations'][$operation]['input']) ? - array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : - $this->portTypes[ $bindingData['portType'] ][$operation]['input']; + isset($this->bindings[$binding]['operations'][$operation]['input']) ? + array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : + $this->portTypes[$bindingData['portType']][$operation]['input']; $this->bindings[$binding]['operations'][$operation]['output'] = - isset($this->bindings[$binding]['operations'][$operation]['output']) ? - array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : - $this->portTypes[ $bindingData['portType'] ][$operation]['output']; - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){ - $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; - } - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){ - $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; + isset($this->bindings[$binding]['operations'][$operation]['output']) ? + array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : + $this->portTypes[$bindingData['portType']][$operation]['output']; + if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) { + $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']]; + } + if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) { + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']]; } // Set operation style if necessary, but do not override one already provided - if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) { + if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) { $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; } $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; - $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; + $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : ''; $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; } } } - } + } /** * parses the wsdl document @@ -4770,8 +4930,9 @@ class wsdl extends nusoap_base { * @param string $wsdl path or URL * @access private */ - function parseWSDL($wsdl = '') { - $this->debug("parse WSDL at path=$wsdl"); + function parseWSDL($wsdl = '') + { + $this->debug("parse WSDL at path=$wsdl"); if ($wsdl == '') { $this->debug('no wsdl passed to parseWSDL()!!'); @@ -4784,38 +4945,38 @@ class wsdl extends nusoap_base { if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { $this->debug('getting WSDL http(s) URL ' . $wsdl); - // get wsdl - $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); - $tr->request_method = 'GET'; - $tr->useSOAPAction = false; - if($this->proxyhost && $this->proxyport){ - $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); - } - if ($this->authtype != '') { - $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); - } - $tr->setEncoding('gzip, deflate'); - $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout); - //$this->debug("WSDL request\n" . $tr->outgoing_payload); - //$this->debug("WSDL response\n" . $tr->incoming_payload); - $this->appendDebug($tr->getDebug()); - // catch errors - if($err = $tr->getError() ){ - $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; - $this->debug($errstr); - $this->setError($errstr); - unset($tr); - return false; - } - unset($tr); - $this->debug("got WSDL URL"); + // get wsdl + $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); + $tr->request_method = 'GET'; + $tr->useSOAPAction = false; + if ($this->proxyhost && $this->proxyport) { + $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); + } + if ($this->authtype != '') { + $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); + } + $tr->setEncoding(); + $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout); + //$this->debug("WSDL request\n" . $tr->outgoing_payload); + //$this->debug("WSDL response\n" . $tr->incoming_payload); + $this->appendDebug($tr->getDebug()); + // catch errors + if ($err = $tr->getError()) { + $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err; + $this->debug($errstr); + $this->setError($errstr); + unset($tr); + return false; + } + unset($tr); + $this->debug("got WSDL URL"); } else { // $wsdl is not http(s), so treat it as a file URL or plain file path - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { - $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; - } else { - $path = $wsdl; - } + if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { + $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; + } else { + $path = $wsdl; + } $this->debug('getting WSDL file ' . $path); if ($fp = @fopen($path, 'r')) { $wsdl_string = ''; @@ -4824,8 +4985,8 @@ class wsdl extends nusoap_base { } fclose($fp); } else { - $errstr = "Bad path to WSDL file $path"; - $this->debug($errstr); + $errstr = "Bad path to WSDL file $path"; + $this->debug($errstr); $this->setError($errstr); return false; } @@ -4846,23 +5007,26 @@ class wsdl extends nusoap_base { if (!xml_parse($this->parser, $wsdl_string, true)) { // Display an error message. $errstr = sprintf( - 'XML error parsing WSDL from %s on line %d: %s', - $wsdl, + 'XML error parsing WSDL from %s on line %d: %s', + $wsdl, xml_get_current_line_number($this->parser), xml_error_string(xml_get_error_code($this->parser)) - ); + ); $this->debug($errstr); - $this->debug("XML payload:\n" . $wsdl_string); + $this->debug("XML payload:\n" . $wsdl_string); $this->setError($errstr); + xml_parser_free($this->parser); + unset($this->parser); return false; } - // free the parser + // free the parser xml_parser_free($this->parser); + unset($this->parser); $this->debug('Parsing WSDL done'); - // catch wsdl parse errors - if($this->getError()){ - return false; - } + // catch wsdl parse errors + if ($this->getError()) { + return false; + } return true; } @@ -4871,7 +5035,7 @@ class wsdl extends nusoap_base { * * @param string $parser XML parser object * @param string $name element name - * @param string $attrs associative array of attributes + * @param array $attrs associative array of attributes * @access private */ function start_element($parser, $name, $attrs) @@ -4881,7 +5045,7 @@ class wsdl extends nusoap_base { $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); } elseif (preg_match('/schema$/', $name)) { - $this->debug('Parsing WSDL schema'); + $this->debug('Parsing WSDL schema'); // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); $this->status = 'schema'; $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces); @@ -4897,9 +5061,9 @@ class wsdl extends nusoap_base { $this->message[$pos] = array('cdata' => ''); // process attributes if (count($attrs) > 0) { - // register namespace declarations - foreach($attrs as $k => $v) { - if (preg_match('/^xmlns/',$k)) { + // register namespace declarations + foreach ($attrs as $k => $v) { + if (preg_match('/^xmlns/', $k)) { if ($ns_prefix = substr(strrchr($k, ':'), 1)) { $this->namespaces[$ns_prefix] = $v; } else { @@ -4912,7 +5076,8 @@ class wsdl extends nusoap_base { } } // expand each attribute prefix to its namespace - foreach($attrs as $k => $v) { + $eAttrs = array (); + foreach ($attrs as $k => $v) { $k = strpos($k, ':') ? $this->expandQname($k) : $k; if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { $v = strpos($v, ':') ? $this->expandQname($v) : $v; @@ -4923,6 +5088,10 @@ class wsdl extends nusoap_base { } else { $attrs = array(); } + // Set default prefix and namespace + // to prevent error Undefined variable $prefix and $namespace if (preg_match('/:/', $name)) return 0 or FALSE + $prefix = ''; + $namespace = ''; // get element prefix, namespace and name if (preg_match('/:/', $name)) { // get ns prefix @@ -4932,418 +5101,427 @@ class wsdl extends nusoap_base { // get unqualified name $name = substr(strstr($name, ':'), 1); } - // process attributes, expanding any prefixes to namespaces + // process attributes, expanding any prefixes to namespaces // find status, register data switch ($this->status) { case 'message': if ($name == 'part') { - if (isset($attrs['type'])) { - $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; - } - if (isset($attrs['element'])) { - $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; - } - } - break; - case 'portType': - switch ($name) { - case 'operation': - $this->currentPortOperation = $attrs['name']; - $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); - if (isset($attrs['parameterOrder'])) { - $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; - } - break; - case 'documentation': - $this->documentation = true; - break; - // merge input/output data - default: - $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; - $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; - break; - } - break; - case 'binding': - switch ($name) { - case 'binding': - // get ns prefix - if (isset($attrs['style'])) { - $this->bindings[$this->currentBinding]['prefix'] = $prefix; - } - $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); - break; - case 'header': - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; - break; - case 'operation': - if (isset($attrs['soapAction'])) { - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; - } - if (isset($attrs['style'])) { - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; - } - if (isset($attrs['name'])) { - $this->currentOperation = $attrs['name']; - $this->debug("current binding operation: $this->currentOperation"); - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; - } - break; - case 'input': - $this->opStatus = 'input'; - break; - case 'output': - $this->opStatus = 'output'; - break; - case 'body': - if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) { - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); - } else { - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; - } - break; - } - break; - case 'service': - switch ($name) { - case 'port': - $this->currentPort = $attrs['name']; - $this->debug('current port: ' . $this->currentPort); - $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); + if (isset($attrs['type'])) { + $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; + } + if (isset($attrs['element'])) { + $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; + } + } + break; + case 'portType': + switch ($name) { + case 'operation': + $this->currentPortOperation = $attrs['name']; + $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); + if (isset($attrs['parameterOrder'])) { + $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; + } + break; + case 'documentation': + $this->documentation = true; + break; + // merge input/output data + default: + $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; + $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; + break; + } + break; + case 'binding': + switch ($name) { + case 'binding': + // get ns prefix + if (isset($attrs['style'])) { + $this->bindings[$this->currentBinding]['prefix'] = $prefix; + } + $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); + break; + case 'header': + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; + break; + case 'operation': + if (isset($attrs['soapAction'])) { + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; + } + if (isset($attrs['style'])) { + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; + } + if (isset($attrs['name'])) { + $this->currentOperation = $attrs['name']; + $this->debug("current binding operation: $this->currentOperation"); + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; + } + break; + case 'input': + $this->opStatus = 'input'; + break; + case 'output': + $this->opStatus = 'output'; + break; + case 'body': + if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) { + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); + } else { + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; + } + break; + } + break; + case 'service': + switch ($name) { + case 'port': + $this->currentPort = $attrs['name']; + $this->debug('current port: ' . $this->currentPort); + $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); - break; - case 'address': - $this->ports[$this->currentPort]['location'] = $attrs['location']; - $this->ports[$this->currentPort]['bindingType'] = $namespace; - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; - break; - } - break; - } - // set status - switch ($name) { - case 'import': - if (isset($attrs['location'])) { - $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); - $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')'); - } else { - $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); - if (! $this->getPrefixFromNamespace($attrs['namespace'])) { - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; - } - $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')'); - } - break; - //wait for schema - //case 'types': - // $this->status = 'schema'; - // break; - case 'message': - $this->status = 'message'; - $this->messages[$attrs['name']] = array(); - $this->currentMessage = $attrs['name']; - break; - case 'portType': - $this->status = 'portType'; - $this->portTypes[$attrs['name']] = array(); - $this->currentPortType = $attrs['name']; - break; - case "binding": - if (isset($attrs['name'])) { - // get binding name - if (strpos($attrs['name'], ':')) { - $this->currentBinding = $this->getLocalPart($attrs['name']); - } else { - $this->currentBinding = $attrs['name']; - } - $this->status = 'binding'; - $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); - $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']); - } - break; - case 'service': - $this->serviceName = $attrs['name']; - $this->status = 'service'; - $this->debug('current service: ' . $this->serviceName); - break; - case 'definitions': - foreach ($attrs as $name => $value) { - $this->wsdl_info[$name] = $value; - } - break; - } - } - } - - /** - * end-element handler - * - * @param string $parser XML parser object - * @param string $name element name - * @access private - */ - function end_element($parser, $name){ - // unset schema status - if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { - $this->status = ""; - $this->appendDebug($this->currentSchema->getDebug()); - $this->currentSchema->clearDebug(); - $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; - $this->debug('Parsing WSDL schema done'); - } - if ($this->status == 'schema') { - $this->currentSchema->schemaEndElement($parser, $name); - } else { - // bring depth down a notch - $this->depth--; - } - // end documentation - if ($this->documentation) { - //TODO: track the node to which documentation should be assigned; it can be a part, message, etc. - //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; - $this->documentation = false; - } - } - - /** - * element content handler - * - * @param string $parser XML parser object - * @param string $data element content - * @access private - */ - function character_data($parser, $data) - { - $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; - if (isset($this->message[$pos]['cdata'])) { - $this->message[$pos]['cdata'] .= $data; - } - if ($this->documentation) { - $this->documentation .= $data; - } - } - - /** - * if authenticating, set user credentials here - * - * @param string $username - * @param string $password - * @param string $authtype (basic|digest|certificate|ntlm) - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) - * @access public - */ - function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { - $this->debug("setCredentials username=$username authtype=$authtype certRequest="); - $this->appendDebug($this->varDump($certRequest)); - $this->username = $username; - $this->password = $password; - $this->authtype = $authtype; - $this->certRequest = $certRequest; - } - - function getBindingData($binding) - { - if (is_array($this->bindings[$binding])) { - return $this->bindings[$binding]; - } - } - - /** - * returns an assoc array of operation names => operation data - * - * @param string $portName WSDL port name - * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported) - * @return array - * @access public - */ - function getOperations($portName = '', $bindingType = 'soap') { - $ops = array(); - if ($bindingType == 'soap') { - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ($bindingType == 'soap12') { - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; - } else { - $this->debug("getOperations bindingType $bindingType may not be supported"); - } - $this->debug("getOperations for port '$portName' bindingType $bindingType"); - // loop thru ports - foreach($this->ports as $port => $portData) { - $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']); - if ($portName == '' || $port == $portName) { - // binding type of port matches parameter - if ($portData['bindingType'] == $bindingType) { - $this->debug("getOperations found port $port bindingType $bindingType"); - //$this->debug("port data: " . $this->varDump($portData)); - //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ])); - // merge bindings - if (isset($this->bindings[ $portData['binding'] ]['operations'])) { - $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']); - } - } - } - } - if (count($ops) == 0) { - $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType"); - } - return $ops; - } - - /** - * returns an associative array of data necessary for calling an operation - * - * @param string $operation name of operation - * @param string $bindingType type of binding eg: soap, soap12 - * @return array - * @access public - */ - function getOperationData($operation, $bindingType = 'soap') - { - if ($bindingType == 'soap') { - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ($bindingType == 'soap12') { - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; - } - // loop thru ports - foreach($this->ports as $port => $portData) { - // binding type of port matches parameter - if ($portData['bindingType'] == $bindingType) { - // get binding - //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { - foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) { - // note that we could/should also check the namespace here - if ($operation == $bOperation) { - $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; - return $opData; - } - } - } - } - } - - /** - * returns an associative array of data necessary for calling an operation - * - * @param string $soapAction soapAction for operation - * @param string $bindingType type of binding eg: soap, soap12 - * @return array - * @access public - */ - function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') { - if ($bindingType == 'soap') { - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ($bindingType == 'soap12') { - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; - } - // loop thru ports - foreach($this->ports as $port => $portData) { - // binding type of port matches parameter - if ($portData['bindingType'] == $bindingType) { - // loop through operations for the binding - foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { - if ($opData['soapAction'] == $soapAction) { - return $opData; - } - } - } - } - } - - /** - * returns an array of information about a given type - * returns false if no type exists by the given name - * - * typeDef = array( - * 'elements' => array(), // refs to elements array - * 'restrictionBase' => '', - * 'phpType' => '', - * 'order' => '(sequence|all)', - * 'attrs' => array() // refs to attributes array - * ) - * - * @param string $type the type - * @param string $ns namespace (not prefix) of the type - * @return mixed - * @access public - * @see nusoap_xmlschema - */ - function getTypeDef($type, $ns) { - $this->debug("in getTypeDef: type=$type, ns=$ns"); - if ((! $ns) && isset($this->namespaces['tns'])) { - $ns = $this->namespaces['tns']; - $this->debug("in getTypeDef: type namespace forced to $ns"); - } - if (!isset($this->schemas[$ns])) { - foreach ($this->schemas as $ns0 => $schema0) { - if (strcasecmp($ns, $ns0) == 0) { - $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0"); - $ns = $ns0; - break; - } - } - } - if (isset($this->schemas[$ns])) { - $this->debug("in getTypeDef: have schema for namespace $ns"); - for ($i = 0; $i < count($this->schemas[$ns]); $i++) { - $xs = &$this->schemas[$ns][$i]; - $t = $xs->getTypeDef($type); - $this->appendDebug($xs->getDebug()); - $xs->clearDebug(); - if ($t) { - $this->debug("in getTypeDef: found type $type"); - if (!isset($t['phpType'])) { - // get info for type to tack onto the element - $uqType = substr($t['type'], strrpos($t['type'], ':') + 1); - $ns = substr($t['type'], 0, strrpos($t['type'], ':')); - $etype = $this->getTypeDef($uqType, $ns); - if ($etype) { - $this->debug("found type for [element] $type:"); - $this->debug($this->varDump($etype)); - if (isset($etype['phpType'])) { - $t['phpType'] = $etype['phpType']; - } - if (isset($etype['elements'])) { - $t['elements'] = $etype['elements']; - } - if (isset($etype['attrs'])) { - $t['attrs'] = $etype['attrs']; - } - } else { - $this->debug("did not find type for [element] $type"); - } - } - return $t; - } - } - $this->debug("in getTypeDef: did not find type $type"); - } else { - $this->debug("in getTypeDef: do not have schema for namespace $ns"); - } - return false; - } + break; + case 'address': + $this->ports[$this->currentPort]['location'] = $attrs['location']; + $this->ports[$this->currentPort]['bindingType'] = $namespace; + $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace; + $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location']; + break; + } + break; + } + // set status + switch ($name) { + case 'import': + if (isset($attrs['location'])) { + $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); + $this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')'); + } else { + $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); + if (!$this->getPrefixFromNamespace($attrs['namespace'])) { + $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace']; + } + $this->debug('parsing import ' . $attrs['namespace'] . ' - [no location] (' . count($this->import[$attrs['namespace']]) . ')'); + } + break; + //wait for schema + //case 'types': + // $this->status = 'schema'; + // break; + case 'message': + $this->status = 'message'; + $this->messages[$attrs['name']] = array(); + $this->currentMessage = $attrs['name']; + break; + case 'portType': + $this->status = 'portType'; + $this->portTypes[$attrs['name']] = array(); + $this->currentPortType = $attrs['name']; + break; + case "binding": + if (isset($attrs['name'])) { + // get binding name + if (strpos($attrs['name'], ':')) { + $this->currentBinding = $this->getLocalPart($attrs['name']); + } else { + $this->currentBinding = $attrs['name']; + } + $this->status = 'binding'; + $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); + $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']); + } + break; + case 'service': + $this->serviceName = $attrs['name']; + $this->status = 'service'; + $this->debug('current service: ' . $this->serviceName); + break; + case 'definitions': + foreach ($attrs as $name => $value) { + $this->wsdl_info[$name] = $value; + } + break; + } + } + } /** - * prints html description of services - * - * @access private - */ - function webDescription(){ - global $HTTP_SERVER_VARS; + * end-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @access private + */ + function end_element($parser, $name) + { + // unset schema status + if (/*preg_match('/types$/', $name) ||*/ + preg_match('/schema$/', $name) + ) { + $this->status = ""; + $this->appendDebug($this->currentSchema->getDebug()); + $this->currentSchema->clearDebug(); + $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; + $this->debug('Parsing WSDL schema done'); + } + if ($this->status == 'schema') { + $this->currentSchema->schemaEndElement($parser, $name); + } else { + // bring depth down a notch + $this->depth--; + } + // end documentation + if ($this->documentation) { + //TODO: track the node to which documentation should be assigned; it can be a part, message, etc. + //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; + $this->documentation = false; + } + } - if (isset($_SERVER)) { - $PHP_SELF = $_SERVER['PHP_SELF']; - } elseif (isset($HTTP_SERVER_VARS)) { - $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; - } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); - } + /** + * element content handler + * + * @param string $parser XML parser object + * @param string $data element content + * @access private + */ + function character_data($parser, $data) + { + $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; + if (isset($this->message[$pos]['cdata'])) { + $this->message[$pos]['cdata'] .= $data; + } + if ($this->documentation) { + $this->documentation .= $data; + } + } - $b = ' - NuSOAP: '.$this->serviceName.' + /** + * if authenticating, set user credentials here + * + * @param string $username + * @param string $password + * @param string $authtype (basic|digest|certificate|ntlm) + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) + * @access public + */ + function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) + { + $this->debug("setCredentials username=$username authtype=$authtype certRequest="); + $this->appendDebug($this->varDump($certRequest)); + $this->username = $username; + $this->password = $password; + $this->authtype = $authtype; + $this->certRequest = $certRequest; + } + + function getBindingData($binding) + { + if (is_array($this->bindings[$binding])) { + return $this->bindings[$binding]; + } + return false; + } + + /** + * returns an assoc array of operation names => operation data + * + * @param string $portName WSDL port name + * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported) + * @return array + * @access public + */ + function getOperations($portName = '', $bindingType = 'soap') + { + $ops = array(); + if ($bindingType == 'soap') { + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; + } elseif ($bindingType == 'soap12') { + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; + } else { + $this->debug("getOperations bindingType $bindingType may not be supported"); + } + $this->debug("getOperations for port '$portName' bindingType $bindingType"); + // loop thru ports + foreach ($this->ports as $port => $portData) { + $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']); + if ($portName == '' || $port == $portName) { + // binding type of port matches parameter + if ($portData['bindingType'] == $bindingType) { + $this->debug("getOperations found port $port bindingType $bindingType"); + //$this->debug("port data: " . $this->varDump($portData)); + //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ])); + // merge bindings + if (isset($this->bindings[$portData['binding']]['operations'])) { + $ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']); + } + } + } + } + if (count($ops) == 0) { + $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType"); + } + return $ops; + } + + /** + * returns an associative array of data necessary for calling an operation + * + * @param string $operation name of operation + * @param string $bindingType type of binding eg: soap, soap12 + * @return array + * @access public + */ + function getOperationData($operation, $bindingType = 'soap') + { + if ($bindingType == 'soap') { + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; + } elseif ($bindingType == 'soap12') { + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; + } + // loop thru ports + foreach ($this->ports as $portData) { + // binding type of port matches parameter + if ($portData['bindingType'] == $bindingType) { + // get binding + //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { + // note that we could/should also check the namespace here + if (in_array ($operation, array_keys ($this->bindings[$portData['binding']]['operations']))) + { + return $this->bindings[$portData['binding']]['operations'][$operation]; + } + } + } + return array (); + } + + /** + * returns an associative array of data necessary for calling an operation + * + * @param string $soapAction soapAction for operation + * @param string $bindingType type of binding eg: soap, soap12 + * @return array + * @access public + */ + function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') + { + if ($bindingType == 'soap') { + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; + } elseif ($bindingType == 'soap12') { + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; + } + // loop thru ports + foreach ($this->ports as $portData) { + // binding type of port matches parameter + if ($portData['bindingType'] == $bindingType) { + // loop through operations for the binding + foreach ($this->bindings[$portData['binding']]['operations'] as $opData) { + if ($opData['soapAction'] == $soapAction) { + return $opData; + } + } + } + } + return array (); + } + + /** + * returns an array of information about a given type + * returns false if no type exists by the given name + * typeDef = array( + * 'elements' => array(), // refs to elements array + * 'restrictionBase' => '', + * 'phpType' => '', + * 'order' => '(sequence|all)', + * 'attrs' => array() // refs to attributes array + * ) + * + * @param string $type the type + * @param string $ns namespace (not prefix) of the type + * @return false + * @access public + * @see nusoap_xmlschema + */ + function getTypeDef($type, $ns) + { + $this->debug("in getTypeDef: type=$type, ns=$ns"); + if ((!$ns) && isset($this->namespaces['tns'])) { + $ns = $this->namespaces['tns']; + $this->debug("in getTypeDef: type namespace forced to $ns"); + } + if (!isset($this->schemas[$ns])) { + foreach ($this->schemas as $ns0 => $schema0) { + if (strcasecmp($ns, $ns0) == 0) { + $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0"); + $ns = $ns0; + break; + } + } + } + if (isset($this->schemas[$ns])) { + $this->debug("in getTypeDef: have schema for namespace $ns"); + for ($i = 0; $i < count($this->schemas[$ns]); $i++) { + $xs = &$this->schemas[$ns][$i]; + $t = $xs->getTypeDef($type); + $this->appendDebug($xs->getDebug()); + $xs->clearDebug(); + if ($t) { + $this->debug("in getTypeDef: found type $type"); + if (!isset($t['phpType'])) { + // get info for type to tack onto the element + $uqType = substr($t['type'], strrpos($t['type'], ':') + 1); + $ns = substr($t['type'], 0, strrpos($t['type'], ':')); + $etype = $this->getTypeDef($uqType, $ns); + if ($etype) { + $this->debug("found type for [element] $type:"); + $this->debug($this->varDump($etype)); + if (isset($etype['phpType'])) { + $t['phpType'] = $etype['phpType']; + } + if (isset($etype['elements'])) { + $t['elements'] = $etype['elements']; + } + if (isset($etype['attrs'])) { + $t['attrs'] = $etype['attrs']; + } + } else { + $this->debug("did not find type for [element] $type"); + } + } + return $t; + } + } + $this->debug("in getTypeDef: did not find type $type"); + } else { + $this->debug("in getTypeDef: do not have schema for namespace $ns"); + } + return false; + } + + /** + * prints html description of services + * + * @access private + */ + function webDescription() + { + global $HTTP_SERVER_VARS; + + if (isset($_SERVER)) { + $PHP_SELF = $_SERVER['PHP_SELF']; + } elseif (isset($HTTP_SERVER_VARS)) { + $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; + } else { + $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $PHP_SELF = ''; + } + + $b = ' + NuSOAP: ' . $this->serviceName . ' '; $out .= ''; } else { @@ -8101,7 +8140,7 @@ class Form * Output html form to select an object. * Note, this function is called by selectForForms or by ajax selectobject.php * - * @param Object $objecttmp Object to knwo the table to scan for combo. + * @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', ...) @@ -8113,13 +8152,13 @@ class Form * @param int $outputmode 0=HTML select string, 1=Array * @param int $disabled 1=Html component is disabled * @param string $sortfield Sort field - * @param string $filter Add more filter + * @param string $filter Add more filter (Universal Search Filter) * @return string|array Return HTML string * @see selectForForms() */ public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '', $filter = '') { - global $conf, $langs, $user, $hookmanager; + global $langs, $user, $hookmanager; //print "$htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, $outputmode, $disabled"; @@ -8239,7 +8278,7 @@ class Form $textifempty = ' '; //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; - if (!empty($conf->global->$confkeyforautocompletemode)) { + if (getDolGlobalInt($confkeyforautocompletemode)) { if ($showempty && !is_numeric($showempty)) { $textifempty = $langs->trans($showempty); } else { @@ -8289,7 +8328,7 @@ class Form if (!$forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname, null, (!empty($conf->global->$confkeyforautocompletemode) ? $conf->global->$confkeyforautocompletemode : 0)); + $out .= ajax_combobox($htmlname, null, getDolGlobalInt($confkeyforautocompletemode, 0)); } } else { dol_print_error($this->db); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index de24f13997f..a1cb88fa60e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12134,7 +12134,7 @@ function getElementProperties($element_type) * Fetch an object from its id and element_type * Inclusion of classes is automatic * - * @param int $element_id Element id + * @param int $element_id Element id (Use this or element_id but not both) * @param string $element_type Element type ('module' or 'myobject@mymodule' or 'mymodule_myobject') * @param string $element_ref Element ref (Use this or element_id but not both) * @return int|object object || 0 || <0 if error @@ -12154,13 +12154,17 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '') if (class_exists($element_prop['classname'])) { $classname = $element_prop['classname']; $objecttmp = new $classname($db); - $ret = $objecttmp->fetch($element_id, $element_ref); - if ($ret >= 0) { - if (empty($objecttmp->module)) { - $objecttmp->module = $element_prop['module']; - } - return $objecttmp; + if ($element_id > 0 || !empty($element_ref)) { + $ret = $objecttmp->fetch($element_id, $element_ref); + if ($ret >= 0) { + if (empty($objecttmp->module)) { + $objecttmp->module = $element_prop['module']; + } + return $objecttmp; + } + } else { + return $objecttmp; // returned an object without fetch } } else { return -1; From a767028464ca6605d176f99e70c60a1d66a65282 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Dec 2023 21:35:23 +0100 Subject: [PATCH 147/315] Clean code --- htdocs/contact/class/contact.class.php | 5 +---- htdocs/contact/list.php | 22 ++++++++++++------- .../partnership/class/partnership.class.php | 13 ++++++----- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/list.php | 5 +++-- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index cf0599e3e00..f87217d2e02 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -99,7 +99,7 @@ class Contact extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>3, 'notnull'=>1, 'position'=>30, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>3, 'position'=>35), 'civility' =>array('type'=>'varchar(6)', 'label'=>'Civility', 'enabled'=>1, 'visible'=>3, 'position'=>40), @@ -359,9 +359,6 @@ class Contact extends CommonObject $this->db = $db; $this->statut = 1; // By default, status is enabled - if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) { - $this->fields['rowid']['visible'] = 0; - } if (!isModEnabled('mailing')) { $this->fields['no_email']['enabled'] = 0; } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 8330a43f424..126b475a665 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -298,7 +298,7 @@ if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change custom require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $invoice = new Facture($db); $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $invoice->socid = $conf->global->$constforthirdpartyid; + $invoice->socid = getDolGlobalInt($constforthirdpartyid); $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; @@ -594,7 +594,7 @@ if (!empty($searchCategoryCustomerList)) { } } - // Search Supplier Categories +// Search Supplier Categories $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array(); $searchCategorySupplierOperator = 0; // Search for tag/category ($searchCategorySupplierList is an array of ID) @@ -748,6 +748,11 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec $sql .= $hookmanager->resPrint; //print $sql; +// Add GroupBy from hooks +$parameters = array('fieldstosearchall' => $fieldstosearchall); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + // Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { @@ -798,7 +803,7 @@ if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($ // Output page // -------------------------------------------------------------------- -// Page Header + llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -813,6 +818,9 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} $param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($search_all); $param .= '&type='.urlencode($type).'&view='.urlencode($view); if (!empty($search_categ) && $search_categ != '-1') { @@ -892,9 +900,6 @@ if (is_array($search_level) && count($search_level)) { if ($search_import_key != '') { $param .= '&search_import_key='.urlencode($search_import_key); } -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} if (count($search_roles) > 0) { $param .= implode('&search_roles[]=', $search_roles); } @@ -953,6 +958,7 @@ if ($contextpage != 'poslist') { $label = 'MenuNewCustomer'; $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url); } + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; @@ -1020,7 +1026,7 @@ print ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields -$selectedfields .= count($arrayofmassactions) && $contextpage != 'poslist' ? $form->showCheckAddButtons('checkforselect', 1) : ''; +$selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; @@ -1030,7 +1036,7 @@ print '
'; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index bd402f916d2..3f8e6b176d8 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -26,6 +26,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + /** * Class for Partnership */ @@ -105,16 +106,16 @@ class Partnership extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object", 'csslist'=>'tdoverflowmax150'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'isModEnabled("multicompany")', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), - 'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax100'), + 'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax125'), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax125',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax125'), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax125'), 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6d173cd11a2..8489ae8d290 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -189,7 +189,7 @@ class Societe extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), 'parent' =>array('type'=>'integer', 'label'=>'Parent', 'enabled'=>1, 'visible'=>-1, 'position'=>20), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30), diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 57e4657148e..ab63c3e24ab 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -309,7 +309,7 @@ $result = restrictedArea($user, 'societe', $socid, ''); * Actions */ -if ($action == "change") { // Change customer for TakePOS +if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change customer for TakePOS $idcustomer = GETPOST('idcustomer', 'int'); // Check if draft invoice already exists, if not create it @@ -538,7 +538,7 @@ $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; -$sqlfields = $sql; // $sql fields to remove for count totall +$sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; @@ -609,6 +609,7 @@ if (!empty($searchCategoryCustomerList)) { } } } +// Search Supplier Categories $searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array(); $searchCategorySupplierOperator = 0; // Search for tag/category ($searchCategorySupplierList is an array of ID) From 756180cfb5b6f75822bca2954ef87ab089c9f07e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Dec 2023 22:21:41 +0100 Subject: [PATCH 148/315] Debug v19 --- htdocs/adherents/class/adherent.class.php | 31 ++++++++------- htdocs/adherents/list.php | 47 +++++++++++++++++------ 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 154b886ae0e..f8aabe6867d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -280,35 +280,35 @@ class Adherent extends CommonObject */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), - 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'default' => 1, 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 12, 'index' => 1), + 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 12, 'index' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), - 'lastname' => array('type' => 'varchar(50)', 'label' => 'Lastname', 'enabled' => 1, 'visible' => -1, 'position' => 30, 'showoncombobox'=>1), - 'firstname' => array('type' => 'varchar(50)', 'label' => 'Firstname', 'enabled' => 1, 'visible' => -1, 'position' => 35, 'showoncombobox'=>1), - 'login' => array('type' => 'varchar(50)', 'label' => 'Login', 'enabled' => 1, 'visible' => -1, 'position' => 40), - 'gender' => array('type' => 'varchar(10)', 'label' => 'Gender', 'enabled' => 1, 'visible' => -1, 'position' => 250), + 'lastname' => array('type' => 'varchar(50)', 'label' => 'Lastname', 'enabled' => 1, 'visible' => 1, 'position' => 30, 'showoncombobox'=>1), + 'firstname' => array('type' => 'varchar(50)', 'label' => 'Firstname', 'enabled' => 1, 'visible' => 1, 'position' => 35, 'showoncombobox'=>1), + 'login' => array('type' => 'varchar(50)', 'label' => 'Login', 'enabled' => 1, 'visible' => 1, 'position' => 40), 'pass' => array('type' => 'varchar(50)', 'label' => 'Pass', 'enabled' => 1, 'visible' => -1, 'position' => 45), 'pass_crypted' => array('type' => 'varchar(128)', 'label' => 'Pass crypted', 'enabled' => 1, 'visible' => -1, 'position' => 50), - 'fk_adherent_type' => array('type' => 'integer', 'label' => 'Fk adherent type', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 55), - 'morphy' => array('type' => 'varchar(3)', 'label' => 'MorPhy', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 60), - 'societe' => array('type' => 'varchar(128)', 'label' => 'Societe', 'enabled' => 1, 'visible' => -1, 'position' => 65, 'showoncombobox'=>2), - 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'enabled' => 1, 'visible' => -1, 'position' => 70), + 'morphy' => array('type' => 'varchar(3)', 'label' => 'MemberNature', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 55), + 'fk_adherent_type' => array('type' => 'integer', 'label' => 'Fk adherent type', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 60), + 'societe' => array('type' => 'varchar(128)', 'label' => 'Societe', 'enabled' => 1, 'visible' => 1, 'position' => 65, 'showoncombobox'=>2), + 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'enabled' => 1, 'visible' => 1, 'position' => 70), 'address' => array('type' => 'text', 'label' => 'Address', 'enabled' => 1, 'visible' => -1, 'position' => 75), 'zip' => array('type' => 'varchar(10)', 'label' => 'Zip', 'enabled' => 1, 'visible' => -1, 'position' => 80), 'town' => array('type' => 'varchar(50)', 'label' => 'Town', 'enabled' => 1, 'visible' => -1, 'position' => 85), 'state_id' => array('type' => 'integer', 'label' => 'State id', 'enabled' => 1, 'visible' => -1, 'position' => 90), - 'country' => array('type' => 'integer:Ccountry:core/class/ccountry.class.php', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), - 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => -1, 'position' => 100), - 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>110), - 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 105), + 'country' => array('type' => 'integer:Ccountry:core/class/ccountry.class.php', 'label' => 'Country', 'enabled' => 1, 'visible' => 1, 'position' => 95), 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => -1, 'position' => 115), 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'Phone perso', 'enabled' => 1, 'visible' => -1, 'position' => 120), 'phone_mobile' => array('type' => 'varchar(30)', 'label' => 'Phone mobile', 'enabled' => 1, 'visible' => -1, 'position' => 125), + 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => 1, 'position' => 126), + 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>127), + 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 128), 'birth' => array('type' => 'date', 'label' => 'DateOfBirth', 'enabled' => 1, 'visible' => -1, 'position' => 130), + 'gender' => array('type' => 'varchar(10)', 'label' => 'Gender', 'enabled' => 1, 'visible' => -1, 'position' => 132), 'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => -1, 'position' => 135), 'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145), - 'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => -1, 'position' => 150), + 'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => 1, 'position' => 150), 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=> 153), 'note_public' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155), 'note_private' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160), @@ -319,8 +319,7 @@ class Adherent extends CommonObject 'fk_user_mod' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'Fk user mod', 'enabled' => 1, 'visible' => -1, 'position' => 185), 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190), 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195), - 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500, - 'arrayofkeyval' => array(-1 => 'Draft', 1 => 'Validated', 0 => 'MemberStatusResiliatedShort', -2 => 'MemberStatusExcludedShort')), + 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 500, 'arrayofkeyval' => array(-1 => 'Draft', 1 => 'Validated', 0 => 'MemberStatusResiliatedShort', -2 => 'MemberStatusExcludedShort')), 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800), 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805) ); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index db1b89a49ab..018b023a837 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -150,32 +150,57 @@ $arrayfields = array( 'd.lastname'=>array('label'=>"Lastname", 'checked'=>1), 'd.firstname'=>array('label'=>"Firstname", 'checked'=>1), 'd.gender'=>array('label'=>"Gender", 'checked'=>0), - 'd.company'=>array('label'=>"Company", 'checked'=>1), + 'd.company'=>array('label'=>"Company", 'checked'=>1, 'position'=>70), 'd.login'=>array('label'=>"Login", 'checked'=>1), 'd.morphy'=>array('label'=>"MemberNature", 'checked'=>1), - 't.libelle'=>array('label'=>"Type", 'checked'=>1), - 'd.email'=>array('label'=>"Email", 'checked'=>1), + 't.libelle'=>array('label'=>"Type", 'checked'=>1, 'position'=>55), 'd.address'=>array('label'=>"Address", 'checked'=>0), 'd.zip'=>array('label'=>"Zip", 'checked'=>0), 'd.town'=>array('label'=>"Town", 'checked'=>0), 'd.phone'=>array('label'=>"Phone", 'checked'=>0), 'd.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0), 'd.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>0), - 'state.nom'=>array('label'=>"State", 'checked'=>0), - 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), + 'd.email'=>array('label'=>"Email", 'checked'=>1), + 'state.nom'=>array('label'=>"State", 'checked'=>0, 'position'=>90), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>95), /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0), 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/ - 'd.datefin'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>500), - 'd.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 'd.birth'=>array('label'=>"Birthday", 'checked'=>0, 'position'=>500), - 'd.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), - 'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), + 'd.datefin'=>array('label'=>"EndSubscription"), + 'd.datec'=>array('label'=>"DateCreation"), + 'd.birth'=>array('label'=>"Birthday"), + 'd.tms'=>array('label'=>"DateModificationShort"), + 'd.statut'=>array('label'=>"Status"), + 'd.import_key'=>array('label'=>"ImportId"), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +$object->fields = dol_sort_array($object->fields, 'position'); +//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); + +// Complete array of fields for columns +$tableprefix = 'd'; +foreach ($object->fields as $key => $val) { + if (!array_key_exists($tableprefix.'.'.$key, $arrayfields)) { // Discard record not into $arrayfields + continue; + } + // If $val['visible']==0, then we never show the field + + if (!empty($val['visible'])) { + $visible = (int) dol_eval($val['visible'], 1); + $arrayfields[$tableprefix.'.'.$key] = array( + 'label'=>$val['label'], + 'checked'=>(($visible < 0) ? 0 : 1), + 'enabled'=>dol_eval($val['enabled'], 1), + 'position'=>$val['position'], + 'help'=> isset($val['help']) ? $val['help'] : '' + ); + } +} +$arrayfields = dol_sort_array($arrayfields, 'position'); +//var_dump($arrayfields);exit; + // Security check $result = restrictedArea($user, 'adherent'); From 4c7c456e8acb00db4da95aac6e6f3937b8509933 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Dec 2023 10:40:22 +0100 Subject: [PATCH 149/315] css --- 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 7f6a397e0c6..73d9e78a02c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8272,7 +8272,7 @@ class Form $resql = $this->db->query($sql); if ($resql) { // Construct $out and $outarray - $out .= '' . "\n"; // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4 $textifempty = ' '; From 1838bc0031e2e2abea3b8e70c242618bf68ac0de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Dec 2023 10:46:05 +0100 Subject: [PATCH 150/315] Fix #yogosha19630 --- build/exe/doliwamp/UsedPort.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build/exe/doliwamp/UsedPort.cpp b/build/exe/doliwamp/UsedPort.cpp index 48a44f03c47..a63938c5038 100644 --- a/build/exe/doliwamp/UsedPort.cpp +++ b/build/exe/doliwamp/UsedPort.cpp @@ -253,6 +253,7 @@ int main(int argc, char **argv) //---------------- int noarg,curseurarg,help=0,invalide=0; char option; +char *endptr; for (noarg=1;noarg INT_MAX) { + // Handle error: Port number out of range + printf("Port number out of range\n"); + exit(-1); +} + help=!(Port > 0); // Show usage From fbf91cc211b61de7b0385a95a7051e3181afd99e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Dec 2023 11:43:30 +0100 Subject: [PATCH 151/315] Fix #yogosha19665 --- htdocs/core/ajax/fileupload.php | 4 +- htdocs/core/class/fileupload.class.php | 54 +++++++++++++------------- htdocs/filefunc.inc.php | 1 + htdocs/ftp/index.php | 4 +- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 177154cee3a..fc89b77c56b 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -18,7 +18,7 @@ /** * \file htdocs/core/ajax/fileupload.php - * \brief File to return Ajax response on file upload + * \brief File to return Ajax response on common file upload. For large files, see flowjs-server.php */ if (!defined('NOREQUIREMENU')) { @@ -36,7 +36,7 @@ if (!defined('NOREQUIRESOC')) { // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php'; // Class to upload common files require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; $id = GETPOST('fk_element', 'int'); diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index a5d1e170674..357554a3f13 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -18,7 +18,7 @@ /** * \file htdocs/core/class/fileupload.class.php - * \brief File to return Ajax response on file upload + * \brief File to return Ajax response on common file upload. For large files, see flowjs-server.php */ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -44,7 +44,7 @@ class FileUpload */ public function __construct($options = null, $fk_element = null, $element = null) { - global $db, $conf; + global $db; global $hookmanager; $hookmanager->initHooks(array('fileupload')); @@ -56,8 +56,8 @@ class FileUpload $this->element = $element; $pathname = str_replace('/class', '', $element_prop['classpath']); - $filename = $element_prop['classfile']; - $dir_output = $element_prop['dir_output']; + $filename = dol_sanitizeFileName($element_prop['classfile']); + $dir_output = dol_sanitizePathName($element_prop['dir_output']); //print 'fileupload.class.php: element='.$element.' pathname='.$pathname.' filename='.$filename.' dir_output='.$dir_output."\n"; @@ -131,7 +131,7 @@ class FileUpload */ 'thumbnail' => array( 'upload_dir' => $dir_output.'/'.$object_ref.'/thumbs/', - 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.urlencode($element).'&attachment=1&file=/'.$object_ref.'/thumbs/', + 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.urlencode($element).'&attachment=1&file='.urlencode('/'.$object_ref.'/thumbs/'), 'max_width' => 80, 'max_height' => 80 ) @@ -211,20 +211,20 @@ class FileUpload */ protected function getFileObject($file_name) { - $file_path = $this->options['upload_dir'].$file_name; - if (is_file($file_path) && $file_name[0] !== '.') { + $file_path = $this->options['upload_dir'].dol_sanitizeFileName($file_name); + if (dol_is_file($file_path) && $file_name[0] !== '.') { $file = new stdClass(); $file->name = $file_name; $file->mime = dol_mimetype($file_name, '', 2); $file->size = filesize($file_path); - $file->url = $this->options['upload_url'].rawurlencode($file->name); + $file->url = $this->options['upload_url'].urlencode($file->name); foreach ($this->options['image_versions'] as $version => $options) { - if (is_file($options['upload_dir'].$file_name)) { + if (dol_is_file($options['upload_dir'].$file_name)) { $tmp = explode('.', $file->name); // We save the path of mini file into file->... (seems not used) $keyforfile = $version.'_url'; - $file->$keyforfile = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); + $file->$keyforfile = $options['upload_url'].urlencode($tmp[0].'_mini.'.$tmp[1]); } } $this->setFileDeleteUrl($file); @@ -280,7 +280,7 @@ class FileUpload } /** - * Enter description here ... + * Make validation on an uploaded file * * @param string $uploaded_file Uploade file * @param object $file File @@ -303,7 +303,7 @@ class FileUpload return false; } if ($uploaded_file && is_uploaded_file($uploaded_file)) { - $file_size = filesize($uploaded_file); + $file_size = dol_filesize($uploaded_file); } else { $file_size = $_SERVER['CONTENT_LENGTH']; } @@ -379,15 +379,14 @@ class FileUpload { // Remove path information and dots around the filename, to prevent uploading // into different directories or replacing hidden system files. - // Also remove control characters and spaces (\x00..\x20) around the filename: - $file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); + $file_name = basename(dol_sanitizeFileName($name)); // Add missing file extension for known image types: $matches = array(); if (strpos($file_name, '.') === false && preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { $file_name .= '.'.$matches[1]; } if ($this->options['discard_aborted_uploads']) { - while (is_file($this->options['upload_dir'].$file_name)) { + while (dol_is_file($this->options['upload_dir'].$file_name)) { $file_name = $this->upcountName($file_name); } } @@ -414,12 +413,16 @@ class FileUpload $file->size = intval($size); $file->type = $type; + // Sanitize to avoid stream execution when calling file_size(). Not that this is a second security because + // most streams are already disabled by stream_wrapper_unregister() in filefunc.inc.php + $uploaded_file = preg_replace('/\s*(http|ftp)s?:/i', '', $uploaded_file); + $validate = $this->validate($uploaded_file, $file, $error, $index); if ($validate) { if (dol_mkdir($this->options['upload_dir']) >= 0) { - $file_path = $this->options['upload_dir'].$file->name; - $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); + $file_path = dol_sanitizePathName($this->options['upload_dir']).dol_sanitizeFileName($file->name); + $append_file = !$this->options['discard_aborted_uploads'] && dol_is_file($file_path) && $file->size > dol_filesize($file_path); clearstatcache(); @@ -434,16 +437,16 @@ class FileUpload // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } - $file_size = filesize($file_path); + $file_size = dol_filesize($file_path); if ($file_size === $file->size) { - $file->url = $this->options['upload_url'].rawurlencode($file->name); + $file->url = $this->options['upload_url'].urlencode($file->name); foreach ($this->options['image_versions'] as $version => $options) { if ($this->createScaledImage($file->name, $options)) { // Creation of thumbs mini and small is ok $tmp = explode('.', $file->name); // We save the path of mini file into file->... (seems not used) $keyforfile = $version.'_url'; - $file->$keyforfile = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); + $file->$keyforfile = $options['upload_url'].urlencode($tmp[0].'_mini.'.$tmp[1]); } } } elseif ($this->options['discard_aborted_uploads']) { @@ -537,7 +540,7 @@ class FileUpload /* disabled. Param redirect seems not used $redirect = isset($_REQUEST['redirect']) ? stripslashes($_REQUEST['redirect']) : null; if ($redirect) { - header('Location: '.sprintf($redirect, rawurlencode($json))); + header('Location: '.sprintf($redirect, urlencode($json))); return; } */ @@ -559,14 +562,13 @@ class FileUpload */ public function delete() { - $file_name = isset($_REQUEST['file']) ? - basename(stripslashes($_REQUEST['file'])) : null; - $file_path = $this->options['upload_dir'].$file_name; - $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); + $file_name = GETPOST('file') ? basename(GETPOST('file')) : null; + $file_path = $this->options['upload_dir'].dol_sanitizeFileName($file_name); + $success = dol_is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); if ($success) { foreach ($this->options['image_versions'] as $version => $options) { $file = $options['upload_dir'].$file_name; - if (is_file($file)) { + if (dol_is_file($file)) { unlink($file); } } diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 91d3f73152d..48288cf2de4 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -81,6 +81,7 @@ $result = @include_once $conffile; // Keep @ because with some error reporting t // Disable some not used PHP stream $listofwrappers = stream_get_wrappers(); // We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar by default. +// phar stream does not auto unserialize content (possible code execution) since PHP 8.1 $arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zip', 'zlib'); if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) { $arrayofstreamtodisable = $dolibarr_main_stream_to_disable; diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index c1fac0b66e5..d13b83402bf 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -111,8 +111,8 @@ if ($action == 'uploadfile') { $nbfile = count($_FILES['userfile']['name']); for ($i = 0; $i < $nbfile; $i++) { $newsection = $newsectioniso; - $fileupload = $_FILES['userfile']['name'][$i]; - $fileuploadpath = $_FILES['userfile']['tmp_name'][$i]; + $fileupload = dol_sanitizeFileName($_FILES['userfile']['name'][$i]); + $fileuploadpath = dol_sanitizePathName($_FILES['userfile']['tmp_name'][$i]); $result = dol_ftp_put($conn_id, $fileupload, $fileuploadpath, $newsection); if ($result) { From d21a5000a807aa8766cbd06dc7ec2e208018f676 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Dec 2023 11:48:00 +0100 Subject: [PATCH 152/315] Fix #yogosha19665 --- htdocs/core/class/fileupload.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 357554a3f13..d0cd306d2f2 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2012 Laurent Destailleur + * Copyright (C) 2011-2023 Laurent Destailleur * * 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 @@ -17,8 +17,9 @@ */ /** - * \file htdocs/core/class/fileupload.class.php - * \brief File to return Ajax response on common file upload. For large files, see flowjs-server.php + * \file htdocs/core/class/fileupload.class.php + * \brief File to return Ajax response on common file upload. + * For large files, see flowjs-server.php */ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -195,8 +196,7 @@ class FileUpload */ protected function setFileDeleteUrl($file) { - $file->delete_url = $this->options['script_url'] - .'?file='.urlencode($file->name).'&fk_element='.urlencode($this->fk_element).'&element='.urlencode($this->element); + $file->delete_url = $this->options['script_url'].'?file='.urlencode($file->name).'&fk_element='.urlencode($this->fk_element).'&element='.urlencode($this->element); $file->delete_type = $this->options['delete_type']; if ($file->delete_type !== 'DELETE') { $file->delete_url .= '&_method=DELETE'; @@ -212,6 +212,7 @@ class FileUpload protected function getFileObject($file_name) { $file_path = $this->options['upload_dir'].dol_sanitizeFileName($file_name); + if (dol_is_file($file_path) && $file_name[0] !== '.') { $file = new stdClass(); $file->name = $file_name; @@ -416,6 +417,7 @@ class FileUpload // Sanitize to avoid stream execution when calling file_size(). Not that this is a second security because // most streams are already disabled by stream_wrapper_unregister() in filefunc.inc.php $uploaded_file = preg_replace('/\s*(http|ftp)s?:/i', '', $uploaded_file); + $uploaded_file = realpath($uploaded_file); // A hack to be sure the file point to an existing file on disk (and is not a SSRF attack) $validate = $this->validate($uploaded_file, $file, $error, $index); From 40d10299644dd143f987621b94c8bf1f980b8261 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Dec 2023 12:09:54 +0100 Subject: [PATCH 153/315] Fix debug v19 - "Show more" on ACE editor was broken --- htdocs/core/class/doleditor.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 4a9d216bca2..01a17f605b6 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -263,7 +263,7 @@ class DolEditor if ($titlecontent) { $out .= '
'.$titlecontent; - $out .= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; + $out .= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; $out .= '
'; $out .= ''."\n"; foreach ($showextcals as $val) { - $htmlname = md5($val['name']); + $htmlname = md5($val['name']); // not used for security purpose, only to get a string with no special char if (!empty($val['default']) || GETPOST('check_ext'.$htmlname, 'int')) { $default = "checked"; From 00f5a7bc4c00ba916b3066d591a23f71e9414844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 22 Dec 2023 15:22:40 +0100 Subject: [PATCH 179/315] Update PclZipProxy.php --- htdocs/includes/odtphp/zip/PclZipProxy.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/includes/odtphp/zip/PclZipProxy.php b/htdocs/includes/odtphp/zip/PclZipProxy.php index 45ea50d5047..01d657a80a9 100644 --- a/htdocs/includes/odtphp/zip/PclZipProxy.php +++ b/htdocs/includes/odtphp/zip/PclZipProxy.php @@ -39,7 +39,7 @@ class PclZipProxy implements ZipInterface * Open a Zip archive * * @param string $filename the name of the archive to open - * @return true if openning has succeeded + * @return bool true if openning has succeeded */ public function open($filename) { @@ -56,7 +56,7 @@ class PclZipProxy implements ZipInterface * Retrieve the content of a file within the archive from its name * * @param string $name the name of the file to extract - * @return the content of the file in a string + * @return string the content of the file in a string */ public function getFromName($name) { @@ -77,7 +77,7 @@ class PclZipProxy implements ZipInterface * * @param string $localname the local path to the file in the archive * @param string $contents the content of the file - * @return true if the file has been successful added + * @return bool true if the file has been successful added */ public function addFromString($localname, $contents) { @@ -110,7 +110,7 @@ class PclZipProxy implements ZipInterface * * @param string $filename the path to the file we want to add * @param string $localname the local path to the file in the archive - * @return true if the file has been successful added + * @return bool true if the file has been successful added */ public function addFile($filename, $localname = null) { @@ -144,7 +144,7 @@ class PclZipProxy implements ZipInterface /** * Close the Zip archive - * @return true + * @return bool true */ public function close() { From 0453b3efe2404f7ab004b65889894995c52ce270 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 22 Dec 2023 16:10:14 +0100 Subject: [PATCH 180/315] fix some warnings phpstan --- htdocs/core/class/extrafields.class.php | 14 +++++++------- htdocs/core/class/extralanguages.class.php | 2 +- htdocs/core/class/fiscalyear.class.php | 10 +++++----- htdocs/core/class/hookmanager.class.php | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 92483d49a6b..d0659dc3036 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -185,7 +185,7 @@ class ExtraFields * This is a private method. For public method, use addExtraField. * * @param string $attrname code of attribute - * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','pricecy','phone','mail','password','url','select','checkbox', ...) + * @param string $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','pricecy','phone','mail','password','url','select','checkbox', ...) * @param string $length Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not @@ -199,7 +199,7 @@ class ExtraFields * @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) * @return int Return integer <=0 if KO, >0 if OK */ - private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '', $moreparams = array()) + private function create($attrname, $type = 'varchar', $length = '255', $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = array(), $perms = '', $list = '0', $computed = '', $help = '', $moreparams = array()) { if ($elementtype == 'thirdparty') { $elementtype = 'societe'; @@ -281,7 +281,7 @@ class ExtraFields * * @param string $attrname code of attribute * @param string $label label of attribute - * @param int $type Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datehour', 'float') + * @param string $type Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datehour', 'float') * @param int $pos Position of attribute * @param string $size Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) @@ -303,7 +303,7 @@ class ExtraFields * @return int Return integer <=0 if KO, >0 if OK * @throws Exception */ - private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) + private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = '', $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) { // phpcs:enable global $conf, $user; @@ -551,7 +551,7 @@ class ExtraFields * @return int >0 if OK, <=0 if KO * @throws Exception */ - public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) + public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = array(), $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) { global $action, $hookmanager; @@ -676,7 +676,7 @@ class ExtraFields * @return int Return integer <=0 if KO, >0 if OK * @throws Exception */ - private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) + private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = array(), $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array()) { // phpcs:enable global $conf, $user; @@ -934,7 +934,7 @@ class ExtraFields * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) * @param int $objectid Current object id * @param string $extrafieldsobjectkey The key to use to store retreived data (commonly $object->table_element) - * @param string $mode 1=Used for search filters + * @param int $mode 1=Used for search filters * @return string */ public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '', $mode = 0) diff --git a/htdocs/core/class/extralanguages.class.php b/htdocs/core/class/extralanguages.class.php index e5a07aa6ac0..b5e05ca04e2 100644 --- a/htdocs/core/class/extralanguages.class.php +++ b/htdocs/core/class/extralanguages.class.php @@ -134,7 +134,7 @@ class ExtraLanguages * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) * @param int $objectid Current object id - * @param string $mode 1=Used for search filters + * @param int $mode 1=Used for search filters * @return string */ public function showInputField($key, $value, $extrafieldsobjectkey, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $mode = 0) diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index caa62050b48..0162ee7de95 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -463,9 +463,9 @@ class Fiscalyear extends CommonObject /** * Return the number of entries by fiscal year * - * @param int $datestart Date start to scan - * @param int $dateend Date end to scan - * @return string Number of entries + * @param int|string $datestart Date start to scan + * @param int|string $dateend Date end to scan + * @return string Number of entries */ public function getAccountancyEntriesByFiscalYear($datestart = '', $dateend = '') { @@ -497,8 +497,8 @@ class Fiscalyear extends CommonObject /** * Return the number of movements by fiscal year * - * @param int $datestart Date start to scan - * @param int $dateend Date end to scan + * @param int|string $datestart Date start to scan + * @param int|string $dateend Date end to scan * @return string Number of movements */ public function getAccountancyMovementsByFiscalYear($datestart = '', $dateend = '') diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index b3e71f4d543..6fd2fbd8249 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -153,7 +153,7 @@ class HookManager * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. */ - public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') + public function executeHooks($method, $parameters = array(), &$object = null, &$action = '') { if (!is_array($this->hooks) || empty($this->hooks)) { return 0; // No hook available, do nothing. From 484dd8e4267fb5a6dde615c6ae2e1a1cba12dc23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 10:17:28 +0100 Subject: [PATCH 181/315] Debug v19 --- .../modulebuilder/template/myobject_card.php | 1 + htdocs/product/card.php | 2 +- .../workstation/class/workstation.class.php | 8 +- htdocs/workstation/workstation_card.php | 119 +++++++++------- htdocs/workstation/workstation_list.php | 132 +++++++++++------- 5 files changed, 156 insertions(+), 106 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 3f62a4006e9..8695b9a9100 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -560,6 +560,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } /* + // Disable / Enable if ($permissiontoadd) { if ($object->status == $object::STATUS_ENABLED) { print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 0783ed88269..c25993cac5d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2106,7 +2106,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio if (!getDolGlobalString('PRODUCT_DISABLE_PUBLIC_URL')) { print '
'; } diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index a4339f27372..1249240c4ba 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -100,7 +100,7 @@ class Workstation extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object", 'csslist'=>'tdoverflowmax150'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'showoncombobox'=>'2',), 'type' => array('type'=>'varchar(8)', 'label'=>'Type', 'enabled'=>'1', 'position'=>32, 'default'=>1, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('HUMAN'=>'Human', 'MACHINE'=>'Machine', 'BOTH'=>'HumanMachine'),), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), @@ -110,9 +110,9 @@ class Workstation extends CommonObject 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>512, 'notnull'=>-1, 'visible'=>-2,), - 'nb_operators_required' => array('type'=>'integer', 'label'=>'NbOperatorsRequired', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1,), - 'thm_operator_estimated' => array('type'=>'double', 'help'=>'THMOperatorEstimatedHelp','label'=>'THMOperatorEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1, 'css'=>'right'), - 'thm_machine_estimated' => array('type'=>'double', 'help'=>'THMMachineEstimatedHelp', 'label'=>'THMMachineEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1, 'css'=>'right'), + 'nb_operators_required' => array('type'=>'integer', 'label'=>'NbOperatorsRequired', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1, 'css'=>'right', 'csslist'=>'maxwidth75imp'), + 'thm_operator_estimated' => array('type'=>'double', 'help'=>'THMOperatorEstimatedHelp','label'=>'THMOperatorEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1, 'css'=>'right', 'csslist'=>'maxwidth75imp'), + 'thm_machine_estimated' => array('type'=>'double', 'help'=>'THMMachineEstimatedHelp', 'label'=>'THMMachineEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1, 'css'=>'right', 'csslist'=>'maxwidth75imp'), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>1, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled'),), ); public $rowid; diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 1dc7d42e72a..7d8f2d63eba 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -43,9 +43,16 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'workstationcard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha'); +$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); + +if (!empty($backtopagejsfields)) { + $tmpbacktopagejsfields = explode(':', $backtopagejsfields); + $dol_openinpopup = $tmpbacktopagejsfields[0]; +} $groups = GETPOST('groups', 'array:int'); $resources = GETPOST('resources', 'array:int'); @@ -56,7 +63,7 @@ $object = new Workstation($db); //$extrafields = new ExtraFields($db); $diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('workstationcard', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($object->element.'card', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -64,7 +71,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha')) { @@ -156,7 +163,10 @@ $form = new Form($db); $formfile = new FormFile($db); $formresource = new FormResource($db); -$title = $langs->trans("Workstation"); +$title = $langs->trans("Workstation")." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewObject", $langs->transnoentitiesnoconv("Workstation")); +} $help_url = 'EN:Module_Workstation'; llxHeader('', $title, $help_url); @@ -190,10 +200,14 @@ llxHeader('', $title, $help_url); // Part to create if ($action == 'create') { + if (empty($permissiontoadd)) { + accessforbidden('NotEnoughPermissions', 0, 1); + } + // Set default value of the property ref $object->fields['ref']['default'] = $object->getNextNumRef(); - print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Workstation")), '', 'object_'.$object->picto); + print load_fiche_titre($title, '', 'object_'.$object->picto); print ''; print ''; @@ -230,7 +244,7 @@ if ($action == 'create') { print ''; // Other attributes - //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print '
'.$langs->trans("PublicUrl").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); - print ''; + print ''; print '
'."\n"; @@ -283,7 +297,7 @@ if (($id || $ref) && $action == 'edit') { print ''; // Other attributes - //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; print ''; @@ -296,16 +310,15 @@ if (($id || $ref) && $action == 'edit') { // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); - $head = workstationPrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto); $formconfirm = ''; - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWorkstation'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + // Confirmation to delete (using preloaded confirm popup) + if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWorkstation'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 'action-delete'); } // Clone confirmation if ($action == 'clone') { @@ -341,38 +354,33 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref = '
'; /* // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300'); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= '
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + $morehtmlref .= '
'; + if ($permissiontoadd) { + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; + } + } + } + } } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ + */ $morehtmlref .= '
'; @@ -392,6 +400,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $object->fields['nb_operators_required']['visible'] = 0; } + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Groups @@ -446,28 +458,31 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Modify - if ($permissiontoadd) { - print ''.$langs->trans("Modify").''."\n"; - } else { - print ''.$langs->trans('Modify').''."\n"; - } + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); // Clone if ($permissiontoadd) { - print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=workstation', 'clone', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&token='.newToken(), '', $permissiontoadd); } // Disable / Enable if ($permissiontoadd) { if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; + print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd); } else { - print ''.$langs->trans("Enable").''."\n"; + print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd); } } - // Delete - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); + // Delete (with preloaded confirm popup) + $deleteUrl = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(); + $buttonId = 'action-delete-no-ajax'; + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can use preloaded confirm if not jmobile + $deleteUrl = ''; + $buttonId = 'action-delete'; + } + $params = array(); + print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $deleteUrl, $buttonId, $permissiontodelete, $params); } print '
'."\n"; } diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index c2339e59c7e..5ce13e79a81 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -36,18 +36,19 @@ global $conf, $db, $hookmanager, $langs, $user; // Load translation files required by the page $langs->loadLangs(array('mrp', 'other')); -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'workstationlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -84,7 +85,7 @@ if (!$sortorder) { } // Initialize array of search criterias -$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_all = trim(GETPOST('search_all', 'alphanohtml')); $search = array(); foreach ($object->fields as $key => $val) { @@ -129,7 +130,8 @@ $arrayfields['wug.fk_usergroup'] = array( 'checked'=>(($visible < 0) ? 0 : 1), 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), 'position'=>1000, - 'help' => empty($val['help']) ? '' : $val['help'] + 'help' => empty($val['help']) ? '' : $val['help'], + 'csslist' => 'minwidth100' ); /* disabled because adding resources to workstation seems not yet available in GUI @@ -214,8 +216,8 @@ $formresource = new FormResource($db); $now = dol_now(); -$help_url = 'EN:Module_Workstation'; $title = $langs->trans("Workstations"); +$help_url = 'EN:Module_Workstation'; $morejs = array(); $morecss = array(); @@ -232,9 +234,12 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -247,10 +252,10 @@ if (!empty($resources)) { } // Add table from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; + $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOST('search_current_entity', 'int') ? 0 : 1)).")"; } else { $sql .= " WHERE 1 = 1"; } @@ -302,7 +307,7 @@ if (!empty($resources)) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql.= " GROUP BY "; @@ -315,7 +320,7 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); } } -// Add where from hooks +// Add groupby from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -324,11 +329,19 @@ $sql = preg_replace('/,\s*$/', '', $sql); // Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* This old and fast method to get and count full list returns all record so use a high amount of memory. */ - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -351,10 +364,10 @@ $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { +if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/workstation/workstation_card.php?id='.$id); + header("Location: ".DOL_URL_ROOT.'/workstation/workstation_card.php?id='.((int) $id)); exit; } @@ -376,25 +389,29 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { if ($skey != '') { $param .= '&search_'.$key.'[]='.urlencode($skey); } } + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $param .= $hookmanager->resPrint; // List of mass actions available @@ -404,7 +421,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -423,9 +440,13 @@ print ''; print ''; print ''; print ''; +print ''; print ''; $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/workstation/workstation_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -438,9 +459,12 @@ $trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } + print ''."\n"; print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } @@ -450,7 +474,7 @@ $moreforfilter.= $langs->trans('MyFilter') . ': '; print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print ''; } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -474,15 +501,16 @@ print ''; +print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; } foreach ($object->fields as $key => $val) { + $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -490,15 +518,15 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; } @@ -536,11 +564,11 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -555,7 +583,7 @@ $totalarray['nbfield'] = 0; print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } foreach ($object->fields as $key => $val) { @@ -566,11 +594,12 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n"; $totalarray['nbfield']++; } } @@ -589,11 +618,11 @@ if (!empty($arrayfields['wr.fk_resource']['checked'])) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } print ''."\n"; @@ -614,6 +643,7 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar // -------------------------------------------------------------------- $i = 0; $savnbfield = $totalarray['nbfield']; +$totalarray = array(); $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { @@ -647,7 +677,7 @@ while ($i < $imaxinloop) { print ''; } } else { - // Show here line of result + // Show line of result $j = 0; print ''; // Action column @@ -674,18 +704,22 @@ while ($i < $imaxinloop) { } if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print '$key)) { + print ' title="'.dol_escape_htmltag($object->$key).'"'; + } + print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { @@ -726,7 +760,7 @@ while ($i < $imaxinloop) { $toprint[] = '
  • ' . $g->getNomUrl(1, '', 0, 'categtextwhite') . '
  • '; } - print '
    '; } @@ -745,7 +779,7 @@ while ($i < $imaxinloop) { $toprint[] = '
  • ' . $r->getNomUrl(1, '', '', 0, 'categtextwhite') . '
  • '; } - print ''; } @@ -754,7 +788,7 @@ while ($i < $imaxinloop) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { @@ -796,7 +830,7 @@ if ($num == 0) { $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
    '; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
    '; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -519,7 +547,7 @@ foreach ($object->fields as $key => $val) { // usergroups if (!empty($arrayfields['wug.fk_usergroup']['checked'])) { - print '
    '; + print ''; print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', '', $conf->entity, true); print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
    '; + print ''; print '
      ' . implode(' ', $toprint) . '
    '; print '
    '; + print ''; print '
      ' . implode(' ', $toprint) . '
    '; print '
    '."\n"; @@ -821,7 +855,7 @@ if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords $genallowed = $permissiontoread; $delallowed = $permissiontoadd; - print $formfile->showdocuments('massfilesarea_workstation', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page From 54f3e10d490b8f008d51d42c8e3c235357c664ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 10:27:09 +0100 Subject: [PATCH 182/315] Debug v19 --- .../workstation/class/workstation.class.php | 45 ++++++++++++++++++- htdocs/workstation/workstation_list.php | 2 +- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index 1249240c4ba..543ded86b6c 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -100,7 +100,7 @@ class Workstation extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object", 'csslist'=>'tdoverflowmax150'), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object", 'csslist'=>'nowraponall'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'showoncombobox'=>'2',), 'type' => array('type'=>'varchar(8)', 'label'=>'Type', 'enabled'=>'1', 'position'=>32, 'default'=>1, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('HUMAN'=>'Human', 'MACHINE'=>'Machine', 'BOTH'=>'HumanMachine'),), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), @@ -698,6 +698,49 @@ class Workstation extends CommonObject return $result; } + /** + * Return a thumb for kanban views + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $conf, $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + + $return = '
    '; + $return .= '
    '; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
    '; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if ($selected >= 0) { + $return .= ''; + } + if (property_exists($this, 'label')) { + $return .= '
    '.$this->label.'
    '; + } + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
    '.$this->thirdparty->getNomUrl(1).'
    '; + } + if (property_exists($this, 'amount')) { + $return .= '
    '; + $return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
    '.$this->getLibStatut(3).'
    '; + } + $return .= '
    '; + $return .= '
    '; + $return .= '
    '; + + return $return; + } + /** * Return the label of the status * diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 5ce13e79a81..4667af3ac8c 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -660,7 +660,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { - print ''; + print ''; print '
    '; } // Output Kanban From 34f05d0ff9124810db5ac8c624bf61bf873a38d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 10:43:19 +0100 Subject: [PATCH 183/315] Debug v19 - remove version check of ckeditor --- htdocs/core/class/doleditor.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index cef35c3ed27..00e4b72d721 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -195,6 +195,7 @@ class DolEditor /* property:xxx is same than CKEDITOR.config.property = xxx */ customConfig: ckeditorConfig, removePlugins: \''.dol_escape_js($pluginstodisable).'\', + versionCheck: false, readOnly: '.($this->readonly ? 'true' : 'false').', htmlEncodeOutput: '.dol_escape_js($htmlencode_force).', allowedContent: '.($disallowAnyContent ? 'false' : 'true').', /* Advanced Content Filter (ACF) is own when allowedContent is false */ From 15242875f45c884ec3f86fbc698bdd732e396523 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 11:01:49 +0100 Subject: [PATCH 184/315] Debug v19 --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 035cc7784ed..65e2954c0e3 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -175,7 +175,7 @@ if ($filtertype != 1) { print ''; $coldisplay++; if ($res > 0) { - echo $workstation->getNomUrl(); + echo $workstation->getNomUrl(1); } print ''; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5410c6ce42f..f9978431628 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3619,7 +3619,7 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { .tabactive, a.tab#active { color: var(--colortextbacktab) !important; - background: var(--colorbacktabcard1) !important; + /* background: var(--colorbacktabcard1) !important; */ margin: 0 0.2em 0 0.2em !important; border-right: 1px solid transparent; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 866343ddee6..0de3f4d9706 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4053,7 +4053,7 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-bottom-color: #BBB; border-bottom-style: solid; - margin: 0px 0px 15px 0px; + margin: 0px 0px 20px 0px; -webkit-border-radius: 0.1em; border-radius: 0.1em; From 5870e62fce529a3931426cbf245975b715028ff1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 12:33:19 +0100 Subject: [PATCH 185/315] Debug v19 --- htdocs/bom/bom_card.php | 4 +- htdocs/core/actions_addupdatedelete.inc.php | 2 +- htdocs/langs/en_US/mrp.lang | 2 + htdocs/mrp/class/mo.class.php | 11 ++--- htdocs/mrp/mo_card.php | 1 + htdocs/mrp/mo_production.php | 51 +++++++++++++-------- htdocs/mrp/tpl/originproductline.tpl.php | 28 +++++++---- htdocs/product/class/product.class.php | 36 +++++++++------ htdocs/theme/eldy/global.inc.php | 7 +-- htdocs/theme/md/style.css.php | 1 + 10 files changed, 89 insertions(+), 54 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 816ad0190a8..f375004b4a4 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -590,7 +590,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); - print '
    + print ' @@ -642,7 +642,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); - print ' + print ' diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 8adc3d1f886..754e3eceda3 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -95,7 +95,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { } elseif ($object->fields[$key]['type'] == 'datetime') { $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel'); } elseif ($object->fields[$key]['type'] == 'duration') { - $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int'); + $value = 60 * 60 * GETPOSTINT($key.'hour') + 60 * GETPOSTINT($key.'min'); } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 935995ea3ae..948bff00757 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -65,6 +65,8 @@ ToProduce=To produce ToObtain=To obtain QtyAlreadyConsumed=Qty already consumed QtyAlreadyProduced=Qty already produced +QtyAlreadyConsumedShort=Qty consumed +QtyAlreadyProducedShort=Qty produced QtyRequiredIfNoLoss=Qty required to produce the quantity defined into the BOM if there is no loss (if the manufacturing efficiency is 100%%) ConsumeOrProduce=Consume or Produce ConsumeAndProduceAll=Consume and Produce All diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 476abd4ede8..d1d7523acd9 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1757,19 +1757,18 @@ class Mo extends CommonObject */ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array()) { - global $langs, $conf; + $productstatic = new Product($this->db); $this->tpl['id'] = $line->id; $this->tpl['label'] = ''; - if (!empty($line->fk_product)) { - $productstatic = new Product($this->db); + if (!empty($line->fk_product) && $line->fk_product > 0) { $productstatic->fetch($line->fk_product); $productstatic->load_virtual_stock(); $this->tpl['label'] .= $productstatic->getNomUrl(1); //$this->tpl['label'].= ' - '.$productstatic->label; } else { - // If origin MRP line is not a product, but another MRP + // If origin MO line is not a product, but another MO // TODO } @@ -1787,8 +1786,8 @@ class Mo extends CommonObject $this->tpl['disable_stock_change'] = $line->disable_stock_change; $this->tpl['efficiency'] = $line->efficiency; - $tpl = DOL_DOCUMENT_ROOT.'/mrp/tpl/originproductline.tpl.php'; - $res = include $tpl; + global $conf; // used into template + $res = include DOL_DOCUMENT_ROOT.'/mrp/tpl/originproductline.tpl.php'; } /** diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 7dcfec9e805..441e0d79bf7 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -428,6 +428,7 @@ if ($action == 'create') { if ($objectbom->id > 0) { print load_fiche_titre($titlelist); + print ''."\n"; print '
    '; print ''; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 0f2bbd9bce4..9fb66eb916d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -25,20 +25,20 @@ // Load Dolibarr environment require '../main.inc.php'; - +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/mrp/class/mo.class.php'); -dol_include_once('/mrp/lib/mrp_mo.lib.php'); // Load translation files required by the page $langs->loadLangs(array("mrp", "stocks", "other", "product", "productbatch")); @@ -848,12 +848,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } // Qty already consumed - print ''; + print ''; // Warehouse print ''; // Unit if ($conf->global->PRODUCT_USE_UNITS) { @@ -1041,24 +1043,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Stock print ''; - // Batch - print ''; + // Batch + /* + print ''; + */ + // Action delete line - print ''; // Action delete line if ($permissiontodelete) { - print ''; + print ''; } print ''; print ''; @@ -1140,11 +1147,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ' ' . price2num($alreadyconsumed, 'MS'); print ''; - // Warehouse + // Warehouse and/or workstation print ''; // Stock if (isModEnabled('stock')) { @@ -1402,6 +1414,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea });'; } + // Lines to produce print ''; @@ -1448,7 +1461,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } // Already produced - print ''; + print ''; // Warehouse print ''; print ''; // Unit print ''; -print ''; -print ''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ac36d79fc05..bf930472395 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6140,7 +6140,7 @@ class Product extends CommonObject } /** - * Return if object is a product + * Return if object is a product. * * @return boolean True if it's a product */ @@ -6159,6 +6159,15 @@ class Product extends CommonObject return ($this->type == Product::TYPE_SERVICE ? true : false); } + /** + * Return if object need to have its stock managed + * + * @return boolean True if it's a service + */ + public function isStockManaged() + { + return ($this->isProduct() || getDolGlobalString('STOCK_SUPPORTS_SERVICES')); + } /** * Return if object have a constraint on mandatory_period @@ -6169,6 +6178,18 @@ class Product extends CommonObject { return ($this->mandatory_period == 1 ? true : false); } + + /** + * Return if object has a sell-by date or eat-by date + * + * @return boolean True if it's has + */ + public function hasbatch() + { + return ($this->status_batch > 0 ? true : false); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get a barcode from the module to generate barcode values. @@ -6211,8 +6232,6 @@ class Product extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf, $mysoc; - $now = dol_now(); // Initialize parameters @@ -6285,17 +6304,6 @@ class Product extends CommonObject } } - /** - * Return if object has a sell-by date or eat-by date - * - * @return boolean True if it's has - */ - public function hasbatch() - { - return ($this->status_batch > 0 ? true : false); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return minimum product recommended price diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index f9978431628..c6873a66ec2 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1638,9 +1638,10 @@ maxscreenheightless200 { .clearboth { clear:both; } .hideobject { display: none; } -.minwidth25 { min-width: 25px; } -.minwidth50 { min-width: 50px; } -.minwidth75 { min-width: 75px; } +.minwidth25 { min-width: 25px; } +.minwidth50 { min-width: 50px; } +.minwidth75 { min-width: 75px; } +.nominwidth { min-width: fit-content !important; } /* rule for not too small screen only */ @media only screen and (min-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0de3f4d9706..19dec5d2392 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1875,6 +1875,7 @@ tr.nobottom td { .minwidth25 { min-width: 25px; } .minwidth50 { min-width: 50px; } .minwidth75 { min-width: 75px; } +.nominwidth { min-width: fit-content !important; } /* rule for not too small screen only */ @media only screen and (min-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) { From 8874ef84545dea92a1e60891723012c9531837fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 18:47:38 +0100 Subject: [PATCH 186/315] Debug v19 --- htdocs/core/db/mysqli.class.php | 2 +- htdocs/core/db/pgsql.class.php | 2 +- htdocs/core/db/sqlite3.class.php | 2 +- phpstan.neon | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 6d1a43c7908..cb7d98b04ab 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -49,7 +49,7 @@ class DoliDBMysqli extends DoliDB * Constructor. * This create an opened connexion to a database server and eventually to a database * - * @param string $type Type of database (mysql, pgsql...) + * @param string $type Type of database (mysql, pgsql...). Not used. * @param string $host Address of database server * @param string $user Name of database user * @param string $pass Password of database user diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 12e29d949c3..566cccf332a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -69,7 +69,7 @@ class DoliDBPgsql extends DoliDB * Constructor. * This create an opened connexion to a database server and eventually to a database * - * @param string $type Type of database (mysql, pgsql...) + * @param string $type Type of database (mysql, pgsql...). Not used. * @param string $host Address of database server * @param string $user Nom de l'utilisateur autorise * @param string $pass Mot de passe diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 41c1c021525..c6eeb736325 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -53,7 +53,7 @@ class DoliDBSqlite3 extends DoliDB * Constructor. * This create an opened connexion to a database server and eventually to a database * - * @param string $type Type of database (mysql, pgsql...) + * @param string $type Type of database (mysql, pgsql...). Not used. * @param string $host Address of database server * @param string $user Nom de l'utilisateur autorise * @param string $pass Mot de passe diff --git a/phpstan.neon b/phpstan.neon index a898f05f524..1562b13e1e2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -50,27 +50,28 @@ parameters: - '#Undefined variable: \$errors#' - '#Undefined variable: \$form#' - '#has an unused parameter \$param#' - - '#Result of function fieldList#' - - '#Caught class Stripe#' - '#Function llxHeader invoked with#' - '#Function llxHeaderVierge invoked with#' - '#Function llxFooter invoked with#' - '#Function llxFooterVierge invoked with#' - '#If condition is always true#' - '#always exists and is not falsy#' - - '#has no return type specified#' - '#is always true#' - '#is always fal#' + - '#has no return type specified#' - '#always exists and is not nullable#' - '#PHPDoc tag @return has invalid value#' - '#type has no value type specified in iterable type array#' - '#with no value type specified in iterable type array#' - '#Empty array passed to foreach#' + - '#Result of function fieldList#' - '#in isset\(\) is not nullable#' - '#in isset\(\) is never defined#' - '#(\$force_dolibarr_lib|\$dolibarr_main_db).*in empty\(\) is never defined.#' + - '#Caught class Stripe#' - '#Sprain\\SwissQrBill\\#' - '#Constructor of class DolEditor has an unused parameter \$toolbarlocation#' + - '#Constructor of class DoliDB\w+ has an unused parameter $type#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 From 7bb32a04b4c0257ed7ee057a396472fc57d55229 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 19:33:51 +0100 Subject: [PATCH 187/315] Fix warnings --- .../rector/src/Renaming/GlobalToFunction.php | 2 +- htdocs/accountancy/bookkeeping/export.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- .../accountancy/bookkeeping/listbyaccount.php | 2 +- .../class/accountancyexport.class.php | 18 +++------ .../class/accountingjournal.class.php | 6 +-- htdocs/accountancy/customer/index.php | 38 +++++++++---------- htdocs/accountancy/customer/lines.php | 4 +- htdocs/accountancy/customer/list.php | 4 +- htdocs/accountancy/expensereport/index.php | 26 ++++++------- htdocs/accountancy/expensereport/lines.php | 4 +- htdocs/accountancy/expensereport/list.php | 4 +- htdocs/accountancy/journal/bankjournal.php | 7 ++-- .../journal/expensereportsjournal.php | 10 ++--- htdocs/accountancy/supplier/index.php | 28 +++++++------- htdocs/accountancy/supplier/lines.php | 4 +- htdocs/accountancy/supplier/list.php | 6 +-- 17 files changed, 80 insertions(+), 87 deletions(-) diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index f81f2ee34c1..0c0cd9c7cc8 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -103,7 +103,7 @@ class GlobalToFunction extends AbstractRector if ($node instanceof FuncCall) { $tmpfunctionname = $this->getName($node); - // If function is ok(we must avoid a lot of cases like isset, empty) + // If function is ok. We must avoid a lot of cases like isset(), empty() if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) { $args = $node->getArgs(); $nbofparam = count($args); diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index b6f21694a4f..0d4b02386e1 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -134,7 +134,7 @@ $search_lettering_code = GETPOST('search_lettering_code', 'alpha'); $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 4efa16fcbde..7a10c5d96d6 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -129,7 +129,7 @@ $search_lettering_code = GETPOST('search_lettering_code', 'alpha'); $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 8143cee2434..51b37ce6651 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -104,7 +104,7 @@ if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_ } // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 7573dbee9f4..e372ab9c206 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -103,7 +103,7 @@ class AccountancyExport $this->db = $db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $this->end_line = !getDolGlobalString('ACCOUNTING_EXPORT_ENDLINE') ? "\n" : (getDolGlobalInt('ACCOUNTING_EXPORT_ENDLINE') == 1 ? "\n" : "\r\n"); + $this->end_line = getDolGlobalString('ACCOUNTING_EXPORT_ENDLINE') ? (getDolGlobalInt('ACCOUNTING_EXPORT_ENDLINE') == 1 ? "\n" : "\r\n") : "\n"; $hookmanager->initHooks(array('accountancyexport')); } @@ -201,9 +201,9 @@ class AccountancyExport 'param' => array( self::$EXPORT_TYPE_CONFIGURABLE => array( 'label' => $langs->trans('Modelcsv_configurable'), - 'ACCOUNTING_EXPORT_FORMAT' => !getDolGlobalString('ACCOUNTING_EXPORT_FORMAT') ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT, - 'ACCOUNTING_EXPORT_SEPARATORCSV' => !getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV') ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV, - 'ACCOUNTING_EXPORT_ENDLINE' => !getDolGlobalString('ACCOUNTING_EXPORT_ENDLINE') ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE, + 'ACCOUNTING_EXPORT_FORMAT' => getDolGlobalString('ACCOUNTING_EXPORT_FORMAT', 'txt'), + 'ACCOUNTING_EXPORT_SEPARATORCSV' => getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV', ','), + 'ACCOUNTING_EXPORT_ENDLINE' => getDolGlobalString('ACCOUNTING_EXPORT_ENDLINE', 1), 'ACCOUNTING_EXPORT_DATE' => getDolGlobalString('ACCOUNTING_EXPORT_DATE', '%Y-%m-%d'), ), self::$EXPORT_TYPE_CEGID => array( @@ -839,8 +839,6 @@ class AccountancyExport $end_line = "\r\n"; // We should use dol_now function not time however this is wrong date to transfert in accounting - // $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy - // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ($objectLines as $line) { // Clean some data $line->doc_ref = dol_string_unaccent($line->doc_ref); @@ -938,7 +936,6 @@ class AccountancyExport // Force date format : %d%m%y if (!empty($line->date_lim_reglement)) { - //$tab['date_echeance'] = dol_print_date($line->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE); $tab['date_echeance'] = dol_print_date($line->date_lim_reglement, '%d%m%y'); // Format must be ddmmyy } else { $tab['date_echeance'] = '000000'; @@ -1061,10 +1058,6 @@ class AccountancyExport $end_line = "\r\n"; $index = 1; - //We should use dol_now function not time however this is wrong date to transfert in accounting - //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy - //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy - // Warning ! When truncation is necessary, no dot because 3 dots = three characters. The columns are shifted foreach ($objectLines as $line) { @@ -1109,7 +1102,6 @@ class AccountancyExport $tab['code_stat'] = str_repeat(' ', 4); if (!empty($line->date_lim_reglement)) { - //$tab['date_echeance'] = dol_print_date($line->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE); $tab['date_echeance'] = dol_print_date($line->date_lim_reglement, '%d%m%Y'); } else { $tab['date_echeance'] = dol_print_date($line->doc_date, '%d%m%Y'); @@ -1276,7 +1268,7 @@ class AccountancyExport $separator = $this->separator; foreach ($objectLines as $line) { - $date_document = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + $date_document = dol_print_date($line->doc_date, getDolGlobalString('ACCOUNTING_EXPORT_DATE')); $tab = array(); // export configurable diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 1d475b67527..0e3dc913917 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -470,7 +470,7 @@ class AccountingJournal extends CommonObject } // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; + $sql .= " AND ad.depreciation_date >= '" . $this->db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) . "'"; } $sql .= " ORDER BY ad.depreciation_date"; @@ -616,12 +616,12 @@ class AccountingJournal extends CommonObject $disposal_date = $pre_data_info['disposal']['date']; if ((!($date_start && $date_end) || ($date_start <= $disposal_date && $disposal_date <= $date_end)) && - (!getDolGlobalString('ACCOUNTING_DATE_START_BINDING') || $conf->global->ACCOUNTING_DATE_START_BINDING <= $disposal_date) + (!getDolGlobalString('ACCOUNTING_DATE_START_BINDING') || getDolGlobalInt('ACCOUNTING_DATE_START_BINDING') <= $disposal_date) ) { $disposal_amount = $pre_data_info['disposal']['amount']; $disposal_subject_to_vat = $pre_data_info['disposal']['subject_to_vat']; $disposal_date_formatted = dol_print_date($disposal_date, 'day'); - $disposal_vat = getDolGlobalInt('ASSET_DISPOSAL_VAT') > 0 ? $conf->global->ASSET_DISPOSAL_VAT : 20; + $disposal_vat = getDolGlobalInt('ASSET_DISPOSAL_VAT') > 0 ? getDolGlobalInt('ASSET_DISPOSAL_VAT') : 20; // Get accountancy codes //--------------------------- diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0551a3fe95a..5bfa1435df6 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -329,7 +329,7 @@ print '
    '.$langs->trans("UnitCost").''.$langs->trans("QtyAlreadyConsumed").''.$form->textwithpicto($langs->trans("QtyAlreadyConsumedShort"), $langs->trans("QtyAlreadyConsumed")).''; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print $langs->trans("Warehouse"); - + if (isModEnabled('workstation')) { + print ' '.$langs->trans("or").' '.$langs->trans("Workstation"); + } // Select warehouse to force it everywhere if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { $listwarehouses = $tmpwarehouse->list_array(1); @@ -1024,7 +1026,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''; - print ''; + print ''; print ''; - if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { - print img_warning($langs->trans('StockTooLow')).' '; + if ($tmpproduct->isStockManaged()) { + if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { + print img_warning($langs->trans('StockTooLow')).' '; + } + print ''. $tmpproduct->stock_reel .' '; } - print ''. $tmpproduct->stock_reel .' '; - print ''; print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
    '; if (getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) { print img_picto('', $tmpwarehouse->picto) . " " . $tmpwarehouse->label; } + if (isModEnabled('workstation') && $line->fk_default_workstation > 0) { + $tmpworkstation = new Workstation($db); + $tmpworkstation->fetch($line->fk_default_workstation); + print $tmpworkstation->getNomUrl(1); + } print ''.$langs->trans("QtyAlreadyProduced").''.$form->textwithpicto($langs->trans("QtyAlreadyProducedShort"), $langs->trans("QtyAlreadyProduced")).''; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 3a9c031a1ae..50eba62dba6 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -22,7 +22,7 @@ if (empty($conf) || !is_object($conf)) { exit; } -global $db; +global $db, $langs; if (!empty($form) && !is_object($form)) { $form = new Form($db); @@ -35,9 +35,13 @@ $qtytoconsumeforline = $this->tpl['qty'] / (!empty($this->tpl['efficiency']) ? $ $qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS'); $tmpproduct = new Product($db); -$tmpproduct->fetch($line->fk_product); +if ($line->fk_product > 0) { + $tmpproduct->fetch($line->fk_product); +} $tmpbom = new BOM($db); -$res = $tmpbom->fetch($line->fk_bom_child); +if ($line->fk_bom_child > 0) { + $res = $tmpbom->fetch($line->fk_bom_child); +} ?> @@ -63,14 +67,20 @@ print ''.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').''.measuringUnitString($this->tpl['fk_unit'], '', '', 1).''.(empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS')); -if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) { - print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte'])); +print ''; +if ($tmpproduct->isStockManaged()) { + print (empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS')); + if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) { + print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte'])); + } } print ''.((empty($this->tpl['virtual_stock']) ? 0 : price2num($this->tpl['virtual_stock'], 'MS'))); -if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['virtual_stock'] < $this->tpl['seuil_stock_alerte'])) { - print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte'])); +print ''; +if ($tmpproduct->isStockManaged()) { + print ((empty($this->tpl['virtual_stock']) ? 0 : price2num($this->tpl['virtual_stock'], 'MS'))); + if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['virtual_stock'] < $this->tpl['seuil_stock_alerte'])) { + print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte'])); + } } print ''.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').'
    '; print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -337,7 +337,7 @@ for ($i = 1; $i <= 12; $i++) { if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '' $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -405,27 +405,27 @@ if ($resql) { print ''; print ''; for ($i = 2; $i <= 13; $i++) { - $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2); if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '
    '.$langs->trans("Account").''.$langs->trans("Label").''; @@ -357,7 +357,7 @@ print ''.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { - $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if ($startmonth > 12) { $startmonth -= 12; } - $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; - $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + $startyear = ($startmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; + $endmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + 11; if ($endmonth > 12) { $endmonth -= 12; } - $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endyear = ($endmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; @@ -466,7 +466,7 @@ print ''; print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -474,7 +474,7 @@ for ($i = 1; $i <= 12; $i++) { if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '' $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -551,11 +551,11 @@ if ($resql) { print ''; for ($i = 2; $i <= 13; $i++) { - $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2); if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '
    '.$langs->trans("Account").''.$langs->trans("Label").''; @@ -494,7 +494,7 @@ print ''.$langs->trans("Total").'
    '; @@ -590,7 +590,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -600,7 +600,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql = "SELECT '".$db->escape($langs->trans("TotalVente"))."' AS total,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -650,7 +650,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa print '
    '.$langs->trans("TotalVente").'
    '; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -662,7 +662,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa // With old situation invoice setup $sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -684,7 +684,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa } else { $sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index aad7c00f46c..4929b45ac67 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -65,7 +65,7 @@ $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -506,7 +506,7 @@ if ($result) { print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 3e312a220ef..26d3c32b512 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -80,7 +80,7 @@ if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDI } // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -660,7 +660,7 @@ if ($result) { // Description of line print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 1382eaf5ac6..5c2ca5d52bf 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -204,7 +204,7 @@ print '
    '.$langs->trans("TotalMarge").''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1)); - $trunclength = !getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION') ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($facture_static_det->desc, 1)); - $trunclength = !getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION') ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc); print '
    '; print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -212,7 +212,7 @@ for ($i = 1; $i <= 12; $i++) { if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '' $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -271,27 +271,27 @@ if ($resql) { print ''; print ''; for ($i = 2; $i <= 13; $i++) { - $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2); if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '
    '.$langs->trans("Account").''.$langs->trans("Label").''; @@ -233,7 +233,7 @@ print ''.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { - $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if ($startmonth > 12) { $startmonth -= 12; } - $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; - $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + $startyear = ($startmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; + $endmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + 11; if ($endmonth > 12) { $endmonth -= 12; } - $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endyear = ($endmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; @@ -333,7 +333,7 @@ print ''; print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -344,7 +344,7 @@ print '' $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -421,7 +421,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa print '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans("Total").'
    '; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -431,7 +431,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 2f9c4e70e8e..998992dc3cd 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -59,7 +59,7 @@ $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_s $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -414,7 +414,7 @@ if ($result) { // Fees description -- Can be null print ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index a1d405f5725..e22581aebde 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -73,7 +73,7 @@ if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDI } // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -489,7 +489,7 @@ if ($result) { // Fees description -- Can be null print ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 5d80232d51d..11c00917743 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1305,7 +1305,7 @@ if (empty($action) || $action == 'view') { if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { $accounttoshow = ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').''; } else { - $accounttoshow = ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account + $accounttoshow = ''.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).''; // We will use a waiting account } } else { // We will refuse writing @@ -1396,7 +1396,8 @@ if (empty($action) || $action == 'view') { { print ''.$langs->trans("WaitAccountNotDefined").''; } - else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + else */ + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); print ""; // Subledger account print ""; - print ""; + print ""; print '"; print '"; print '"; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index fb86cdc3505..e553be8e1bb 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -162,8 +162,8 @@ if ($result) { $num = $db->num_rows($result); // Variables - $account_salary = (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT')) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; - $account_vat = (getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT')) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; + $account_salary = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); + $account_vat = getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT', 'NotDefined'); $i = 0; while ($i < $num) { @@ -247,7 +247,7 @@ if ($action == 'writebookkeeping' && !$error) { $error = 0; $accountingaccountexpense = new AccountingAccount($db); - $accountingaccountexpense->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true); + $accountingaccountexpense->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); foreach ($taber as $key => $val) { // Loop on each expense report $errorforline = 0; @@ -279,7 +279,7 @@ if ($action == 'writebookkeeping' && !$error) { $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); $bookkeeping->label_compte = $accountingaccountexpense->label; $bookkeeping->label_operation = $tabuser[$key]['name']; @@ -726,7 +726,7 @@ if (empty($action) || $action == 'view') { print ""; // Account print "
    '.$langs->trans("Total").''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1)); - $trunclength = !getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION') ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION', 32); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1)); - $trunclength = !getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION') ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print '"; @@ -1407,7 +1408,7 @@ if (empty($action) || $action == 'view') { else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); */ print "".$reflabel."".dol_escape_htmltag($reflabel)."'.$val["type_payment"]."'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."".$expensereportstatic->getNomUrl(1).""; - $accountoshow = length_accountg($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT); + $accountoshow = length_accountg(getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT')); if (($accountoshow == "") || $accountoshow == 'NotDefined') { print ''.$langs->trans("MainAccountForUsersNotDefined").''; } else { diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index a8181885c3a..6c91aa09a95 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -322,7 +322,7 @@ print ''; print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -330,7 +330,7 @@ for ($i = 1; $i <= 12; $i++) { if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '' $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -393,27 +393,27 @@ if ($resql) { print ''; print ''; for ($i = 2; $i <= 13; $i++) { - $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2); if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '
    '.$langs->trans("Account").''.$langs->trans("Label").''; @@ -350,7 +350,7 @@ print ''.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { - $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if ($startmonth > 12) { $startmonth -= 12; } - $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; - $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + $startyear = ($startmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; + $endmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + 11; if ($endmonth > 12) { $endmonth -= 12; } - $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endyear = ($endmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; @@ -454,7 +454,7 @@ print ''; print ''; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -462,7 +462,7 @@ for ($i = 1; $i <= 12; $i++) { if ($cursormonth > 12) { $cursormonth -= 12; } - $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); print '' $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -566,7 +566,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa print '
    '.$langs->trans("Account").''.$langs->trans("Label").''; @@ -482,7 +482,7 @@ print ''.$langs->trans("Total").'
    '; print ''; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } @@ -576,7 +576,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql = "SELECT '".$db->escape($langs->trans("CAHTF"))."' AS label,"; for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { $j -= 12; } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index ac35e048744..480c18f1c25 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -67,7 +67,7 @@ $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -536,7 +536,7 @@ if ($result) { print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 6573f18503f..17f87eec351 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -77,7 +77,7 @@ $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -119,7 +119,7 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { // Define begin binding date if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING); + $search_date_start = $db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING')); } @@ -687,7 +687,7 @@ if ($result) { // Description of line print ''; From 07f4c9b3357dcc05b65fd0a94b800dfd67c9dd7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 19:47:10 +0100 Subject: [PATCH 188/315] Fix warnings --- htdocs/admin/eventorganization.php | 4 ++-- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/hrm.php | 4 ++-- htdocs/admin/knowledgemanagement.php | 2 +- htdocs/admin/modules.php | 2 +- htdocs/admin/webhook.php | 8 ++++---- htdocs/admin/workstation.php | 2 +- htdocs/api/class/api_setup.class.php | 2 +- htdocs/asset/admin/setup.php | 2 +- htdocs/bookcal/admin/setup.php | 2 +- htdocs/core/lib/functions2.lib.php | 3 +-- htdocs/product/admin/product.php | 2 +- htdocs/recruitment/admin/setup.php | 2 +- htdocs/recruitment/admin/setup_candidatures.php | 2 +- htdocs/takepos/index.php | 2 +- htdocs/takepos/invoice.php | 7 ++++--- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index c9991c07a38..7e1b74e336e 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -154,7 +154,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } @@ -279,7 +279,7 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); $form->select_produits($selected, $constname, '', 0); } } else { diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 64dc930e5e9..92a235fc178 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -173,7 +173,7 @@ if (empty($conf->use_javascript_ajax)) { } print ''; print ''; print ''."\n"; } diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 83e8c3f8dbf..7dd152fa3d1 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -247,7 +247,7 @@ if ($resql) { //print "x".$idrss; $rssparser = new RssParser($db); - $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); + $result = $rssparser->parser(getDolGlobalString($keyrssurl), 5, 300, $conf->externalrss->dir_temp); print "
    "; print ''."\n"; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 5e5fd8fb9c0..374685624ba 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -102,7 +102,7 @@ if ($action == 'setvalue' && $user->admin) { $valkey = ''; $key = GETPOST("key"); if ($key) { - $valkey = $conf->global->$key; + $valkey = getDolGlobalString($key); } if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) { $error++; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 878a6c6029a..36ef3b7ad7c 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -79,7 +79,7 @@ if ($action == 'setvalue' && $user->admin) { $valkey = ''; $key = GETPOST("key"); if ($key) { - $valkey = $conf->global->$key; + $valkey = getDolGlobalString($key); } if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) { $error++; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index f7a4af5d2fd..2047cb983ca 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -147,7 +147,7 @@ if ($action == 'setvalue' && $user->admin) { $valkey = ''; $key = GETPOST("key"); if ($key) { - $valkey = $conf->global->$key; + $valkey = getDolGlobalString($key); } if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) { $error++; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 9c7a517bb1f..26af5ba9191 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -73,7 +73,7 @@ if ($action == 'setvalue' && $user->admin) { $valkey = ''; $key = GETPOST("key"); if ($key) { - $valkey = $conf->global->$key; + $valkey = getDolGlobalString($key); } if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) { $error++; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index d2c287aef78..54863009e0d 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -135,7 +135,7 @@ if ($action == 'setvalue' && $user->admin) { $valkey = ''; $key = GETPOST("key"); if ($key) { - $valkey = $conf->global->$key; + $valkey = getDolGlobalString($key); } if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) { $error++; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 78765aae04e..2a401df047e 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -453,7 +453,7 @@ foreach ($listofnotifiedevents as $notifiedevent) { } $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; - $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ? GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; + $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ? GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : getDolGlobalString($param); $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. $arrayemail = explode(',', $value); @@ -464,7 +464,7 @@ foreach ($listofnotifiedevents as $notifiedevent) { $showwarning++; } } - if ((!empty($conf->global->$param)) && $showwarning) { + if (getDolGlobalString($param) && $showwarning) { $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); } print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
    '.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 30950eae177..26ee5a374f5 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -367,7 +367,7 @@ for ($i = 1; $i <= 6; $i++) { if ($conf->use_javascript_ajax) { print ajax_constantonoff($keyforconstant); } else { - print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); + print $form->selectyesno($keyforconstant, getDolGlobalString($keyforconstant, 0), 1, $noCountryCode); } print ''; } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 88d590ffc35..a3d5871840b 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -232,8 +232,8 @@ foreach ($syslogModules as $moduleName) { if (!empty($tmpoption)) { if (GETPOSTISSET($tmpoption)) { $value = GETPOST($tmpoption); - } elseif (!empty($conf->global->$tmpoption)) { - $value = $conf->global->$tmpoption; + } elseif (getDolGlobalString($tmpoption)) { + $value = getDolGlobalString($tmpoption); } } else { $value = (isset($option['default']) ? $option['default'] : ''); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index f5ff8ecea9a..4d7d3965a90 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -315,7 +315,7 @@ foreach ($workflowcodes as $key => $params) { if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff($key); } else { - if (!empty($conf->global->$key)) { + if (getDolGlobalString($key)) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 370f407a1de..09837376096 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -2037,8 +2037,8 @@ class Setup extends DolibarrApi $xmlremote = $conf->global->MAIN_FILECHECK_URL; } $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; - if (empty($xmlremote) && !empty($conf->global->$param)) { - $xmlremote = $conf->global->$param; + if (empty($xmlremote) && getDolGlobalString($param)) { + $xmlremote = getDolGlobalString($param); } if (empty($xmlremote)) { $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4737ff0d9d4..c3b53faccae 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -538,8 +538,8 @@ if ($object->id > 0) { print '"; print ''; diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index fe6c733713b..d2729885b96 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -110,8 +110,8 @@ if ($_socid > 0) { } print '>'.$i; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; - if (!empty($conf->global->$keyforlabel)) { - print ' - '.$langs->trans($conf->global->$keyforlabel); + if (getDolGlobalString($keyforlabel)) { + print ' - '.$langs->trans(getDolGlobalString($keyforlabel)); } print ''; } diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index e702e05ea2c..b8a062c0111 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -281,10 +281,10 @@ if ($resql) { } $transactionspertype[$objp->code] += 1; } else { - if ($conf->global->$var1 == $bankaccount->id) { + if (getDolGlobalString($var1) == $bankaccount->id) { $cash += $objp->amount; - // } elseif ($conf->global->$var2 == $bankaccount->id) $bank+=$objp->amount; - //elseif ($conf->global->$var3 == $bankaccount->id) $cheque+=$objp->amount; + // } elseif (getDolGlobalString($var2) == $bankaccount->id) $bank+=$objp->amount; + //elseif (getDolGlobalString($var3) == $bankaccount->id) $cheque+=$objp->amount; if (empty($transactionspertype['CASH'])) { $transactionspertype['CASH'] = 0; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b819569d041..ba3707fd1bf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3925,9 +3925,9 @@ if ($action == 'create') { if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf $paramkey = 'FACTURE_ADDON_PDF_'.$object->type; - $preselected = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF; + $preselected = getDolGlobalString($paramkey, getDolGlobalString('FACTURE_ADDON_PDF')); } else { - $preselected = $conf->global->FACTURE_ADDON_PDF; + $preselected = getDolGlobalString('FACTURE_ADDON_PDF'); } print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); print ""; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index dad469a8eea..de73c07b98a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1689,10 +1689,10 @@ class Facture extends CommonInvoice $modelByTypeConfName = 'FACTURE_ADDON_PDF_' . $deposit->type; - if (!empty($conf->global->$modelByTypeConfName)) { - $deposit->model_pdf = $conf->global->$modelByTypeConfName; + if (getDolGlobalString($modelByTypeConfName)) { + $deposit->model_pdf = getDolGlobalString($modelByTypeConfName); } elseif (getDolGlobalString('FACTURE_ADDON_PDF')) { - $deposit->model_pdf = $conf->global->FACTURE_ADDON_PDF; + $deposit->model_pdf = getDolGlobalString('FACTURE_ADDON_PDF'); } if (!getDolGlobalString('MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN')) { @@ -3270,7 +3270,7 @@ class Facture extends CommonInvoice // Check for mandatory $keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; - if (!$vallabel && !empty($conf->global->$keymandatory)) { + if (!$vallabel && getDolGlobalString($keymandatory)) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); @@ -5219,8 +5219,8 @@ class Facture extends CommonInvoice if (!empty($this->model_pdf)) { $modele = $this->model_pdf; - } elseif (!empty($conf->global->$thisTypeConfName)) { - $modele = $conf->global->$thisTypeConfName; + } elseif (getDolGlobalString($thisTypeConfName)) { + $modele = getDolGlobalString($thisTypeConfName); } elseif (getDolGlobalString('FACTURE_ADDON_PDF')) { $modele = $conf->global->FACTURE_ADDON_PDF; } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 6e06696b6a1..f9cbe577064 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -111,7 +111,7 @@ if (empty($reshook)) { */ if ($action == 'create' && $permissiontocreate) { $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); - //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit; + //var_dump($default_account);var_dump(getDolGlobalString($default_account));var_dump($id_bankaccount);exit; if ($id_bankaccount != getDolGlobalInt($default_account)) { $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 2e4c87c8e2b..f8b7e424a0d 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -89,7 +89,7 @@ class box_external_rss extends ModeleBoxes $keyforparamtitle = "EXTERNAL_RSS_TITLE_".$site; // Get RSS feed - $url = $conf->global->$keyforparamurl; + $url = getDolGlobalString($keyforparamurl); $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); @@ -98,7 +98,7 @@ class box_external_rss extends ModeleBoxes $description = $rssparser->getDescription(); $link = $rssparser->getLink(); - $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + $title = $langs->trans("BoxTitleLastRssInfos", $max, getDolGlobalString($keyforparamtitle)); if ($result < 0 || !empty($rssparser->error)) { // Show warning $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 5f053ae6e18..f09fb48493d 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -780,12 +780,12 @@ class CMailFile } // Force parameters - //dol_syslog("CMailFile::sendfile conf->global->".$keyforsmtpserver."=".$conf->global->$keyforsmtpserver." cpnf->global->".$keyforsmtpport."=".$conf->global->$keyforsmtpport, LOG_DEBUG); - if (!empty($conf->global->$keyforsmtpserver)) { - ini_set('SMTP', $conf->global->$keyforsmtpserver); + //dol_syslog("CMailFile::sendfile conf->global->".$keyforsmtpserver."=".getDolGlobalString($keyforsmtpserver)." cpnf->global->".$keyforsmtpport."=".$conf->global->$keyforsmtpport, LOG_DEBUG); + if (getDolGlobalString($keyforsmtpserver)) { + ini_set('SMTP', getDolGlobalString($keyforsmtpserver)); } - if (!empty($conf->global->$keyforsmtpport)) { - ini_set('smtp_port', $conf->global->$keyforsmtpport); + if (getDolGlobalString($keyforsmtpport)) { + ini_set('smtp_port', getDolGlobalString($keyforsmtpport)); } $res = true; @@ -869,10 +869,10 @@ class CMailFile } // Restore parameters - if (!empty($conf->global->$keyforsmtpserver)) { + if (getDolGlobalString($keyforsmtpserver)) { ini_restore('SMTP'); } - if (!empty($conf->global->$keyforsmtpport)) { + if (getDolGlobalString($keyforsmtpport)) { ini_restore('smtp_port'); } } elseif ($this->sendmode == 'smtps') { @@ -1059,7 +1059,7 @@ class CMailFile } // If we use SSL/TLS - $server = $conf->global->$keyforsmtpserver; + $server = getDolGlobalString($keyforsmtpserver); $secure = ''; if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) { $secure = 'ssl'; @@ -1068,7 +1068,7 @@ class CMailFile $secure = 'tls'; } - $this->transport = new Swift_SmtpTransport($server, $conf->global->$keyforsmtpport, $secure); + $this->transport = new Swift_SmtpTransport($server, getDolGlobalString($keyforsmtpport), $secure); if (!empty($conf->global->$keyforsmtpid)) { $this->transport->setUsername($conf->global->$keyforsmtpid); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c5914413282..575b3ab2da2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3659,7 +3659,7 @@ abstract class CommonObject } if (!empty($MODULE)) { - if (!empty($conf->global->$MODULE)) { + if (getDolGlobalString($MODULE)) { $modsactivated = explode(',', getDolGlobalString($MODULE)); foreach ($modsactivated as $mod) { if (isModEnabled($mod)) { @@ -5661,8 +5661,8 @@ abstract class CommonObject // If generator is ODT, we must have srctemplatepath defined, if not we set it. if ($obj->type == 'odt' && empty($srctemplatepath)) { $varfortemplatedir = $obj->scandir; - if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) { - $dirtoscan = $conf->global->$varfortemplatedir; + if ($varfortemplatedir && getDolGlobalString($varfortemplatedir)) { + $dirtoscan = getDolGlobalString($varfortemplatedir); $listoffiles = array(); @@ -5970,8 +5970,8 @@ abstract class CommonObject $keyforfieldname = strtoupper($newelement.'_DEFAULT_'.$fieldname); //var_dump($keyforfieldname); - if (isset($conf->global->$keyforfieldname)) { - return $conf->global->$keyforfieldname; + if (getDolGlobalString($keyforfieldname)) { + return getDolGlobalString($keyforfieldname); } // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6d8fb1a4b7a..f0c62c0bd5c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -151,7 +151,6 @@ function getMultidirOutput($object, $module = '') function getDolGlobalString($key, $default = '') { global $conf; - // return $conf->global->$key ?? $default; return (string) (isset($conf->global->$key) ? $conf->global->$key : $default); } @@ -166,7 +165,6 @@ function getDolGlobalString($key, $default = '') function getDolGlobalInt($key, $default = 0) { global $conf; - // return $conf->global->$key ?? $default; return (int) (isset($conf->global->$key) ? $conf->global->$key : $default); } @@ -185,7 +183,6 @@ function getDolUserString($key, $default = '', $tmpuser = null) $tmpuser = $user; } - // return $conf->global->$key ?? $default; return (string) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key); } @@ -204,7 +201,6 @@ function getDolUserInt($key, $default = 0, $tmpuser = null) $tmpuser = $user; } - // return $conf->global->$key ?? $default; return (int) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key); } diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php index d65d937722f..b458378d1c8 100644 --- a/htdocs/public/users/view.php +++ b/htdocs/public/users/view.php @@ -402,10 +402,10 @@ if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { $logosmall = $mysoc->logo_squarred_small ? $mysoc->logo_squarred_small : $mysoc->logo_small; $logo = $mysoc->logo_squarred ? $mysoc->logo_squarred : $mysoc->logo; $paramlogo = 'ONLINE_USER_LOGO_'.$suffix; - if (!empty($conf->global->$paramlogo)) { - $logosmall = $conf->global->$paramlogo; + if (getDolGlobalString($paramlogo)) { + $logosmall = getDolGlobalString($paramlogo); } elseif (getDolGlobalString('ONLINE_USER_LOGO')) { - $logosmall = $conf->global->ONLINE_USER_LOGO; + $logosmall = getDolGlobalString('ONLINE_USER_LOGO'); } //print ''."\n"; // Define urllogo diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index bc833ed6a7e..133720a1b8c 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -341,7 +341,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi // Line of free text $newfreetext = ''; $paramfreetext = 'ORDER_FREE_TEXT'; - if (!empty($conf->global->$paramfreetext)) { + if (getDolGlobalString($paramfreetext)) { $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); } diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 1934c0358a0..7acf9a45117 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -250,7 +250,7 @@ if (isModEnabled("banque")) { $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse; print ''; print ''; - $label = ($langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code)) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label; + $label = ($langs->trans("PaymentType".$objp->payment_code) != "PaymentType".$objp->payment_code) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label; print ''; if (isModEnabled("banque")) { $bankaccountstatic->id = $objp->baid; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index de73c07b98a..cbf57df3ab7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2488,7 +2488,7 @@ class Facture extends CommonInvoice $this->import_key = trim($this->import_key); } if (isset($this->retained_warranty)) { - $this->retained_warranty = floatval($this->retained_warranty); + $this->retained_warranty = (float) $this->retained_warranty; } @@ -5432,7 +5432,7 @@ class Facture extends CommonInvoice $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) { $totalpaid = $this->getSommePaiement(); - $totalpaid = floatval($totalpaid); + $totalpaid = (float) $totalpaid; $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); if ($totalpaid >= 0 && $RetainedWarrantyAmount >= 0) { if (($totalpaid < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { @@ -5532,7 +5532,7 @@ class Facture extends CommonInvoice } if ($rounding < 0) { - $rounding = min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), $conf->global->MAIN_MAX_DECIMALS_TOT); + $rounding = min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), getDolGlobalString('MAIN_MAX_DECIMALS_TOT')); } if ($rounding > 0) { @@ -5559,7 +5559,7 @@ class Facture extends CommonInvoice $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { - $this->retained_warranty = floatval($value); + $this->retained_warranty = (float) $value; return 1; } else { dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); @@ -6755,7 +6755,7 @@ class FactureLigne extends CommonInvoiceLine if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); - $returnPercent = floatval($res['situation_percent']); + $returnPercent = (float) $res['situation_percent']; if ($include_credit_note) { $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd'; @@ -6767,7 +6767,7 @@ class FactureLigne extends CommonInvoiceLine $res = $this->db->query($sql); if ($res) { while ($obj = $this->db->fetch_object($res)) { - $returnPercent = $returnPercent + floatval($obj->situation_percent); + $returnPercent = $returnPercent + (float) $obj->situation_percent; } } else { dol_print_error($this->db); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 32e05251fde..ae2a97958b7 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -141,7 +141,7 @@ if (empty($reshook)) { } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key)); - $multicurrency_totalpayment += floatval($multicurrency_amounts[$cursorfacid]); + $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid]; if (!empty($multicurrency_amounts[$cursorfacid])) { $atleastonepaymentnotnull++; } @@ -301,7 +301,7 @@ if (empty($reshook)) { $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) { + if (is_numeric($amount) && $amount != 0) { if ($invoiceid != 0) { $invoiceid = -1; // There is more than one invoice payed by this payment } else { diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index adb1e38af89..63a47618cd7 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -308,7 +308,7 @@ print $form->editfieldval("Date", 'datep', $object->date, $object, $user->hasRig print ''; // Payment type (VIR, LIQ, ...) -$labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; +$labeltype = $langs->trans("PaymentType".$object->type_code) != "PaymentType".$object->type_code ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; print ''; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 7eba56434fe..e9ea56f19ed 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -258,7 +258,7 @@ class RemiseCheque extends CommonObject } if ($this->id > 0 && $this->errno == 0) { - if ($this->updateAmount() <> 0) { + if ($this->updateAmount() != 0) { $this->errno = -1027; dol_syslog("RemiseCheque::Create Error update amount ".$this->errno, LOG_ERR); } @@ -307,7 +307,7 @@ class RemiseCheque extends CommonObject if ($resql) { $num = $this->db->affected_rows($resql); - if ($num <> 1) { + if ($num != 1) { $this->errno = -2; dol_syslog("Remisecheque::Delete Erreur Lecture ID ($this->errno)"); } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 64335484aa1..b35b091f315 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -362,7 +362,7 @@ class Paiement extends CommonObject // Insert links amount / invoices foreach ($this->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) { + if (is_numeric($amount) && $amount != 0) { $amount = price2num($amount); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)"; $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).", ".($currencyofpayment ? "'".$this->db->escape($currencyofpayment)."'" : 'NULL').", ".(!empty($this->multicurrency_tx) ? (float) $currencytxofpayment : 1).")"; diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index dfb25dd6c69..5984c9f2f04 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -273,7 +273,7 @@ if ($action == 'create') { print ''; print ''; print ''; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 564de96b4f4..591d1c0a68b 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -719,7 +719,7 @@ if ($id > 0) { print ''; print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; + $labeltype = $langs->trans("PaymentType".$objp->type_code) != "PaymentType".$objp->type_code ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; if (isModEnabled("banque")) { $bankaccountstatic->id = $objp->baid; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 5b0782a6598..645f1d0c25f 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -229,7 +229,7 @@ class PaymentSocialContribution extends CommonObject // Insere tableau des montants / factures foreach ($this->amounts as $key => $amount) { $contribid = $key; - if (is_numeric($amount) && $amount <> 0) { + if (is_numeric($amount) && $amount != 0) { $amount = price2num($amount); // If we want to closed paid invoices diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 0b89a923153..65d8cb7de58 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -713,7 +713,7 @@ if ($id > 0) { print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; print ''; print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; + $labeltype = $langs->trans("PaymentType".$objp->type_code) != "PaymentType".$objp->type_code ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; if (isModEnabled("banque")) { $bankaccountstatic->id = $objp->baid; diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 3d0d51bebf8..713cc9a6ed0 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -233,7 +233,7 @@ class PaymentVAT extends CommonObject // Insert table of amounts / invoices foreach ($this->amounts as $key => $amount) { $contribid = $key; - if (is_numeric($amount) && $amount <> 0) { + if (is_numeric($amount) && $amount != 0) { $amount = price2num($amount); // If we want to closed paid invoices diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index e160abfc3b8..8eac0e00140 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -891,18 +891,18 @@ class Tva extends CommonObject //$langs->load("mymodule"); $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid'); $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid'); - if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) { + if ($status == self::STATUS_UNPAID && $alreadypaid != 0) { $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted"); } $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid'); - if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) { + if ($status == self::STATUS_UNPAID && $alreadypaid != 0) { $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted"); } } $statusType = 'status1'; - if ($status == 0 && $alreadypaid <> 0) { + if ($status == 0 && $alreadypaid != 0) { $statusType = 'status3'; } if ($status == 1) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 9f549577365..028ad27c755 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1028,7 +1028,7 @@ class Contact extends CommonObject $this->ref_ext = $obj->ref_ext; $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != "Civility".$obj->civility_code ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 9b6c0b4bf75..81683c81d18 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1712,7 +1712,7 @@ abstract class CommonDocGenerator $def = array( 'rank' => intval($extrafields->attributes[$object->table_element]['pos'][$key]), 'width' => 25, // in mm - 'status' => boolval($enabled), + 'status' => (bool) $enabled, 'title' => array( 'label' => $outputlangs->transnoentities($label) ), diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 575b3ab2da2..627f1b8c0e7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4847,7 +4847,7 @@ abstract class CommonObject $qty = $obj->qty; $total_ht = $obj->total_ht; - $total_discount_line = floatval(price2num(($pu_ht * $qty) - $total_ht, 'MT')); + $total_discount_line = (float) price2num(($pu_ht * $qty) - $total_ht, 'MT'); $total_discount += $total_discount_line; $i++; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 4c7f1246587..e09a6ce88fb 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -424,7 +424,7 @@ class CUnits extends CommonDict */ public function unitConverter($value, $fk_unit, $fk_new_unit = 0) { - $value = floatval(price2num($value)); + $value = (float) price2num($value); $fk_unit = intval($fk_unit); // Calcul en unité de base @@ -463,10 +463,10 @@ class CUnits extends CommonDict // TODO : if base exists in unit dictionary table, remove this convertion exception and update convertion infos in database. // Example time hour currently scale 3600 will become scale 2 base 60 if ($unit->unit_type == 'time') { - return floatval($unit->scale); + return (float) $unit->scale; } - return pow($base, floatval($unit->scale)); + return pow($base, (float) $unit->scale); } } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 07e3ffe8d94..abb82dd9e2e 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -152,8 +152,6 @@ class DiscountAbsolute */ public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) { - global $conf; - // Check parameters if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) { $this->error = 'ErrorBadParameters'; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d0659dc3036..0a77e11981b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2315,9 +2315,9 @@ class ExtraFields $dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end'; if (GETPOST($dateparamname_start . 'year') && GETPOST($dateparamname_end . 'year')) { // values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc. - $dateparamname_end_hour = GETPOST($dateparamname_end . 'hour', 'int') !='-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23'; - $dateparamname_end_min = GETPOST($dateparamname_end . 'min', 'int') !='-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59'; - $dateparamname_end_sec = GETPOST($dateparamname_end . 'sec', 'int') !='-1' ? GETPOST($dateparamname_end . 'sec', 'int') : '59'; + $dateparamname_end_hour = GETPOST($dateparamname_end . 'hour', 'int') != '-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23'; + $dateparamname_end_min = GETPOST($dateparamname_end . 'min', 'int') != '-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59'; + $dateparamname_end_sec = GETPOST($dateparamname_end . 'sec', 'int') != '-1' ? GETPOST($dateparamname_end . 'sec', 'int') : '59'; if ($key_type == 'datetimegmt') { $value_key = array( 'start' => dol_mktime(GETPOST($dateparamname_start . 'hour', 'int'), GETPOST($dateparamname_start . 'min', 'int'), GETPOST($dateparamname_start . 'sec', 'int'), GETPOST($dateparamname_start . 'month', 'int'), GETPOST($dateparamname_start . 'day', 'int'), GETPOST($dateparamname_start . 'year', 'int'), 'gmt'), diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 73d9e78a02c..f5a05e2bf97 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4039,7 +4039,7 @@ class Form $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label = ($langs->trans("PaymentConditionShort" . $obj->code) != ("PaymentConditionShort" . $obj->code) ? $langs->trans("PaymentConditionShort" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->trans("PaymentConditionShort" . $obj->code) != "PaymentConditionShort" . $obj->code ? $langs->trans("PaymentConditionShort" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_conditions_paiements[$obj->rowid]['code'] = $obj->code; $this->cache_conditions_paiements[$obj->rowid]['label'] = $label; $this->cache_conditions_paiements[$obj->rowid]['deposit_percent'] = $obj->deposit_percent; @@ -4088,7 +4088,7 @@ class Form $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label = ($langs->trans("AvailabilityType" . $obj->code) != ("AvailabilityType" . $obj->code) ? $langs->trans("AvailabilityType" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->trans("AvailabilityType" . $obj->code) != "AvailabilityType" . $obj->code ? $langs->trans("AvailabilityType" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_availability[$obj->rowid]['code'] = $obj->code; $this->cache_availability[$obj->rowid]['label'] = $label; $this->cache_availability[$obj->rowid]['position'] = $obj->position; @@ -4170,7 +4170,7 @@ class Form // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = ($obj->label != '-' ? $obj->label : ''); - if ($langs->trans("DemandReasonType" . $obj->code) != ("DemandReasonType" . $obj->code)) { + if ($langs->trans("DemandReasonType" . $obj->code) != "DemandReasonType" . $obj->code) { $label = $langs->trans("DemandReasonType" . $obj->code); // So translation key DemandReasonTypeSRC_XXX will work } if ($langs->trans($obj->code) != $obj->code) { @@ -4269,7 +4269,7 @@ class Form $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label = ($langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != ("PaymentTypeShort" . $obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != "PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_types_paiements[$obj->id]['id'] = $obj->id; $this->cache_types_paiements[$obj->id]['code'] = $obj->code; $this->cache_types_paiements[$obj->id]['label'] = $label; @@ -4583,7 +4583,7 @@ class Form $obj = $this->db->fetch_object($resql); // If traduction exist, we use it else we take the default label - $label = ($langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != ("PaymentTypeShort" . $obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != "PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; $this->cache_transport_mode[$obj->rowid]['label'] = $label; @@ -10891,7 +10891,7 @@ class Form $obj = $this->db->fetch_object($resql); // If translation exists, we use it, otherwise we take the default wording - $label = ($langs->trans("InvoiceSubtype" . $obj->rowid) != ("InvoiceSubtype" . $obj->rowid)) ? $langs->trans("InvoiceSubtype" . $obj->rowid) : (($obj->label != '-') ? $obj->label : ''); + $label = ($langs->trans("InvoiceSubtype" . $obj->rowid) != "InvoiceSubtype" . $obj->rowid) ? $langs->trans("InvoiceSubtype" . $obj->rowid) : (($obj->label != '-') ? $obj->label : ''); $this->cache_invoice_subtype[$obj->rowid]['rowid'] = $obj->rowid; $this->cache_invoice_subtype[$obj->rowid]['code'] = $obj->code; $this->cache_invoice_subtype[$obj->rowid]['label'] = $label; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index c0d6174b1c8..346ec645e14 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -201,7 +201,7 @@ class FormAdmin $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index') { + if (is_file($dir."/".$file) && substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS' && substr($file, 0, 5) != 'index') { if (preg_match('/lib\.php$/i', $file)) { continue; // We exclude library files } @@ -301,7 +301,7 @@ class FormAdmin $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { + if (is_file($dir."/".$file) && substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') { $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); if (preg_match('/^index/i', $filelib)) { continue; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 9df01212214..3c09c410e22 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1469,7 +1469,7 @@ class FormOther } else { print ''; $i++; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 0112d617ac4..972458dd5c8 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -845,7 +845,7 @@ class FormTicket } $label = ($arraycategories['label'] != '-' ? $arraycategories['label'] : ''); - if ($outputlangs->trans("TicketCategoryShort".$arraycategories['code']) != ("TicketCategoryShort".$arraycategories['code'])) { + if ($outputlangs->trans("TicketCategoryShort".$arraycategories['code']) != "TicketCategoryShort".$arraycategories['code']) { $label = $outputlangs->trans("TicketCategoryShort".$arraycategories['code']); } elseif ($outputlangs->trans($arraycategories['code']) != $arraycategories['code']) { $label = $outputlangs->trans($arraycategories['code']); @@ -907,7 +907,7 @@ class FormTicket } print ajax_combobox('select'.$htmlname); - } elseif ($htmlname!='') { + } elseif ($htmlname != '') { $selectedgroups = array(); $groupvalue = ""; $groupticket=GETPOST($htmlname, 'aZ09'); @@ -958,7 +958,7 @@ class FormTicket $obj = $this->db->fetch_object($resql); if ($obj) { $label = ($obj->label != '-' ? $obj->label : ''); - if ($outputlangs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code)) { + if ($outputlangs->trans("TicketCategoryShort".$obj->code) != "TicketCategoryShort".$obj->code) { $label = $outputlangs->trans("TicketCategoryShort".$obj->code); } elseif ($outputlangs->trans($obj->code) != $obj->code) { $label = $outputlangs->trans($obj->code); @@ -1029,7 +1029,7 @@ class FormTicket $obj = $this->db->fetch_object($resql); if ($obj) { $label = ($obj->label != '-' ? $obj->label : ''); - if ($outputlangs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code)) { + if ($outputlangs->trans("TicketCategoryShort".$obj->code) != "TicketCategoryShort".$obj->code) { $label = $outputlangs->trans("TicketCategoryShort".$obj->code); } elseif ($outputlangs->trans($obj->code) != $obj->code) { $label = $outputlangs->trans($obj->code); diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index a3e6398a00a..0484968f526 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -1225,7 +1225,7 @@ class Lessc } list($color, $delta) = $args[2]; $color = $this->assertColor($color); - $delta = floatval($delta[1]); + $delta = (float) $delta[1]; return array($color, $delta); } @@ -1654,7 +1654,7 @@ class Lessc $i = 0; foreach ($rawComponents as $c) { $val = $this->reduce($c); - $val = isset($val[1]) ? floatval($val[1]) : 0; + $val = isset($val[1]) ? (float) $val[1] : 0; if ($i == 0) { $clamp = 360; @@ -1682,13 +1682,13 @@ class Lessc if ($c[0] == "number" && $c[2] == "%") { $components[] = 255 * ($c[1] / 100); } else { - $components[] = floatval($c[1]); + $components[] = (float) $c[1]; } } elseif ($i == 4) { if ($c[0] == "number" && $c[2] == "%") { $components[] = 1.0 * ($c[1] / 100); } else { - $components[] = floatval($c[1]); + $components[] = (float) $c[1]; } } else { break; diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index 4259e1e1a63..ec02afa8817 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -649,7 +649,7 @@ function GetRootPath() // This can check only that this script isn't run from a virtual dir // But it avoids the problems that arise if it isn't checked - if ($position === false || $position <> strlen($sRealPath) - strlen($sSelfPath)) { + if ($position === false || $position != strlen($sRealPath) - strlen($sSelfPath)) { SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.inc.php".'); } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 02683de3c61..cebf9ac7b3e 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -764,7 +764,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $nbFerie = 0; // Check to ensure we use correct parameters - if ((($timestampEnd - $timestampStart) % 86400) != 0) { + if (($timestampEnd - $timestampStart) % 86400 != 0) { return 'Error Dates must use same hours and must be GMT dates'; } diff --git a/htdocs/core/lib/doleditor.lib.php b/htdocs/core/lib/doleditor.lib.php index 43e59c01e65..275b69aea2b 100644 --- a/htdocs/core/lib/doleditor.lib.php +++ b/htdocs/core/lib/doleditor.lib.php @@ -87,8 +87,8 @@ function show_skin($fuser, $edit = 0) $handle = opendir($dirskin); if (is_resource($handle)) { while (($subdir = readdir($handle)) !== false) { - if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.' - && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) { + if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) != '.' + && substr($subdir, 0, 3) != 'CVS' && !preg_match('/common|phones/i', $subdir)) { // Disable not stable themes (dir ends with _exp or _dev) if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && preg_match('/_dev$/i', $subdir)) { continue; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f0c62c0bd5c..90e8faf65ed 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6044,7 +6044,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ } $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) if ($rounding == -1) { - $rounding = min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), $conf->global->MAIN_MAX_DECIMALS_TOT); + $rounding = min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), getDolGlobalString('MAIN_MAX_DECIMALS_TOT')); } $nbdecimal = $rounding; @@ -8244,7 +8244,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->delivery_date) ? dol_print_date($object->delivery_date, 'day', 0, $outputlangs) : ''); - $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '')) : ''); + $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset($object->availability_code) ? ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '')) : ''); $substitutionarray['__EXPIRATION_DATE__'] = (isset($object->fin_validite) ? dol_print_date($object->fin_validite, 'daytext') : ''); if (is_object($object) && ($object->element == 'adherent' || $object->element == 'member') && $object->id > 0) { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 906a658b445..d2781ffd31a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -97,7 +97,7 @@ function dolGetModulesDirs($subdir = '') continue; // We discard module if it contains disabled into name. } - if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') { + if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS' && $file != 'includes') { if (is_dir($dirroot.'/'.$file.'/core/modules'.$subdir.'/')) { $modulesdir[$dirroot.'/'.$file.'/core/modules'.$subdir.'/'] = $dirroot.'/'.$file.'/core/modules'.$subdir.'/'; } @@ -1690,7 +1690,7 @@ function weight_convert($weight, &$from_unit, $to_unit) * */ $weight = is_numeric($weight) ? $weight : 0; - while ($from_unit <> $to_unit) { + while ($from_unit != $to_unit) { if ($from_unit > $to_unit) { $weight = $weight * 10; $from_unit = $from_unit - 1; @@ -2513,7 +2513,7 @@ function colorHexToRgb($hex, $alpha = false, $returnArray = false) $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); if ($alpha !== false) { - $rgb['a'] = floatval($alpha); + $rgb['a'] = (float) $alpha; $string = 'rgba('.implode(',', $rgb).')'; } else { $string = 'rgb('.implode(',', $rgb).')'; diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 0236afaddf5..c4d7ddac7e9 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -272,7 +272,7 @@ function dol_setshmop($memoryid, $data, $expire) if ($handle) { $shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0); $shm_bytes_written2 = shmop_write($handle, $newdata, 6); - if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata))) { + if ($shm_bytes_written1 + $shm_bytes_written2 != 6 + dol_strlen($newdata)) { print "Couldn't write the entire length of data\n"; } shmop_close($handle); diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index abb50904502..7e422f130ff 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -263,7 +263,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = 0, $freetag = 'y if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) { $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { - $out .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2)); + $out .= '&securekey='.urlencode(dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2)); } } //if ($mode) $out.='&noidempotency=1'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1449fb333f5..37c630ba212 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1263,7 +1263,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for set top margin height of footer after freetext if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) { - $posy -= floatval(getDolGlobalString('PDF_FOOTER_TOP_MARGIN')); + $posy -= (float) getDolGlobalString('PDF_FOOTER_TOP_MARGIN'); } else { $posy--; } @@ -1317,7 +1317,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for set top margin height of footer after freetext if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) { - $posy -= floatval(getDolGlobalString('PDF_FOOTER_TOP_MARGIN')); + $posy -= (float) getDolGlobalString('PDF_FOOTER_TOP_MARGIN'); } else { $posy--; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ddcae0393c5..b7af2262de4 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2860,7 +2860,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $progressBarClass = 'progress-bar-info'; $progressCalculated = 0; if ($task->planned_workload) { - $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2); + $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2); // this conf is actually hidden, by default we use 10% for "be carefull or warning" $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10; @@ -2869,11 +2869,11 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $diffTitle .= '
    '.$langs->trans('ProgressCalculated').' : '.$progressCalculated.(isset($progressCalculated) ? '%' : ''); //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.floatval($task->progress * $warningRatio)); - if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) { + if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) { $progressBarClass = 'progress-bar-danger'; $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point")); $diff = ' '.($task->progress - $progressCalculated).'%'; - } elseif (floatval($progressCalculated) > floatval($task->progress)) { // warning if close at 10% + } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10% $progressBarClass = 'progress-bar-warning'; $title = $langs->trans('TheReportedProgressIsLessThanTheCalculatedProgressionByX', abs($task->progress - $progressCalculated).' '.$langs->trans("point")); $diff = ' '.($task->progress - $progressCalculated).'%'; @@ -2937,18 +2937,18 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $out .= ''; $out .= '
    '; - $diffval = floatval($task->progress) - floatval($progressCalculated); + $diffval = (float) $task->progress - (float) $progressCalculated; if ($diffval >= 0) { // good - $out .= '
    '; + $out .= '
    '; if (!empty($task->progress)) { - $out .= '
    '; + $out .= '
    '; } $out .= '
    '; } else { // bad - $out .= '
    '; - $out .= '
    '; + $out .= '
    '; + $out .= '
    '; $out .= '
    '; } $out .= '
    '; @@ -2977,17 +2977,17 @@ function getTaskProgressBadge($task, $label = '', $tooltip = '') // define color according to time spend vs workload $badgeClass = 'badge '; if ($task->planned_workload) { - $progressCalculated = round(100 * floatval($task->duration_effective) / floatval($task->planned_workload), 2); + $progressCalculated = round(100 * (float) $task->duration_effective / (float) $task->planned_workload, 2); // this conf is actually hidden, by default we use 10% for "be carefull or warning" $warningRatio = getDolGlobalString('PROJECT_TIME_SPEND_WARNING_PERCENT') ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10; - if (floatval($progressCalculated) > floatval($task->progress * $warningRatio)) { + if ((float) $progressCalculated > (float) ($task->progress * $warningRatio)) { $badgeClass .= 'badge-danger'; if (empty($tooltip)) { $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%'; } - } elseif (floatval($progressCalculated) > floatval($task->progress)) { // warning if close at 10% + } elseif ((float) $progressCalculated > (float) $task->progress) { // warning if close at 10% $badgeClass .= 'badge-warning'; if (empty($tooltip)) { $tooltip = $task->progress.'% < '.$langs->trans("TimeConsumed").' '.$progressCalculated.'%'; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 60b52ba3101..bed487971d5 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -406,8 +406,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $handle = opendir($dirtheme); if (is_resource($handle)) { while (($subdir = readdir($handle)) !== false) { - if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' - && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) { + if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) != '.' + && substr($subdir, 0, 3) != 'CVS' && !preg_match('/common|phones/i', $subdir)) { // Disable not stable themes (dir ends with _exp or _dev) if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && preg_match('/_dev$/i', $subdir)) { continue; diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 144d46d31de..8767a8a227c 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -581,7 +581,7 @@ function showWebsiteTemplates(Website $website) $handle = opendir($dirtheme); if (is_resource($handle)) { while (($subdir = readdir($handle)) !== false) { - if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' && substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir)) { + if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) != '.' && substr($subdir, 0, 3) != 'CVS' && preg_match('/\.zip$/i', $subdir)) { $subdirwithoutzip = preg_replace('/\.zip$/i', '', $subdir); // Disable not stable themes (dir ends with _exp or _dev) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 13ff885a2d0..1f300718385 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -619,7 +619,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it global $langs; $langs->load("admin"); - if ($langs->transnoentitiesnoconv("Module".$this->numero."Name") != ("Module".$this->numero."Name")) { + if ($langs->transnoentitiesnoconv("Module".$this->numero."Name") != "Module".$this->numero."Name") { // If module name translation exists return $langs->transnoentitiesnoconv("Module".$this->numero."Name"); } else { @@ -632,7 +632,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } } - if ($langs->trans("Module".$this->name."Name") != ("Module".$this->name."Name")) { + if ($langs->trans("Module".$this->name."Name") != "Module".$this->name."Name") { // If module name translation exists return $langs->transnoentitiesnoconv("Module".$this->name."Name"); } @@ -653,7 +653,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it global $langs; $langs->load("admin"); - if ($langs->transnoentitiesnoconv("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) { + if ($langs->transnoentitiesnoconv("Module".$this->numero."Desc") != "Module".$this->numero."Desc") { // If module description translation exists return $langs->transnoentitiesnoconv("Module".$this->numero."Desc"); } else { @@ -666,7 +666,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } } - if ($langs->transnoentitiesnoconv("Module".$this->name."Desc") != ("Module".$this->name."Desc")) { + if ($langs->transnoentitiesnoconv("Module".$this->name."Desc") != "Module".$this->name."Desc") { // If module name translation exists return $langs->trans("Module".$this->name."Desc"); } diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index cf8e067b8d4..6a8feaefccd 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -261,7 +261,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } else { if ($this->verif_syntax($code, $type) >= 0) { $is_dispo = $this->verif_dispo($db, $code, $product); - if ($is_dispo <> 0) { + if ($is_dispo != 0) { $result = -3; } else { $result = 0; diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php index 7c7921cf461..3037f29d33d 100644 --- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -262,7 +262,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode } else { if ($this->verif_syntax($code, $type) >= 0) { $is_dispo = $this->verif_dispo($db, $code, $thirdparty); - if ($is_dispo <> 0) { + if ($is_dispo != 0) { $result = -3; } else { $result = 0; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index dddb16a3dd7..3c9a8d348e3 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -719,7 +719,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); if ($object->deposit_percent > 0) { $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement); @@ -778,7 +778,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); + $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); @@ -796,7 +796,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a55f63c2233..74851a34c7e 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -921,7 +921,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); if ($object->deposit_percent > 0) { $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement); @@ -979,7 +979,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); + $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); @@ -997,7 +997,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ed3701527c0..018d41dbb53 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1145,7 +1145,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); @@ -1199,7 +1199,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); //#21654: add account number used for the debit if ($object->mode_reglement_code == "PRE") { require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 7a3e443d6ac..de9ec3f2a09 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1238,7 +1238,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0, 'L'); @@ -1292,7 +1292,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); //#21654: add account number used for the debit if ($object->mode_reglement_code == "PRE") { diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 83059884b80..4868f64dbfc 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -454,7 +454,7 @@ class mailing_contacts1 extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index c2a2c0d3c8d..006405f63c8 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -99,7 +99,7 @@ class mailing_eventorganization extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $otherTxt = ($obj->ref ? $langs->transnoentities("Project").'='.$obj->ref : ''); if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) { $otherTxt .= ";"; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 1ffd718a44f..43ece5ec3f6 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -297,7 +297,7 @@ class mailing_fraise extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 03d6a59dba8..739ef8c52f8 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -121,7 +121,7 @@ class mailing_partnership extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $otherTxt = ($obj->label ? $langs->transnoentities("PartnershipType").'='.$obj->label : ''); if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) { $otherTxt .= ";"; diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 25d4d8a4192..9dc1c18f696 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -199,7 +199,7 @@ class mailing_pomme extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index dcda0f2b0aa..b11f80712ec 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -69,7 +69,7 @@ class mailing_thirdparties extends MailingTargets $addDescription = ""; $addFilter = ""; - if (GETPOSTISSET("filter_client_thirdparties") && GETPOST("filter_client_thirdparties") <> '-1') { + if (GETPOSTISSET("filter_client_thirdparties") && GETPOST("filter_client_thirdparties") != '-1') { $addFilter .= " AND s.client=".((int) GETPOST("filter_client_thirdparties", 'int')); $addDescription = $langs->trans('ProspectCustomer')."="; if (GETPOST("filter_client_thirdparties") == 0) { @@ -84,7 +84,7 @@ class mailing_thirdparties extends MailingTargets $addDescription .= "Unknown status ".GETPOST("filter_client_thirdparties"); } } - if (GETPOSTISSET("filter_supplier_thirdparties") && GETPOST("filter_supplier_thirdparties") <> '-1') { + if (GETPOSTISSET("filter_supplier_thirdparties") && GETPOST("filter_supplier_thirdparties") != '-1') { $addFilter .= " AND s.fournisseur = ".((int) GETPOST("filter_supplier_thirdparties", 'int')); $addDescription = $langs->trans('Supplier')."="; if (GETPOST("filter_supplier_thirdparties") == 0) { @@ -188,7 +188,7 @@ class mailing_thirdparties extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $otherTxt = ($obj->label ? $langs->transnoentities("Category").'='.$obj->label : ''); if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) { $otherTxt .= ";"; diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 4d0ac4ea0bb..b628890f8a8 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -129,7 +129,7 @@ class mailing_thirdparties_services_expired extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $cibles[$j] = array( 'email' => $obj->email, 'lastname' => $obj->name, // For thirdparties, lastname must be name diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 3fcbace468b..e1eed1ffb6d 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -165,7 +165,7 @@ class mailing_xinputfile extends MailingTargets if (!empty($buffer)) { //print 'xx'.dol_strlen($buffer).empty($buffer)."
    \n"; if (isValidEMail($email)) { - if ($old <> $email) { + if ($old != $email) { $cibles[$j] = array( 'email' => $email, 'lastname' => $name, diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 36ae75629c2..865452c6e6a 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -704,7 +704,7 @@ class pdf_vinci extends ModelePDFMo $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); @@ -720,7 +720,7 @@ class pdf_vinci extends ModelePDFMo $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 0f83b667b95..53a2b63ec49 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -925,7 +925,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); + $lib_availability = ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); @@ -966,7 +966,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); if ($object->deposit_percent > 0) { $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement); @@ -987,7 +987,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1cda855a095..4bed358b2ba 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1018,7 +1018,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); + $lib_availability = ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); @@ -1059,7 +1059,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); if ($object->deposit_percent > 0) { $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement); @@ -1080,7 +1080,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 62091507449..50100967a03 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -490,7 +490,7 @@ class pdf_paiement extends CommonDocGenerator $pdf->SetFont('', '', $default_font_size - 1); $yp = 0; } - if ($oldprowid <> $lines[$j][7]) { + if ($oldprowid != $lines[$j][7]) { if ($yp > $this->tab_height - 15) { $pdf->SetFillColor(255, 255, 255); $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array()); @@ -547,7 +547,7 @@ class pdf_paiement extends CommonDocGenerator $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0); $yp = $yp + 5; - if ($oldprowid <> $lines[$j][7]) { + if ($oldprowid != $lines[$j][7]) { $oldprowid = $lines[$j][7]; } diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 89dcab90827..1c27d563ecb 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -329,7 +329,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode return -6; } else { $is_dispo = $this->verif_dispo($db, $code, $soc, $type); - if ($is_dispo <> 0) { + if ($is_dispo != 0) { $result = -3; } } diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index bf7a5ea84f4..4ae2207fecf 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -188,7 +188,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } else { if ($this->verif_syntax($code) >= 0) { $is_dispo = $this->verif_dispo($db, $code, $soc, $type); - if ($is_dispo <> 0) { + if ($is_dispo != 0) { $result = -3; } else { $result = 0; diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 0a33980e694..ccb480dcc52 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -237,7 +237,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || getDolGlobalString('COMPANY_DIGITARIA_UNIQUE_CODE')) { $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); - while ($disponibility <> 0 && $i < 1000) { + while ($disponibility != 0 && $i < 1000) { $widthsupplier = $this->supplieraccountancycodecharacternumber; $widthcustomer = $this->customeraccountancycodecharacternumber; diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index de7a1f65f5e..76db4f7a157 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -855,7 +855,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); @@ -910,7 +910,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); + $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); @@ -928,7 +928,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 940a4f09a6d..44abdcd64a3 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -875,7 +875,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); @@ -891,7 +891,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 09604265236..1bbb8cbf623 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -754,7 +754,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); @@ -770,7 +770,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index ee84d168da9..958382e0a34 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -779,7 +779,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); @@ -797,7 +797,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy - 2); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php index d87861f0ab9..b500aeae310 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -874,7 +874,7 @@ class pdf_zenith extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); + $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); @@ -890,7 +890,7 @@ class pdf_zenith extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); - $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 1499e29b7fa..b4d72e29738 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -848,7 +848,7 @@ if (!empty($id) && $action != 'edit') { print '
    '; print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; + $labeltype = ($langs->trans("PaymentType".$objp->type_code) != "PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; print '\n"; print ""; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 0a065a71933..b8a07790426 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -325,7 +325,7 @@ if ($socid > 0) { if ($socid) { $sql .= " AND e.fk_soc = ".((int) $socid); } -if ($search_status <> '' && $search_status >= 0) { +if ($search_status != '' && $search_status >= 0) { $sql .= " AND e.fk_statut = ".((int) $search_status); } if ($search_ref_customer != '') { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 5426fc1a8ac..90f808087cd 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1970,7 +1970,7 @@ if ($action == 'create') { print $paymentexpensereportstatic->getNomUrl(1); print ''; print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_type; + $labeltype = $langs->trans("PaymentType".$objp->payment_code) != "PaymentType".$objp->payment_code ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_type; print "\n"; // Bank account if (isModEnabled("banque")) { diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 6f9dc7e8355..5b67b635ff4 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -586,7 +586,7 @@ while ($i < $imaxinloop) { // Pyament type if (!empty($arrayfields['c.libelle']['checked'])) { - $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; + $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index f004f25b290..0f83e21ea93 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1512,7 +1512,7 @@ if ($action == 'create') { $db->free($resql); // Add new line - if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer') && $action <> 'editline' && !getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { + if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer') && $action != 'editline' && !getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { if (!$num) { print '
    '; print '
    '.$langs->trans("Total").''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1)); - $trunclength = !getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION') ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($facturefourn_static_det->desc, 1)); - $trunclength = !getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION') ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); print $form->textwithtooltip(dol_trunc($text, $trunclength), $facturefourn_static_det->desc); print ''; - $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); + $value = getDolGlobalInt($constante, 0); if ($value == 0) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; } elseif ($value == 1) { diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 423b78bc071..6b75e92bfca 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -159,7 +159,7 @@ if ($action == 'update') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } @@ -549,7 +549,7 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token' . $constname); } elseif ($val['type'] == 'product') { if (isModEnabled('product') || isModEnabled('service')) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); $form->select_produits($selected, $constname, '', 0); } } else { diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index ed99e058328..40e92d8270a 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -137,7 +137,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 78fed9249ea..eb3938ac088 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -851,7 +851,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { } // Activate/Disable and Setup (2 columns) - if (!empty($conf->global->$const_name)) { // If module is already activated + if (getDolGlobalString($const_name)) { // If module is already activated // Set $codeenabledisable $disableSetup = 0; if (!empty($arrayofwarnings[$modName])) { diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index 155606bc698..cc7527579aa 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -142,7 +142,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } @@ -270,7 +270,7 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); $form->select_produits($selected, $constname, '', 0); } } else { @@ -447,7 +447,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; $constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $file) { + if (getDolGlobalString($constforvar) == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -589,7 +589,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON'; - if ($conf->global->$constforvar == $name) { + if (getDolGlobalString($constforvar) == $name) { //print img_picto($langs->trans("Default"), 'on'); // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset print 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index e1a73810eb1..de2e7de2e74 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -120,7 +120,7 @@ if ($action == 'updateMask') { $ret = delDocumentModel($value, $type); if ($ret > 0) { $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 292add085d2..370f407a1de 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -2098,7 +2098,7 @@ class Setup extends DolibarrApi // Value found $value = ''; if ($constname && getDolGlobalString($constname) != '') { - $value = $conf->global->$constname; + $value = getDolGlobalString($constname); } $valueforchecksum = (empty($value) ? '0' : $value); diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index a184f667b8e..4232e60e481 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -139,7 +139,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index 5ddcffd25a7..7117deee8e1 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -188,7 +188,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'BOOKCAL_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3ff44d56866..906a658b445 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1893,8 +1893,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $const = $obj->description; - //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); - $dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); + $dirtoscan = preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString($const))); $listoffiles = array(); diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 87fd2ce60ae..22e4294eead 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -765,7 +765,7 @@ if (getDolGlobalString('PRODUCT_CANVAS_ABILITY')) { $const = "PRODUCT_SPECIAL_".strtoupper($file); - if ($conf->global->$const) { + if (getDolGlobalString($const)) { print img_picto($langs->trans("Active"), 'tick'); print ''; print ''.$langs->trans("Disable").''; diff --git a/htdocs/recruitment/admin/setup.php b/htdocs/recruitment/admin/setup.php index d3f56a73092..02c9ceeb336 100644 --- a/htdocs/recruitment/admin/setup.php +++ b/htdocs/recruitment/admin/setup.php @@ -153,7 +153,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'RECRUITMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index 9d8e60e44c0..487f39dad84 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -153,7 +153,7 @@ if ($action == 'updateMask') { $ret = delDocumentModel($value, $type); if ($ret > 0) { $constforval = 'RECRUITMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b3abbe70756..1380c032c86 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1223,7 +1223,7 @@ if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) { $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"]; //var_dump($constantforkey.' '.getDolGlobalInt($constantforkey)); - if (!empty($conf->global->$constantforkey) && getDolGlobalInt($constantforkey) > 0) { + if (getDolGlobalInt($constantforkey) > 0) { array_push($paiementsModes, $obj); } } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 094c65fdf84..f76069a7d23 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -323,11 +323,11 @@ if (empty($reshook)) { $prod_batch->find(0, '', '', $line->batch, $line->fk_warehouse); $mouvP = new MouvementStock($db); $mouvP->origin = $invoice; - $mouvP->livraison($user, $line->fk_product, $conf->global->$constantforkey, $line->qty, $line->price, 'TakePOS', '', '', '', $prod_batch->batch, $line->batch); + $mouvP->livraison($user, $line->fk_product, getDolGlobalString($constantforkey), $line->qty, $line->price, 'TakePOS', '', '', '', $prod_batch->batch, $line->batch); } else { $mouvP = new MouvementStock($db); $mouvP->origin = $invoice; - $mouvP->livraison($user, $line->fk_product, $conf->global->$constantforkey, $line->qty, $line->price, 'TakePOS', '', '', ''); + $mouvP->livraison($user, $line->fk_product, getDolGlobalString($constantforkey), $line->qty, $line->price, 'TakePOS', '', '', ''); } } } @@ -534,6 +534,7 @@ if (empty($reshook)) { if (!empty($batch)) { $action="setbatch"; } else { + $nbofsuggested = 0; $prod->load_stock('warehouseopen'); $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; if ($prod->stock_warehouse[getDolGlobalString($constantforkey)]->detail_batch!="") { @@ -561,7 +562,7 @@ if (empty($reshook)) { print ''; $staticwarehouse = new Entrepot($db); if ($warehouse_id > 0) { - $staticwarehouse->fetch($conf->global->$constantforkey); + $staticwarehouse->fetch(getDolGlobalString($constantforkey)); } $detail = ''; $detail .= $langs->trans("LotSerial").': '.$dbatch->batch; From 1985d1fd4df5bcb2dd78b496b509572136a1b66a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Dec 2023 20:00:57 +0100 Subject: [PATCH 189/315] Fix warnings --- htdocs/admin/events.php | 2 +- htdocs/admin/external_rss.php | 2 +- htdocs/admin/ldap_contacts.php | 2 +- htdocs/admin/ldap_groups.php | 2 +- htdocs/admin/ldap_members.php | 2 +- htdocs/admin/ldap_members_types.php | 2 +- htdocs/admin/ldap_users.php | 2 +- htdocs/admin/notification.php | 4 ++-- htdocs/admin/pdf.php | 2 +- htdocs/admin/syslog.php | 4 ++-- htdocs/admin/workflow.php | 2 +- htdocs/api/class/api_setup.class.php | 4 ++-- htdocs/comm/card.php | 4 ++-- htdocs/comm/multiprix.php | 4 ++-- htdocs/compta/cashcontrol/report.php | 6 +++--- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 12 ++++++------ htdocs/compta/prelevement/create.php | 2 +- htdocs/core/boxes/box_external_rss.php | 4 ++-- htdocs/core/class/CMailFile.class.php | 18 +++++++++--------- htdocs/core/class/commonobject.class.php | 10 +++++----- htdocs/core/lib/functions.lib.php | 4 ---- htdocs/public/users/view.php | 6 +++--- ...eric_recruitmentjobposition_odt.modules.php | 2 +- htdocs/takepos/admin/terminal.php | 2 +- 25 files changed, 52 insertions(+), 56 deletions(-) diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index fef00036cc2..afdeca4b7b2 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -122,7 +122,7 @@ foreach ($eventstolog as $key => $arr) { print ''.$arr['id'].''; $key = 'MAIN_LOGEVENTS_'.$arr['id']; - $value = empty($conf->global->$key) ? '' : $conf->global->$key; + $value = getDolGlobalString($key); print ''; print '
    '; print $object->price_level; $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level; - if (!empty($conf->global->$keyforlabel)) { - print ' - '.$langs->trans($conf->global->$keyforlabel); + if (getDolGlobalString($keyforlabel)) { + print ' - '.$langs->trans(getDolGlobalString($keyforlabel)); } print "
    '.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).''; - if (!empty($conf->global->$name)) { + if (getDolGlobalString($name)) { $atleastonefound++; } $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1; From 53cf64e1c9a3fecd2b7602ba15e728f3cb704cb2 Mon Sep 17 00:00:00 2001 From: Paul Dermody Date: Mon, 25 Dec 2023 14:29:44 -0600 Subject: [PATCH 190/315] Fixed issue where last days in current and previous month produce incorrect results in timezones west of GMT. This is due to the fact that the date() function uses the local time zone to do its work which will be the day before the intended date. Note: Does dol_mktime() have a similar problem? --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 755e1d624b3..e05b74fa9a4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -315,8 +315,8 @@ if (empty($mode) || $mode == 'show_month') { $next_year = $next['year']; $next_month = $next['month']; - $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + $max_day_in_prev_month = date("t", dol_mktime(12, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(12, 0, 0, $month, 1, $year)); // Nb of days in next month // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')) + 2; // date('w') is 0 fo sunday $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); From 840e4558a73effadea54e39e4a89dccae0267003 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 12:31:46 +0100 Subject: [PATCH 191/315] Fix display for PWA --- htdocs/theme/eldy/manifest.json.php | 8 ++++---- htdocs/theme/md/manifest.json.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index 7ec2e7e4b22..2cae631d25b 100644 --- a/htdocs/theme/eldy/manifest.json.php +++ b/htdocs/theme/eldy/manifest.json.php @@ -73,14 +73,14 @@ $manifest->manifest_version = 3; $manifest->name = constant('DOL_APPLICATION_TITLE'); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { - $manifest->name = $conf->global->MAIN_APPLICATION_TITLE; + $manifest->name = getDolGlobalString('MAIN_APPLICATION_TITLE'); } $manifest->short_name = $manifest->name; -$manifest->theme_color = !getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR') ? getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40') : $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR; -$manifest->background_color = !getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR') ? "#ffffff" : $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR; -$manifest->display = "standalone"; +$manifest->theme_color = getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR', getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40')); +$manifest->background_color = getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR', "#ffffff"); +$manifest->display = getDolGlobalString('MAIN_MANIFEST_DISPLAY', "minimal-ui"); $manifest->splash_pages = null; $manifest->icons = array(); $manifest->start_url = constant('DOL_MAIN_URL_ROOT'); diff --git a/htdocs/theme/md/manifest.json.php b/htdocs/theme/md/manifest.json.php index cef3eac9236..dc327ddf9dc 100644 --- a/htdocs/theme/md/manifest.json.php +++ b/htdocs/theme/md/manifest.json.php @@ -72,13 +72,13 @@ $manifest->manifest_version = 3; $manifest->name = constant('DOL_APPLICATION_TITLE'); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { - $manifest->name = $conf->global->MAIN_APPLICATION_TITLE; + $manifest->name = getDolGlobalString('MAIN_APPLICATION_TITLE'); } $manifest->short_name = $manifest->name; -$manifest->theme_color = !getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR') ? getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40') : $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR; -$manifest->background_color = !getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR') ? "#ffffff" : $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR; -$manifest->display = "standalone"; +$manifest->theme_color = getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR', getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40')); +$manifest->background_color = getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR', "#ffffff"); +$manifest->display = getDolGlobalString('MAIN_MANIFEST_DISPLAY', "minimal-ui"); $manifest->splash_pages = null; $manifest->icons = array(); $manifest->start_url = constant('DOL_MAIN_URL_ROOT'); @@ -86,8 +86,8 @@ $manifest->id = constant('DOL_MAIN_URL_ROOT'); if (getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL')) { $icon = new stdClass(); - $icon->src = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL; - if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) { + $icon->src = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL'); + if (getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE')) { $icon->sizes = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE') . "x" . getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE'); } else { $icon->sizes = "512x512"; From e97967e243b82522212561cdd8f9d5a094a5b243 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 12:39:28 +0100 Subject: [PATCH 192/315] Fix warning --- .../company/sync_contacts_dolibarr2ldap.php | 5 ++--- .../email_expire_services_to_customers.php | 18 +++++++++--------- ...mail_expire_services_to_representatives.php | 16 ++++++++-------- scripts/withdrawals/build_withdrawal_file.php | 5 ++--- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index c19d6d692df..bdfb856e255 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -89,7 +89,7 @@ print "----- To LDAP database:\n"; print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n"; print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n"; print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n"; -print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; +print "pass=".preg_replace('/./i', '*', getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; print "DN target=" . getDolGlobalString('LDAP_CONTACT_DN')."\n"; print "\n"; @@ -103,8 +103,7 @@ if (!$confirmed) { } /* - * if (! $conf->global->LDAP_CONTACT_ACTIVE) - * { + * if (!getDolGlobalSring('LDAP_CONTACT_ACTIVE')) { * print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); * exit(-1); * } diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index f66df4b011d..24f1529d341 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -248,7 +248,7 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, } $newlangs = new Translate('', $conf); - $newlangs->setDefaultLang(empty($userlang) ? (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT) : $userlang); + $newlangs->setDefaultLang(empty($userlang) ? getDolGlobalString('MAIN_LANG_DEFAULT', 'auto') : $userlang); $newlangs->load("main"); $newlangs->load("contracts"); @@ -262,26 +262,26 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $title = $newlangs->transnoentities("ListOfServicesToExpire"); } - $subject = (!getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT') ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT); + $subject = getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT', $title); $sendto = $oldemail; - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); + $errorsto = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); $msgishtml = -1; print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; dol_syslog("email_expire_services_to_customers.php: send mail to ".$oldemail); $usehtml = 0; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) { + if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER'))) { $usehtml += 1; } - if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER)) { + if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER'))) { $usehtml += 1; } $allmessage = ''; if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER; + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER'); } else { $allmessage .= "Dear customer".($usehtml ? "
    \n" : "\n").($usehtml ? "
    \n" : "\n"); $allmessage .= "Please, find a summary of the services contracted by you that are about to expire.".($usehtml ? "
    \n" : "\n").($usehtml ? "
    \n" : "\n"); @@ -289,8 +289,8 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $allmessage .= $message.($usehtml ? "
    \n" : "\n"); // $allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"
    \n":"\n"); if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) { + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER'); + if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER'))) { $usehtml += 1; } } diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index 2fb61e73c85..a23bf01d942 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -197,7 +197,7 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, } $newlangs = new Translate('', $conf); - $newlangs->setDefaultLang(empty($userlang) ? (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT) : $userlang); + $newlangs->setDefaultLang(empty($userlang) ? getDolGlobalString('MAIN_LANG_DEFAULT', 'auto') : $userlang); $newlangs->load("main"); $newlangs->load("contracts"); @@ -213,24 +213,24 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $subject = (!getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT') ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT); $sendto = $oldemail; - $from = !getDolGlobalString('MAIN_MAIL_EMAIL_FROM') ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = !getDolGlobalString('MAIN_MAIL_ERRORS_TO') ? '' : $conf->global->MAIN_MAIL_ERRORS_TO; + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); + $errorsto = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); $msgishtml = -1; print "- Send email for ".$oldtarget." (".$oldemail."), total: ".$total."\n"; dol_syslog("email_expire_services_to_representatives.php: send mail to ".$oldemail); $usehtml = 0; - if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER') && dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER)) { + if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER') && dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'))) { $usehtml += 1; } - if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER') && dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) { + if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER') && dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER'))) { $usehtml += 1; } $allmessage = ''; if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER; + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER'); } else { $allmessage .= $title.($usehtml ? "
    \n" : "\n").($usehtml ? "
    \n" : "\n"); $allmessage .= $newlangs->transnoentities("NoteListOfYourExpiredServices").($usehtml ? "
    \n" : "\n").($usehtml ? "
    \n" : "\n"); @@ -238,8 +238,8 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $allmessage .= $message.($usehtml ? "
    \n" : "\n"); $allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, $conf->currency).($usehtml ? "
    \n" : "\n"); if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER)) { + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'); + if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'))) { $usehtml += 1; } } diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index 0375d6cc631..e6b99c51369 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -61,7 +61,7 @@ $month = dol_print_date($datetimeprev, "%m"); $year = dol_print_date($datetimeprev, "%Y"); $user = new User($db); -$user->fetch($conf->global->PRELEVEMENT_USER); +$user->fetch(getDolGlobalString('PRELEVEMENT_USER')); if (!isset($argv[1])) { // Check parameters print "This script check invoices with a withdrawal request and\n"; @@ -71,8 +71,7 @@ if (!isset($argv[1])) { // Check parameters } $withdrawreceipt = new BonPrelevement($db); -// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty -$result = $withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $argv[1]); +$result = $withdrawreceipt->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $argv[1]); $db->close(); From b6ca71ce9adc07363366f9a0df973cca577d2d6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 14:31:31 +0100 Subject: [PATCH 193/315] Debug v19 --- htdocs/comm/action/document.php | 46 ++++++++++++++++++---------- htdocs/comm/action/info.php | 46 ++++++++++++++++++---------- htdocs/resource/element_resource.php | 34 ++++++++++++++------ 3 files changed, 84 insertions(+), 42 deletions(-) diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 8493ba2abc9..1f46ee6df1b 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -148,31 +148,45 @@ if ($object->id > 0) { print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); - $linkback = img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="hideonsmartphone pictoactionview"'); - $linkback .= ''.$langs->trans("BackToList").''; - // Link to other agenda views - $out = ''; - $out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewPerUser").''; - $out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewCal").''; - $out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewWeek").''; - $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewDay").''; + $linkback .= ''; + $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); + $linkback .= ''.$langs->trans("BackToList").''; + $linkback .= ''; + $linkback .= '
  • '; + $linkback .= '
  • '; + $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"'); + $linkback .= ''.$langs->trans("ViewCal").''; + $linkback .= ''; + $linkback .= '
  • '; + $linkback .= '
  • '; + $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"'); + $linkback .= ''.$langs->trans("ViewWeek").''; + $linkback .= ''; + $linkback .= '
  • '; + $linkback .= '
  • '; + $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"'); + $linkback .= ''.$langs->trans("ViewDay").''; + $linkback .= ''; + $linkback .= '
  • '; + $linkback .= '
  • '; + $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"'); + $linkback .= ''.$langs->trans("ViewPerUser").''; + $linkback .= ''; // Add more views from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); if (empty($reshook)) { - $out .= $hookmanager->resPrint; + $linkback .= $hookmanager->resPrint; } elseif ($reshook > 1) { - $out = $hookmanager->resPrint; + $linkback = $hookmanager->resPrint; } - $linkback .= $out; - $morehtmlref = '
    '; // Thirdparty //$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 9d9baff3c3e..2301e3e329c 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -72,31 +72,45 @@ $object->info($object->id); $head = actions_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); -$linkback = img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="hideonsmartphone pictoactionview"'); -$linkback .= ''.$langs->trans("BackToList").''; - // Link to other agenda views -$out = ''; -$out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); -$out .= ''.$langs->trans("ViewPerUser").''; -$out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="hideonsmartphone pictoactionview"'); -$out .= ''.$langs->trans("ViewCal").''; -$out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); -$out .= ''.$langs->trans("ViewWeek").''; -$out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); -$out .= ''.$langs->trans("ViewDay").''; +$linkback .= ''; +$linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); +$linkback .= ''.$langs->trans("BackToList").''; +$linkback .= ''; +$linkback .= '
  • '; +$linkback .= '
  • '; +$linkback .= ''; +$linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"'); +$linkback .= ''.$langs->trans("ViewCal").''; +$linkback .= ''; +$linkback .= '
  • '; +$linkback .= '
  • '; +$linkback .= ''; +$linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"'); +$linkback .= ''.$langs->trans("ViewWeek").''; +$linkback .= ''; +$linkback .= '
  • '; +$linkback .= '
  • '; +$linkback .= ''; +$linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"'); +$linkback .= ''.$langs->trans("ViewDay").''; +$linkback .= ''; +$linkback .= '
  • '; +$linkback .= '
  • '; +$linkback .= ''; +$linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"'); +$linkback .= ''.$langs->trans("ViewPerUser").''; +$linkback .= ''; // Add more views from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); if (empty($reshook)) { - $out .= $hookmanager->resPrint; + $linkback .= $hookmanager->resPrint; } elseif ($reshook > 1) { - $out = $hookmanager->resPrint; + $linkback = $hookmanager->resPrint; } -$linkback .= $out; - $morehtmlref = '
    '; // Project if (isModEnabled('project')) { diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 7018a867e97..75cf03d1bb8 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -333,19 +333,33 @@ if (!$ret) { print dol_get_fiche_head($head, 'resources', $langs->trans("Action"), -1, 'action'); - $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); - $linkback .= ''.$langs->trans("BackToList").''; + $linkback .= ''; + $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); + $linkback .= ''.$langs->trans("BackToList").''; + $linkback .= ''; // Link to other agenda views $out = ''; - $out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewPerUser").''; - $out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewCal").''; - $out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewWeek").''; - $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); - $out .= ''.$langs->trans("ViewDay").''; + $out .= '
  • '; + $out .= ''; + $out .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictofixedwidth pictoactionview"'); + $out .= ''.$langs->trans("ViewCal").''; + $out .= ''; + $out .= '
  • '; + $out .= ''; + $out .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictofixedwidth pictoactionview"'); + $out .= ''.$langs->trans("ViewWeek").''; + $out .= ''; + $out .= '
  • '; + $out .= ''; + $out .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictofixedwidth pictoactionview"'); + $out .= ''.$langs->trans("ViewDay").''; + $out .= ''; + $out .= '
  • '; + $out .= ''; + $out .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictofixedwidth pictoactionview"'); + $out .= ''.$langs->trans("ViewPerUser").''; + $out .= ''; // Add more views from hooks $parameters = array(); From 29927b1660bada3660db1efba96b8de1e2da54f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 14:49:38 +0100 Subject: [PATCH 194/315] Fix warning --- ...ail_expire_services_to_representatives.php | 2 +- scripts/cron/cron_run_jobs.php | 6 +++--- scripts/emailings/mailing-send.php | 10 ++++----- .../email_unpaid_invoices_to_customers.php | 12 +++++------ ...ail_unpaid_invoices_to_representatives.php | 12 +++++------ .../members/sync_members_dolibarr2ldap.php | 5 ++--- .../members/sync_members_ldap2dolibarr.php | 4 ++-- .../sync_members_types_dolibarr2ldap.php | 3 +-- .../sync_members_types_ldap2dolibarr.php | 4 ++-- scripts/user/sync_groups_dolibarr2ldap.php | 3 +-- scripts/user/sync_groups_ldap2dolibarr.php | 4 ++-- scripts/user/sync_users_dolibarr2ldap.php | 3 +-- scripts/user/sync_users_ldap2dolibarr.php | 21 +++++++++---------- 13 files changed, 42 insertions(+), 47 deletions(-) diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index a23bf01d942..43c46c8a1b4 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -211,7 +211,7 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $title = $newlangs->transnoentities("ListOfServicesToExpire"); } - $subject = (!getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT') ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT); + $subject = getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT', $title); $sendto = $oldemail; $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); $errorsto = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 005c05a1de0..3aa4f601bc1 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -101,7 +101,7 @@ if (!isModEnabled('cron')) { } // Check security key -if ($key != $conf->global->CRON_KEY) { +if ($key != getDolGlobalString('CRON_KEY')) { print "Error: securitykey is wrong\n"; exit(-1); } @@ -142,7 +142,7 @@ if ($result < 0) { } // Reload langs -$langcode = (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); +$langcode = getDolGlobalString('MAIN_LANG_DEFAULT', 'auto'); if (!empty($user->conf->MAIN_LANG_DEFAULT)) { $langcode = $user->conf->MAIN_LANG_DEFAULT; } @@ -224,7 +224,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { } // Reload langs - $langcode = (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); + $langcode = getDolGlobalString('MAIN_LANG_DEFAULT', 'auto'); if (!empty($user->conf->MAIN_LANG_DEFAULT)) { $langcode = $user->conf->MAIN_LANG_DEFAULT; } diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index d24b3dfcd15..0e6d655468e 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -86,8 +86,8 @@ if (!isModEnabled('mailing')) { @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -if (getDolGlobalString('MAILING_DELAY')) { - print 'A delay of '.((float) $conf->global->MAILING_DELAY).' seconds has been set between each email'."\n"; +if (getDolGlobalInt('MAILING_DELAY')) { + print 'A delay of '.((float) getDolGlobalInt('MAILING_DELAY')).' seconds has been set between each email'."\n"; } if (getDolGlobalString('MAILING_LIMIT_SENDBYCLI') == '-1') { @@ -153,7 +153,7 @@ if ($resql) { if (getDolGlobalInt('MAILING_LIMIT_SENDBYCLI') > 0 && empty($max)) { $sql2 .= " LIMIT " . getDolGlobalString('MAILING_LIMIT_SENDBYCLI'); } elseif (getDolGlobalInt('MAILING_LIMIT_SENDBYCLI') > 0 && $max > 0) { - $sql2 .= " LIMIT ".min($conf->global->MAILING_LIMIT_SENDBYCLI, $max); + $sql2 .= " LIMIT ".min(getDolGlobalInt('MAILING_LIMIT_SENDBYCLI'), $max); } elseif ($max > 0) { $sql2 .= " LIMIT ".((int) $max); } @@ -383,8 +383,8 @@ if ($resql) { } } - if (getDolGlobalString('MAILING_DELAY')) { - usleep((float) $conf->global->MAILING_DELAY * 1000000); + if (getDolGlobalInt('MAILING_DELAY')) { + usleep((float) getDolGlobalInt('MAILING_DELAY') * 1000000); } } } else { diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 6d51a2bd24a..b9c44faf6b8 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -250,14 +250,14 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) } $newlangs = new Translate('', $conf); - $newlangs->setDefaultLang(empty($userlang) ? (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT) : $userlang); + $newlangs->setDefaultLang(empty($userlang) ? getDolGlobalString('MAIN_LANG_DEFAULT', 'auto') : $userlang); $newlangs->load("main"); $newlangs->load("bills"); - $subject = (!getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT') ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT); + $subject = getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT', $newlangs->trans("ListOfYourUnpaidInvoices")); $sendto = $oldemail; - $from = !getDolGlobalString('MAIN_MAIL_EMAIL_FROM') ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = !getDolGlobalString('MAIN_MAIL_ERRORS_TO') ? '' : $conf->global->MAIN_MAIL_ERRORS_TO; + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); + $errorsto = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); $msgishtml = -1; print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; @@ -282,8 +282,8 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) $allmessage .= $message.($usehtml ? "
    \n" : "\n"); $allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, $conf->currency).($usehtml ? "
    \n" : "\n"); if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) { + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'); + if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'))) { $usehtml += 1; } } diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 058966e6a2b..7336f2be259 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -206,14 +206,14 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) } $newlangs = new Translate('', $conf); - $newlangs->setDefaultLang(empty($userlang) ? (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT) : $userlang); + $newlangs->setDefaultLang(empty($userlang) ? getDolGlobalString('MAIN_LANG_DEFAULT', 'auto') : $userlang); $newlangs->load("main"); $newlangs->load("bills"); - $subject = (!getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT') ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT); + $subject = getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT', $newlangs->trans("ListOfYourUnpaidInvoices")); $sendto = $oldemail; - $from = !getDolGlobalString('MAIN_MAIL_EMAIL_FROM') ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = !getDolGlobalString('MAIN_MAIL_ERRORS_TO') ? '' : $conf->global->MAIN_MAIL_ERRORS_TO; + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); + $errorsto = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); $msgishtml = -1; print "- Send email for ".$oldtarget." (".$oldemail."), total: ".$total."\n"; @@ -237,8 +237,8 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) $allmessage .= $message.($usehtml ? "
    \n" : "\n"); $allmessage .= $langs->trans("Total")." = ".price($total, 0, $newlangs, 0, 0, -1, $conf->currency).($usehtml ? "
    \n" : "\n"); if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) { + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'); + if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'))) { $usehtml += 1; } } diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index dbeef136368..ae01a088393 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -90,7 +90,7 @@ print "----- To LDAP database:\n"; print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n"; print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n"; print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n"; -print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; +print "pass=".preg_replace('/./i', '*', getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; print "DN target=" . getDolGlobalString('LDAP_MEMBER_DN')."\n"; print "\n"; @@ -104,8 +104,7 @@ if (!$confirmed) { } /* - * if (! $conf->global->LDAP_MEMBER_ACTIVE) - * { + * if (getDolGlobalString('LDAP_MEMBER_ACTIVE') { * print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); * exit(-1); * } diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index d0496c9d7c0..b8bbabe5060 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -118,7 +118,7 @@ print "----- Synchronize all records from LDAP database:\n"; print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n"; print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n"; print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n"; -print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; +print "pass=".preg_replace('/./i', '*', getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; print "DN to extract=" . getDolGlobalString('LDAP_MEMBER_DN')."\n"; if (getDolGlobalString('LDAP_MEMBER_FILTER')) { print 'Filter=(' . getDolGlobalString('LDAP_MEMBER_FILTER').')'."\n"; // Note: filter is defined into function getRecords @@ -192,7 +192,7 @@ if ($result >= 0) { // We disable synchro Dolibarr-LDAP $conf->global->LDAP_MEMBER_ACTIVE = 0; - $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 'member'); // Fiter on 'member' filter param + $ldaprecords = $ldap->getRecords('*', getDolGlobalString('LDAP_MEMBER_DN'), getDolGlobalString('LDAP_KEY_MEMBERS'), $required_fields, 'member'); // Fiter on 'member' filter param if (is_array($ldaprecords)) { $db->begin(); diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 3ec2c9d0d90..5fd145e0926 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -63,8 +63,7 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); /* - * if (! $conf->global->LDAP_SYNCHRO_ACTIVE) - * { + * if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { * print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); * exit(-1); * } diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index a31d5a3c30c..eeaf1134613 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -100,7 +100,7 @@ print "----- Synchronize all records from LDAP database:\n"; print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n"; print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n"; print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n"; -print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; +print "pass=".preg_replace('/./i', '*', getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; print "DN to extract=" . getDolGlobalString('LDAP_MEMBER_TYPE_DN')."\n"; print 'Filter=(' . getDolGlobalString('LDAP_KEY_MEMBERS_TYPES').'=*)'."\n"; print "----- To Dolibarr database:\n"; @@ -132,7 +132,7 @@ if ($result >= 0) { // We disable synchro Dolibarr-LDAP $conf->global->LDAP_MEMBER_TYPE_ACTIVE = 0; - $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_MEMBER_TYPE_DN, $conf->global->LDAP_KEY_MEMBERS_TYPES, $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)); + $ldaprecords = $ldap->getRecords('*', getDolGlobalString('LDAP_MEMBER_TYPE_DN'), getDolGlobalString('LDAP_KEY_MEMBERS_TYPES'), $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)); if (is_array($ldaprecords)) { $db->begin(); diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index 7d9ed2f307e..2c37c96dd4e 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -61,8 +61,7 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); /* - * if (! $conf->global->LDAP_SYNCHRO_ACTIVE) - * { + * if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { * print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); * exit(-1); * } diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index fd718d132d0..e221e06b378 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -62,7 +62,7 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); // List of fields to get from LDAP -$required_fields = array($conf->global->LDAP_KEY_GROUPS, $conf->global->LDAP_GROUP_FIELD_FULLNAME, $conf->global->LDAP_GROUP_FIELD_DESCRIPTION, $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS); +$required_fields = array(getDolGlobalString('LDAP_KEY_GROUPS'), getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME'), getDolGlobalString('LDAP_GROUP_FIELD_DESCRIPTION'), getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated $required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement"))); @@ -95,7 +95,7 @@ print "----- Synchronize all records from LDAP database:\n"; print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n"; print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n"; print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n"; -print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; +print "pass=".preg_replace('/./i', '*', getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; print "DN to extract=" . getDolGlobalString('LDAP_GROUP_DN')."\n"; if (getDolGlobalString('LDAP_GROUP_FILTER')) { print 'Filter=(' . getDolGlobalString('LDAP_GROUP_FILTER').')'."\n"; // Note: filter is defined into function getRecords diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index abe0b9fbcf4..6ecad166ca1 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -61,8 +61,7 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); /* - * if (! $conf->global->LDAP_SYNCHRO_ACTIVE) - * { + * if (! getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { * print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); * exit(-1); * } diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 98c6a3b5519..2fa35556c8d 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -113,7 +113,7 @@ print "----- Synchronize all records from LDAP database:\n"; print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n"; print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n"; print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n"; -print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; +print "pass=".preg_replace('/./i', '*', getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; print "DN to extract=" . getDolGlobalString('LDAP_USER_DN')."\n"; if (getDolGlobalString('LDAP_FILTER_CONNECTION')) { print 'Filter=(' . getDolGlobalString('LDAP_FILTER_CONNECTION').')'."\n"; // Note: filter is defined into function getRecords @@ -177,7 +177,7 @@ if ($result >= 0) { // We disable synchro Dolibarr-LDAP $conf->global->LDAP_SYNCHRO_ACTIVE = 0; - $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 'user'); // Fiter on 'user' filter param + $ldaprecords = $ldap->getRecords('*', getDolGlobalString('LDAP_USER_DN'), getDolGlobalString('LDAP_KEY_USERS'), $required_fields, 'user'); // Fiter on 'user' filter param if (is_array($ldaprecords)) { $db->begin(); @@ -191,9 +191,9 @@ if ($result >= 0) { $fuser = new User($db); - if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) { + if (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_SID')) { $fuser->fetch('', '', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le SID - } elseif ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) { + } elseif (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_LOGIN')) { $fuser->fetch('', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le login } @@ -206,10 +206,10 @@ if ($result >= 0) { // $user->societe; /* - * $fuser->address=$ldapuser[$conf->global->LDAP_FIELD_ADDRESS]; - * $fuser->zip=$ldapuser[$conf->global->LDAP_FIELD_ZIP]; - * $fuser->town=$ldapuser[$conf->global->LDAP_FIELD_TOWN]; - * $fuser->country=$ldapuser[$conf->global->LDAP_FIELD_COUNTRY]; + * $fuser->address=$ldapuser[getDolGlobalString('LDAP_FIELD_ADDRESS')]; + * $fuser->zip=$ldapuser[getDolGlobalString('LDAP_FIELD_ZIP')]; + * $fuser->town=$ldapuser[getDolGlobalString('LDAP_FIELD_TOWN')]; + * $fuser->country=$ldapuser[getDolGlobalString('LDAP_FIELD_COUNTRY')]; * $fuser->country_id=$countries[$hashlib2rowid[strtolower($fuser->country)]]['rowid']; * $fuser->country_code=$countries[$hashlib2rowid[strtolower($fuser->country)]]['code']; */ @@ -230,8 +230,7 @@ if ($result >= 0) { $fuser->statut = 1; // TODO : revoir la gestion du status /* - * if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS])) - * { + * if (isset($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')])) { * $fuser->datec=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]); * $fuser->datevalid=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]); * $fuser->statut=$ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS]; @@ -269,7 +268,7 @@ if ($result >= 0) { // TODO : revoir la gestion des groupes (ou script de sync groupes) /* * if(!$error) { - * foreach ($ldapuser[$conf->global->LDAP_FIELD_USERGROUPS] as $groupdn) { + * foreach ($ldapuser[getDolGlobalString('LDAP_FIELD_USERGROUPS') as $groupdn) { * $groupdn; * } * } From 096a6251dd62a67a393b784f5b0a26079450df27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 14:54:38 +0100 Subject: [PATCH 195/315] Fix warnings --- scripts/invoices/email_unpaid_invoices_to_customers.php | 4 ++-- .../invoices/email_unpaid_invoices_to_representatives.php | 6 +++--- scripts/members/sync_members_ldap2dolibarr.php | 6 +++--- scripts/members/sync_members_types_ldap2dolibarr.php | 4 ++-- scripts/user/sync_groups_ldap2dolibarr.php | 2 +- scripts/user/sync_users_ldap2dolibarr.php | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index b9c44faf6b8..2a5a199db4d 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -264,10 +264,10 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) dol_syslog("email_unpaid_invoices_to_customers.php: send mail to ".$oldemail); $usehtml = 0; - if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER') && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) { + if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER') && dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'))) { $usehtml += 1; } - if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER') && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) { + if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER') && dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER'))) { $usehtml += 1; } diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 7336f2be259..e5da2436d67 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -220,16 +220,16 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to ".$oldemail); $usehtml = 0; - if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER') && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) { + if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER') && dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'))) { $usehtml += 1; } - if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER') && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) { + if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER') && dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER'))) { $usehtml += 1; } $allmessage = ''; if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER')) { - $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER; + $allmessage .= getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER'); } else { $allmessage .= $newlangs->transnoentities("ListOfYourUnpaidInvoices").($usehtml ? "
    \n" : "\n").($usehtml ? "
    \n" : "\n"); $allmessage .= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices").($usehtml ? "
    \n" : "\n"); diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index b8bbabe5060..90dd86b0ad6 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -253,16 +253,16 @@ if ($result >= 0) { // print_r($member); $datefirst = ''; - if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE) { + if (getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) { $datefirst = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')]); $pricefirst = price2num($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')]); } $datelast = ''; - if ($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE) { + if (getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) { $datelast = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')]); $pricelast = price2num($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')]); - } elseif ($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) { + } elseif (getDolGlobalString('LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) { $datelast = dol_time_plus_duree(dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')]), -1, 'y') + 60 * 60 * 24; $pricelast = price2num($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')]); diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index eeaf1134613..8d4624bbc55 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -62,7 +62,7 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); // List of fields to get from LDAP -$required_fields = array($conf->global->LDAP_KEY_MEMBERS_TYPES, $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME, $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION, $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS); +$required_fields = array(getDolGlobalString('LDAP_KEY_MEMBERS_TYPES'), getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME'), getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION'), getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS')); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated $required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElementType"))); @@ -132,7 +132,7 @@ if ($result >= 0) { // We disable synchro Dolibarr-LDAP $conf->global->LDAP_MEMBER_TYPE_ACTIVE = 0; - $ldaprecords = $ldap->getRecords('*', getDolGlobalString('LDAP_MEMBER_TYPE_DN'), getDolGlobalString('LDAP_KEY_MEMBERS_TYPES'), $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)); + $ldaprecords = $ldap->getRecords('*', getDolGlobalString('LDAP_MEMBER_TYPE_DN'), getDolGlobalString('LDAP_KEY_MEMBERS_TYPES'), $required_fields, 0, array(getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS'))); if (is_array($ldaprecords)) { $db->begin(); diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index e221e06b378..88d39ea2cd5 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -131,7 +131,7 @@ if ($result >= 0) { // We disable synchro Dolibarr-LDAP $conf->global->LDAP_SYNCHRO_ACTIVE = 0; - $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 'group', array($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)); + $ldaprecords = $ldap->getRecords('*', getDolGlobalString('LDAP_GROUP_DN'), getDolGlobalString('LDAP_KEY_GROUPS'), $required_fields, 'group', array(getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS'))); if (is_array($ldaprecords)) { $db->begin(); diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 2fa35556c8d..34e0c0b4382 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -233,7 +233,7 @@ if ($result >= 0) { * if (isset($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')])) { * $fuser->datec=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]); * $fuser->datevalid=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]); - * $fuser->statut=$ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS]; + * $fuser->statut=$ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')]; * } */ // if ($fuser->statut > 1) $fuser->statut=1; From 04c9b4137087d47f7a1d7fd456f56984bb4ae1ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 21:59:08 +0100 Subject: [PATCH 196/315] Enhance rector cleaning code --- dev/tools/rector/rector.php | 9 ++++- .../rector/src/Renaming/GlobalToFunction.php | 37 ++++++++++++++++++- htdocs/core/class/CMailFile.class.php | 4 +- scripts/emailings/mailing-send.php | 20 +++++----- 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php index 6b13c2fbf0b..b4a07cf1b96 100644 --- a/dev/tools/rector/rector.php +++ b/dev/tools/rector/rector.php @@ -39,9 +39,16 @@ return static function (RectorConfig $rectorConfig): void { //$rectorConfig->rule(Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class); //$rectorConfig->rule(Rector\Php72\Rector\Assign\ListEachRector::class); //$rectorConfig->rule(Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class); - //$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class); //$rectorConfig->rule(Rector\Php72\Rector\FuncCall\StringifyDefineRector::class); + //$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class); + + $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class); + $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class); + $rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class); + //$rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class); + $rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class); + $rectorConfig->rule(Dolibarr\Rector\Renaming\GlobalToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index 0c0cd9c7cc8..03760b6fe48 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -12,6 +12,7 @@ use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\Empty_; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Isset_; +use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; @@ -72,7 +73,7 @@ class GlobalToFunction extends AbstractRector */ public function getNodeTypes(): array { - return [FuncCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; + return [FuncCall::class, MethodCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; } /** @@ -104,7 +105,8 @@ class GlobalToFunction extends AbstractRector if ($node instanceof FuncCall) { $tmpfunctionname = $this->getName($node); // If function is ok. We must avoid a lot of cases like isset(), empty() - if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) { + if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'dol_hash', 'make_substitutions', 'min', 'max', 'explode'))) { + //print "tmpfunctionname=".$tmpfunctionname."\n"; $args = $node->getArgs(); $nbofparam = count($args); @@ -130,6 +132,37 @@ class GlobalToFunction extends AbstractRector return $node; } + if ($node instanceof MethodCall) { + $tmpmethodname = $this->getName($node->name); + // If function is ok. We must avoid a lot of cases + if (in_array($tmpmethodname, array('idate'))) { + //print "tmpmethodname=".$tmpmethodname."\n"; + $expr = $node->var; + $args = $node->getArgs(); + $nbofparam = count($args); + + if ($nbofparam >= 1) { + $tmpargs = $args; + foreach ($args as $key => $arg) { // only 1 element in this array + //var_dump($key); + //var_dump($arg->value);exit; + if ($this->isGlobalVar($arg->value)) { + $constName = $this->getConstName($arg->value); + if (empty($constName)) { + return; + } + $a = new FuncCall(new Name('getDolGlobalString'), [new Arg($constName)]); + $tmpargs[$key] = new Arg($a); + + $r = new MethodCall($expr, $tmpmethodname, $tmpargs); + return $r; + } + } + } + } + return $node; + } + if ($node instanceof Concat) { if ($this->isGlobalVar($node->left)) { $constName = $this->getConstName($node->left); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index f09fb48493d..bb1d56a36fc 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1137,7 +1137,7 @@ class CMailFile dol_syslog("CMailFile::sendfile: mail end error=".$e->getMessage(), LOG_ERR); } } - if (!empty($conf->global->$keyforsslseflsigned)) { + if (getDolGlobalString($keyforsslseflsigned)) { $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false))); } //$smtps->_msgReplyTo = 'reply@web.com'; @@ -1150,7 +1150,7 @@ class CMailFile $this->mailer = new Swift_Mailer($this->transport); // DKIM SIGN - if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { + if (getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_ENABLED')) { $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 0e6d655468e..77871ecbf0b 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -244,12 +244,12 @@ if ($resql) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && getDolGlobalString('PAYMENT_SECURITY_TOKEN')) { - $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'order'.$obj->source_id, 2); @@ -259,28 +259,28 @@ if ($resql) { } /* For backward compatibility */ if (isModEnabled('paypal') && getDolGlobalString('PAYPAL_SECURITY_TOKEN')) { - $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'order'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'invoice'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'contractline'.$obj->source_id, 2); } From b75cbc54a8dd90624f78fb093d466628817e5ffc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 21:59:08 +0100 Subject: [PATCH 197/315] Enhance rector cleaning code --- dev/initdata/generate-proposal.php | 2 +- dev/initdata/import-thirdparties.php | 2 +- dev/tools/rector/rector.php | 11 +++++- .../rector/src/Renaming/GlobalToFunction.php | 37 ++++++++++++++++++- htdocs/core/class/CMailFile.class.php | 4 +- scripts/emailings/mailing-send.php | 20 +++++----- 6 files changed, 59 insertions(+), 17 deletions(-) diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index cf9a708de9e..3c357949e28 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -152,7 +152,7 @@ $user->rights->propal->creer=1; $user->rights->propal->propal_advance->validate=1; -if (!empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/" . getDolGlobalString('PROPALE_ADDON').".php")) { +if (getDolGlobalString('PROPALE_ADDON') && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/" . getDolGlobalString('PROPALE_ADDON').".php")) { require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/" . getDolGlobalString('PROPALE_ADDON').".php"; } diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php index 5a5bde31905..a0e40d7b883 100755 --- a/dev/initdata/import-thirdparties.php +++ b/dev/initdata/import-thirdparties.php @@ -129,7 +129,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) $object->fournisseur = $fields[8]; $object->name = $fields[13] ? trim($fields[13]) : $fields[0]; - $object->name_alias = $fields[0]!=$fields[13] ? trim($fields[0]) : ''; + $object->name_alias = $fields[0] != $fields[13] ? trim($fields[0]) : ''; $object->address = trim($fields[14]); $object->zip = trim($fields[15]); diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php index 6b13c2fbf0b..acdc4cade86 100644 --- a/dev/tools/rector/rector.php +++ b/dev/tools/rector/rector.php @@ -26,6 +26,8 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->skip([ '**/includes/**', '**/custom/**', + '**/vendor/**', + '**/rector/**', // Disable this line to test the "test.php" file. __DIR__ . '/../../../htdocs/custom/', __DIR__ . '/../../../htdocs/install/doctemplates/*' ]); @@ -39,9 +41,16 @@ return static function (RectorConfig $rectorConfig): void { //$rectorConfig->rule(Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class); //$rectorConfig->rule(Rector\Php72\Rector\Assign\ListEachRector::class); //$rectorConfig->rule(Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class); - //$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class); //$rectorConfig->rule(Rector\Php72\Rector\FuncCall\StringifyDefineRector::class); + //$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class); + + $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class); + $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class); + $rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class); + //$rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class); + $rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class); + $rectorConfig->rule(Dolibarr\Rector\Renaming\GlobalToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index 0c0cd9c7cc8..03760b6fe48 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -12,6 +12,7 @@ use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\Empty_; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Isset_; +use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; @@ -72,7 +73,7 @@ class GlobalToFunction extends AbstractRector */ public function getNodeTypes(): array { - return [FuncCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; + return [FuncCall::class, MethodCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; } /** @@ -104,7 +105,8 @@ class GlobalToFunction extends AbstractRector if ($node instanceof FuncCall) { $tmpfunctionname = $this->getName($node); // If function is ok. We must avoid a lot of cases like isset(), empty() - if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) { + if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'dol_hash', 'make_substitutions', 'min', 'max', 'explode'))) { + //print "tmpfunctionname=".$tmpfunctionname."\n"; $args = $node->getArgs(); $nbofparam = count($args); @@ -130,6 +132,37 @@ class GlobalToFunction extends AbstractRector return $node; } + if ($node instanceof MethodCall) { + $tmpmethodname = $this->getName($node->name); + // If function is ok. We must avoid a lot of cases + if (in_array($tmpmethodname, array('idate'))) { + //print "tmpmethodname=".$tmpmethodname."\n"; + $expr = $node->var; + $args = $node->getArgs(); + $nbofparam = count($args); + + if ($nbofparam >= 1) { + $tmpargs = $args; + foreach ($args as $key => $arg) { // only 1 element in this array + //var_dump($key); + //var_dump($arg->value);exit; + if ($this->isGlobalVar($arg->value)) { + $constName = $this->getConstName($arg->value); + if (empty($constName)) { + return; + } + $a = new FuncCall(new Name('getDolGlobalString'), [new Arg($constName)]); + $tmpargs[$key] = new Arg($a); + + $r = new MethodCall($expr, $tmpmethodname, $tmpargs); + return $r; + } + } + } + } + return $node; + } + if ($node instanceof Concat) { if ($this->isGlobalVar($node->left)) { $constName = $this->getConstName($node->left); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index f09fb48493d..bb1d56a36fc 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1137,7 +1137,7 @@ class CMailFile dol_syslog("CMailFile::sendfile: mail end error=".$e->getMessage(), LOG_ERR); } } - if (!empty($conf->global->$keyforsslseflsigned)) { + if (getDolGlobalString($keyforsslseflsigned)) { $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false))); } //$smtps->_msgReplyTo = 'reply@web.com'; @@ -1150,7 +1150,7 @@ class CMailFile $this->mailer = new Swift_Mailer($this->transport); // DKIM SIGN - if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { + if (getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_ENABLED')) { $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 0e6d655468e..77871ecbf0b 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -244,12 +244,12 @@ if ($resql) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && getDolGlobalString('PAYMENT_SECURITY_TOKEN')) { - $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'order'.$obj->source_id, 2); @@ -259,28 +259,28 @@ if ($resql) { } /* For backward compatibility */ if (isModEnabled('paypal') && getDolGlobalString('PAYPAL_SECURITY_TOKEN')) { - $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'order'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'invoice'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'contractline'.$obj->source_id, 2); } From 89686e74dc5a7634191108f0b3ada6f08a43eb40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Dec 2023 22:32:46 +0100 Subject: [PATCH 198/315] Clean code --- htdocs/accountancy/bookkeeping/card.php | 12 ++++++------ htdocs/accountancy/class/accountancyimport.class.php | 8 ++++---- htdocs/accountancy/customer/index.php | 10 +++++----- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/index.php | 6 +++--- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/journal/expensereportsjournal.php | 2 +- htdocs/accountancy/supplier/index.php | 8 ++++---- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/adherents/class/adherentstats.class.php | 4 ++-- htdocs/admin/barcode.php | 2 +- htdocs/admin/chequereceipts.php | 2 +- htdocs/admin/facture.php | 2 +- htdocs/admin/payment.php | 2 +- htdocs/admin/perms.php | 4 ++-- htdocs/admin/supplier_payment.php | 2 +- 16 files changed, 35 insertions(+), 35 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 657ab76baf5..6ebc4b218bd 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -103,7 +103,7 @@ if ($cancel) { if ($action == "confirm_update") { $error = 0; - if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { + if (((float) $debit != 0.0) && ((float) $credit != 0.0)) { $error++; setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $action = 'update'; @@ -130,12 +130,12 @@ if ($action == "confirm_update") { $object->debit = $debit; $object->credit = $credit; - if (floatval($debit) != 0.0) { + if ((float) $debit != 0.0) { $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } - if (floatval($credit) != 0.0) { + if ((float) $credit != 0.0) { $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; @@ -159,7 +159,7 @@ if ($action == "confirm_update") { } elseif ($action == "add") { $error = 0; - if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { + if (((float) $debit != 0.0) && ((float) $credit != 0.0)) { $error++; setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $action = ''; @@ -189,13 +189,13 @@ if ($action == "confirm_update") { $object->fk_doc = GETPOSTINT('fk_doc'); $object->fk_docdet = GETPOSTINT('fk_docdet'); - if (floatval($debit) != 0.0) { + if ((float) $debit != 0.0) { $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } - if (floatval($credit) != 0.0) { + if ((float) $credit != 0.0) { $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php index 5f4d76bc4c5..cc21b5ccf6e 100644 --- a/htdocs/accountancy/class/accountancyimport.class.php +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -66,7 +66,7 @@ class AccountancyImport public function cleanAmount(&$arrayrecord, $listfields, $record_key) { $value_trim = trim($arrayrecord[$record_key]['val']); - return floatval($value_trim); + return (float) $value_trim; } /** @@ -98,8 +98,8 @@ class AccountancyImport $debit_index = $field_index_list['debit']; $credit_index = $field_index_list['credit']; - $debit = floatval($arrayrecord[$debit_index]['val']); - $credit = floatval($arrayrecord[$credit_index]['val']); + $debit = (float) $arrayrecord[$debit_index]['val']; + $credit = (float) $arrayrecord[$credit_index]['val']; if (!empty($debit)) { $amount = $debit; } else { @@ -127,7 +127,7 @@ class AccountancyImport if (isset($field_index_list['debit'])) { $debit_index = $field_index_list['debit']; - $debit = floatval($arrayrecord[$debit_index]['val']); + $debit = (float) $arrayrecord[$debit_index]['val']; if (!empty($debit)) { $sens = 'D'; } else { diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 5bfa1435df6..3a9eced377c 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -165,7 +165,7 @@ if ($action == 'validatehistory') { $sql .= " AND l.product_type <= 2"; $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } if ($validatemonth && $validateyear) { $sql .= dolSqlDateFilter('f.datef', 0, $validatemonth, $validateyear); @@ -371,7 +371,7 @@ $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND f.fk_statut > 0"; $sql .= " AND fd.product_type <= 2"; @@ -508,7 +508,7 @@ $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; @@ -613,7 +613,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; @@ -710,7 +710,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 26d3c32b512..4976c285dc0 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -76,7 +76,7 @@ $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Define begin binding date if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING); + $search_date_start = $db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING')); } // Load variable for pagination diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 5c2ca5d52bf..97741175372 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -247,7 +247,7 @@ $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy @@ -358,7 +358,7 @@ $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy @@ -444,7 +444,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index e22581aebde..a5a67770361 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -69,7 +69,7 @@ $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_en // Define begin binding date if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING); + $search_date_start = $db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING')); } // Load variable for pagination diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index e553be8e1bb..a1bf3006328 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -133,7 +133,7 @@ if ($date_start && $date_end) { } // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } // Already in bookkeeping or not if ($in_bookkeeping == 'already') { diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 6c91aa09a95..562d4f73e9d 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -163,7 +163,7 @@ if ($action == 'validatehistory') { $sql .= " AND l.product_type <= 2"; $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } if ($validatemonth && $validateyear) { $sql .= dolSqlDateFilter('f.datef', 0, $validatemonth, $validateyear); @@ -364,7 +364,7 @@ $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND ff.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; @@ -496,7 +496,7 @@ $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND ff.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; @@ -589,7 +589,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + $sql .= " AND ff.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index e3fa96d9fb1..a3bc6ce2ade 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1412,7 +1412,7 @@ class Adherent extends CommonObject $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != "Civility".$obj->civility_code ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 8ae8c77146c..b2644ec7c19 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -231,7 +231,7 @@ class AdherentStats extends Stats ); $totalrow = 0; foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { - if ($key!='label') { + if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; } @@ -311,7 +311,7 @@ class AdherentStats extends Stats ); $totalrow = 0; foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) { - if ($key!='label') { + if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; } diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 2c1cf0bef0b..9a476798c20 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -162,7 +162,7 @@ foreach ($dirbarcode as $reldir) { $handle = @opendir($newdir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { + if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') { if (is_readable($newdir.$file)) { if (preg_match('/(.*)\.modules\.php$/i', $file, $reg)) { $filebis = $reg[1]; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 01dd7dcd2db..ec4bb7cf47d 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -130,7 +130,7 @@ foreach ($dirmodels as $reldir) { $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { + if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) { $filebis = $file; $name = substr($file, 4, dol_strlen($file) - 16); $classname = preg_replace('/\.php$/', '', $file); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 036b0661c52..3384a0d31d6 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -310,7 +310,7 @@ foreach ($dirmodels as $reldir) { $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { + if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index f9e04d6f305..5fd744ca88b 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -134,7 +134,7 @@ foreach ($dirmodels as $reldir) { $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { + if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 4a284a9bf6d..c89c7ad914c 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -193,7 +193,7 @@ if ($result) { } // Break found, it's a new module to catch - if (isset($obj->module) && ($oldmod <> $obj->module)) { + if (isset($obj->module) && ($oldmod != $obj->module)) { $oldmod = $obj->module; // Break detected, we get objMod @@ -248,7 +248,7 @@ if ($result) { } // Permission and tick - $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); + $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != "PermissionAdvanced".$obj->id) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != "Permission".$obj->id) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); print '
  • '; print $permlabel; if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index df24830d98d..c1e01049a65 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -209,7 +209,7 @@ foreach ($dirmodels as $reldir) { $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { + if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility From b28ae5d8d3f93e8b83d11c9878f959d25ed5fdee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 12:12:20 +0100 Subject: [PATCH 199/315] Clean code --- htdocs/bom/tpl/objectline_create.tpl.php | 2 +- htdocs/comm/mailing/card.php | 22 +++++++++---------- htdocs/comm/mailing/cibles.php | 2 +- htdocs/comm/mailing/index.php | 2 +- htdocs/comm/remx.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/commande/list_det.php | 2 +- htdocs/compta/facture/card.php | 6 ++--- htdocs/compta/facture/class/facture.class.php | 12 +++++----- htdocs/compta/paiement.php | 4 ++-- htdocs/compta/paiement/card.php | 2 +- .../cheque/class/remisecheque.class.php | 4 ++-- .../compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/paiement_vat.php | 2 +- .../class/bonprelevement.class.php | 2 +- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/compta/sociales/card.php | 2 +- .../class/paymentsocialcontribution.class.php | 2 +- htdocs/compta/tva/card.php | 2 +- htdocs/compta/tva/class/paymentvat.class.php | 2 +- htdocs/compta/tva/class/tva.class.php | 6 ++--- htdocs/contact/class/contact.class.php | 2 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/cunits.class.php | 6 ++--- htdocs/core/class/discount.class.php | 2 -- htdocs/core/class/extrafields.class.php | 6 ++--- htdocs/core/class/html.form.class.php | 12 +++++----- htdocs/core/class/html.formadmin.class.php | 4 ++-- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 8 +++---- htdocs/core/class/lessc.class.php | 8 +++---- .../connectors/php/connector.lib.php | 2 +- htdocs/core/lib/date.lib.php | 2 +- htdocs/core/lib/doleditor.lib.php | 4 ++-- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/functions2.lib.php | 6 ++--- htdocs/core/lib/memory.lib.php | 2 +- htdocs/core/lib/payments.lib.php | 2 +- htdocs/core/lib/pdf.lib.php | 4 ++-- htdocs/core/lib/project.lib.php | 22 +++++++++---------- htdocs/core/lib/usergroups.lib.php | 4 ++-- htdocs/core/lib/website2.lib.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 8 +++---- .../barcode/mod_barcode_product_standard.php | 2 +- .../mod_barcode_thirdparty_standard.php | 2 +- .../commande/doc/pdf_einstein.modules.php | 6 ++--- .../commande/doc/pdf_eratosthene.modules.php | 6 ++--- .../modules/facture/doc/pdf_crabe.modules.php | 4 ++-- .../facture/doc/pdf_sponge.modules.php | 4 ++-- .../modules/mailings/contacts1.modules.php | 2 +- .../mailings/eventorganization.modules.php | 2 +- .../core/modules/mailings/fraise.modules.php | 2 +- .../modules/mailings/partnership.modules.php | 2 +- .../core/modules/mailings/pomme.modules.php | 2 +- .../modules/mailings/thirdparties.modules.php | 6 ++--- .../thirdparties_services_expired.modules.php | 2 +- .../modules/mailings/xinputfile.modules.php | 2 +- .../modules/mrp/doc/pdf_vinci.modules.php | 4 ++-- .../modules/propale/doc/pdf_azur.modules.php | 6 ++--- .../modules/propale/doc/pdf_cyan.modules.php | 6 ++--- .../modules/rapport/pdf_paiement.class.php | 4 ++-- .../societe/mod_codeclient_elephant.php | 2 +- .../modules/societe/mod_codeclient_monkey.php | 2 +- .../societe/mod_codecompta_digitaria.php | 2 +- .../doc/pdf_eagle_proforma.modules.php | 6 ++--- .../supplier_order/doc/pdf_cornas.modules.php | 4 ++-- .../doc/pdf_muscadet.modules.php | 4 ++-- .../doc/pdf_aurore.modules.php | 4 ++-- .../doc/pdf_zenith.modules.php | 4 ++-- htdocs/don/card.php | 2 +- htdocs/expedition/list.php | 2 +- htdocs/expensereport/card.php | 2 +- htdocs/expensereport/payment/list.php | 2 +- htdocs/fichinter/card.php | 2 +- htdocs/fourn/class/paiementfourn.class.php | 6 ++--- htdocs/fourn/facture/paiement.php | 2 +- htdocs/fourn/paiement/card.php | 2 +- htdocs/fourn/paiement/document.php | 2 +- htdocs/fourn/paiement/list.php | 2 +- htdocs/install/step2.php | 4 ++-- htdocs/install/step5.php | 2 +- .../knowledgerecord_list.php | 2 +- htdocs/loan/payment/payment.php | 2 +- .../mailinglist_mymodule_myobject.modules.php | 2 +- htdocs/mrp/class/api_mos.class.php | 2 +- htdocs/product/card.php | 6 ++--- htdocs/product/class/product.class.php | 22 +++++++++---------- htdocs/product/list.php | 2 +- htdocs/product/stock/card.php | 2 +- htdocs/product/stock/massstockmove.php | 2 +- htdocs/public/agenda/agendaexport.php | 2 +- .../public/eventorganization/attendee_new.php | 14 ++++++------ htdocs/public/project/suggestbooth.php | 6 ++--- htdocs/reception/list.php | 2 +- htdocs/resource/class/dolresource.class.php | 2 +- htdocs/salaries/card.php | 2 +- htdocs/salaries/class/salary.class.php | 6 ++--- htdocs/salaries/virement_request.php | 2 +- .../canvas/company/tpl/card_view.tpl.php | 4 ++-- .../canvas/individual/tpl/card_view.tpl.php | 4 ++-- htdocs/societe/class/societe.class.php | 6 ++--- htdocs/takepos/admin/terminal.php | 2 +- htdocs/takepos/ajax/ajax.php | 2 +- htdocs/takepos/index.php | 4 ++-- htdocs/takepos/invoice.php | 2 +- htdocs/ticket/class/ticket.class.php | 18 +++++++-------- htdocs/user/card.php | 6 ++--- htdocs/user/clicktodial.php | 2 +- htdocs/user/document.php | 2 +- htdocs/user/group/perms.php | 4 ++-- htdocs/user/param_ihm.php | 2 +- htdocs/user/perms.php | 6 ++--- .../class/ProductCombination.class.php | 12 +++++----- htdocs/webservices/server_payment.php | 2 +- 115 files changed, 238 insertions(+), 240 deletions(-) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 3c96a80926f..db3991eac7d 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -127,7 +127,7 @@ if (isModEnabled("product") || isModEnabled("service")) { echo ''; } -if (getDolGlobalString('BOM_SUB_BOM') && $filtertype!=1) { +if (getDolGlobalString('BOM_SUB_BOM') && $filtertype != 1) { print '
    '.$langs->trans("or").'
    '.$langs->trans("BOM"); print $form->select_bom('', 'bom_id', 0, 1, 0, '1', '', 1); } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 40140b43167..1a9286c6091 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -285,13 +285,13 @@ if (empty($reshook)) { $substitutionarray['__ONLINEPAYMENTLINK_INVOICE__'] = getHtmlOnlinePaymentLink('invoice', $obj->source_id); $substitutionarray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getHtmlOnlinePaymentLink('contractline', $obj->source_id); - $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'member'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'donation'.$obj->source_id, 2); @@ -305,28 +305,28 @@ if (empty($reshook)) { } /* For backward compatibility, deprecated */ if (isModEnabled('paypal') && getDolGlobalString('PAYPAL_SECURITY_TOKEN')) { - $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'order'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'invoice'.$obj->source_id, 2); } if (!getDolGlobalString('PAYPAL_SECURITY_TOKEN_UNIQUE')) { - $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN'), 2); } else { $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'contractline'.$obj->source_id, 2); } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 9139e41d189..5b708cb3995 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -430,7 +430,7 @@ if ($object->fetch($id) >= 0) { $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { + if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') { $reg = array(); if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) { if ($reg[1] == 'example') { diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index cf3d18adbac..1f28a16a9d3 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -86,7 +86,7 @@ $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { + if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') { if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) { $modulename = $reg[1]; if ($modulename == 'example') { diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 39bd6bb44a5..a3da222a216 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -206,7 +206,7 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' $db->begin(); $discount = new DiscountAbsolute($db); - $result = $discount->fetch(GETPOST("remid")); + $result = $discount->fetch(GETPOSTINT("remid")); $result = $discount->delete($user); if ($result > 0) { $db->commit(); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d3cbb3c2367..aec3c8390f1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -893,7 +893,7 @@ if ($sall) { if ($search_billed != '' && $search_billed >= 0) { $sql .= ' AND c.facture = '.((int) $search_billed); } -if ($search_status <> '') { +if ($search_status != '') { if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) if ($search_status == 1 && !isModEnabled('expedition')) { $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 80fff860a05..61a363ae3fa 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -470,7 +470,7 @@ if ($sall) { if ($search_billed != '' && $search_billed >= 0) { $sql .= ' AND c.facture = '.((int) $search_billed); } -if ($search_status <> '') { +if ($search_status != '') { if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) if ($search_status == 1 && !isModEnabled('expedition')) { $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ba3707fd1bf..3a2d80e8709 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2757,7 +2757,7 @@ if (empty($reshook)) { $all_progress = GETPOST('all_progress', 'int'); foreach ($object->lines as $line) { $percent = $line->get_prev_progress($object->id); - if (floatval($all_progress) < floatval($percent)) { + if ((float) $all_progress < (float) $percent) { $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $result = -1; @@ -3847,7 +3847,7 @@ if ($action == 'create') { if($( this ).prop("checked") && $.inArray($( this ).val(), '.json_encode($retainedWarrantyInvoiceAvailableType).' ) !== -1) { $(".retained-warranty-line").show(); - $("#new-situation-invoice-retained-warranty").val("'.floatval($retained_warranty_js_default).'"); + $("#new-situation-invoice-retained-warranty").val("'.(float) $retained_warranty_js_default.'"); } else{ $(".retained-warranty-line").hide(); @@ -5264,7 +5264,7 @@ if ($action == 'create') { } print '
    '.dol_escape_htmltag($label.' '.$objp->num_payment).'
    '.$langs->trans('PaymentMode').''.$labeltype; print $object->num_payment ? ' - '.$object->num_payment : ''; print '
    '; - if ($sumpaid <> $objp->amount) { + if ($sumpaid != $objp->amount) { $namef = "amount_".$objp->id; $nameRemain = "remain_".$objp->id; /* Disabled, we autofil the amount with remain to pay by default diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 48b82d45d8a..cee1d06260a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1309,7 +1309,7 @@ class BonPrelevement extends CommonObject */ $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type, $sourcetype); - if ($ri <> 0) { + if ($ri != 0) { $error++; } diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 6be43d6525d..2471ade63ee 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -375,7 +375,7 @@ if ($modecompta == 'BOOKKEEPING') { } - if ($showaccountdetail == 'all' || $resultN <> 0) { + if ($showaccountdetail == 'all' || $resultN != 0) { print '
        '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."'.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."
    '; print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."'.price($objp->amount)."
    '.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."'.$payment_type.' '.dol_trunc($objp->num_payment, 32).'
    '; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 4ca0db593c5..a9e401840fe 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -243,7 +243,7 @@ class PaiementFourn extends Paiement $this->db->begin(); - if ($totalamount <> 0) { // On accepte les montants negatifs + if ($totalamount != 0) { // On accepte les montants negatifs $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); if ($way == 'dolibarr') { @@ -266,7 +266,7 @@ class PaiementFourn extends Paiement // Insere tableau des montants / factures foreach ($this->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) { + if (is_numeric($amount) && $amount != 0) { $amount = price2num($amount); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).', '.($currencyofpayment ? "'".$this->db->escape($currencyofpayment)."'" : 'NULL').', '.(!empty($currencytxofpayment) ? (float) $currencytxofpayment : 1).')'; @@ -408,7 +408,7 @@ class PaiementFourn extends Paiement $error++; } - if ($totalamount <> 0 && $error == 0) { // On accepte les montants negatifs + if ($totalamount != 0 && $error == 0) { // On accepte les montants negatifs $this->amount = $total; $this->total = $total; $this->multicurrency_amount = $mtotal; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index d275fe0a94e..de1e9ae45ae 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -346,7 +346,7 @@ if (empty($reshook)) { $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; - if (is_numeric($amount) && $amount <> 0) { + if (is_numeric($amount) && $amount != 0) { if ($invoiceid != 0) { $invoiceid = -1; // There is more than one invoice payed by this payment } else { diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index e6112780885..93de58280d7 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -205,7 +205,7 @@ if ($result > 0) { print ''; // Payment mode - $labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; + $labeltype = $langs->trans("PaymentType".$object->type_code) != "PaymentType".$object->type_code ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; print ''; print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 25b970a77da..d0b5b20610e 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -193,7 +193,7 @@ if ($action == "set") { if ($fp) { while (!feof($fp)) { $buf = fgets($fp, 4096); - if (substr($buf, 0, 2) <> '--') { + if (substr($buf, 0, 2) != '--') { $buf = preg_replace('/--(.+)*/', '', $buf); $buffer .= $buf; } @@ -405,7 +405,7 @@ if ($action == "set") { $buffer = ''; while (!feof($fp)) { $buf = fgets($fp, 4096); - if (substr($buf, 0, 2) <> '--') { + if (substr($buf, 0, 2) != '--') { $buffer .= $buf."§"; } } diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 6e101a7e3c3..20035b2f935 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -103,7 +103,7 @@ $error = 0; // If install, check password and password_verification used to create admin account if ($action == "set") { - if ($pass <> $pass_verif) { + if ($pass != $pass_verif) { header("Location: step4.php?error=1&selectlang=$setuplang".(isset($login) ? '&login='.$login : '')); exit; } diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 1014f3f367b..ce19af91590 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -102,7 +102,7 @@ $search_all = GETPOST('search_all', 'alphanohtml'); $search = array(); foreach ($object->fields as $key => $val) { if ($key == "lang") { - $search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : ''; + $search[$key] = GETPOST('search_'.$key, 'alpha') != '0' ? GETPOST('search_'.$key, 'alpha') : ''; } else { $search[$key] = GETPOST('search_'.$key, 'alpha'); } diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 885440a6812..1285b09c9cc 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -177,7 +177,7 @@ if ($action == 'add_payment') { // Update loan schedule with payment value if (!$error && !empty($line)) { // If payment values are modified, recalculate schedule - if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) { + if (($line->amount_capital != $pay_amount_capital) || ($line->amount_insurance != $pay_amount_insurance) || ($line->amount_interest != $pay_amount_interest)) { $arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, $loan->nbterm); foreach ($arr_term as $k => $v) { // Update fk_bank for current line diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index 4999067b62c..1e1a2267067 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -123,7 +123,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) { + if ($old != $obj->email) { $target[$j] = array( 'email' => $obj->email, 'name' => $obj->lastname, diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 4962830db07..c3900271e42 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -392,7 +392,7 @@ class Mos extends DolibarrApi if (empty($value["qty"])) { throw new RestException(500, "Field qty required in ".$arrayname); } - if ($value["qty"]!=0) { + if ($value["qty"] != 0) { $qtytoprocess = $value["qty"]; if (isset($value["fk_warehouse"])) { // If there is a warehouse to set if (!($value["fk_warehouse"] > 0)) { // If there is no warehouse set. diff --git a/htdocs/product/card.php b/htdocs/product/card.php index c25993cac5d..cff3bb2cb2a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2891,11 +2891,11 @@ if ($action != 'create' && $action != 'edit') { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($usercancreate) { - if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) { + if (!isset($object->no_button_edit) || $object->no_button_edit != 1) { print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $usercancreate); } - if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) { + if (!isset($object->no_button_copy) || $object->no_button_copy != 1) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { $cloneProductUrl = ''; $cloneButtonId = 'action-clone'; @@ -2906,7 +2906,7 @@ if ($action != 'create' && $action != 'edit') { $object_is_used = $object->isObjectUsed($object->id); if ($usercandelete) { - if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) { + if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete != 1)) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', 'action-delete', true); } else { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bf930472395..4a5b413177d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1189,7 +1189,7 @@ class Product extends CommonObject } // Quantities in batch details are not same as stock quantity, // so we add a default batch record to complete and get same qty in parent and child table - if ($ObjW->real <> $qty_batch) { + if ($ObjW->real != $qty_batch) { $ObjBatch = new Productbatch($this->db); $ObjBatch->batch = $valueforundefinedlot; $ObjBatch->qty = ($ObjW->real - $qty_batch); @@ -1874,13 +1874,13 @@ class Product extends CommonObject $lastPrice = array( 'level' => $level ? $level : 1, - 'multiprices' => doubleval($this->multiprices[$level]), - 'multiprices_ttc' => doubleval($this->multiprices_ttc[$level]), + 'multiprices' => (float) $this->multiprices[$level], + 'multiprices_ttc' => (float) $this->multiprices_ttc[$level], 'multiprices_base_type' => $this->multiprices_base_type[$level], - 'multiprices_min' => doubleval($this->multiprices_min[$level]), - 'multiprices_min_ttc' => doubleval($this->multiprices_min_ttc[$level]), - 'multiprices_tva_tx' => doubleval($this->multiprices_tva_tx[$level]), - 'multiprices_recuperableonly' => doubleval($this->multiprices_recuperableonly[$level]), + 'multiprices_min' => (float) $this->multiprices_min[$level], + 'multiprices_min_ttc' => (float) $this->multiprices_min_ttc[$level], + 'multiprices_tva_tx' => (float) $this->multiprices_tva_tx[$level], + 'multiprices_recuperableonly' => (float) $this->multiprices_recuperableonly[$level], ); return $lastPrice; @@ -3151,7 +3151,7 @@ class Product extends CommonObject if ($socid > 0) { $sql .= " AND c.fk_soc = ".((int) $socid); } - if ($filtrestatut <> '') { + if ($filtrestatut != '') { $sql .= " AND c.fk_statut in (".$this->db->sanitize($filtrestatut).")"; } @@ -3344,7 +3344,7 @@ class Product extends CommonObject if ($socid > 0) { $sql .= " AND e.fk_soc = ".((int) $socid); } - if ($filtrestatut <> '') { + if ($filtrestatut != '') { $sql .= " AND c.fk_statut IN (".$this->db->sanitize($filtrestatut).")"; } if (!empty($filterShipmentStatus)) { @@ -3426,7 +3426,7 @@ class Product extends CommonObject if ($socid > 0) { $sql .= " AND cf.fk_soc = ".((int) $socid); } - if ($filtrestatut <> '') { + if ($filtrestatut != '') { $sql .= " AND cf.fk_statut IN (".$this->db->sanitize($filtrestatut).")"; } if (!empty($dateofvirtualstock)) { @@ -3486,7 +3486,7 @@ class Product extends CommonObject if ($socid > 0) { $sql .= " AND m.fk_soc = ".((int) $socid); } - if ($filtrestatut <> '') { + if ($filtrestatut != '') { $sql .= " AND m.status IN (".$this->db->sanitize($filtrestatut).")"; } if (!empty($dateofvirtualstock)) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d31602a2552..cb46caba07f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -294,7 +294,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES')) { } else { $labelp = $langs->transnoentitiesnoconv("SellingPrice")." ".$i; } - $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>($i == 1 ? 1 : 0), 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>floatval('40.'.sprintf('%03s', $i))); + $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>($i == 1 ? 1 : 0), 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>(float) ('40.'.sprintf('%03s', $i))); $arraypricelevel[$i] = array($i); } } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 52bbd21c37f..610d0ca36ec 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -406,7 +406,7 @@ if ($action == 'create') { } // View mode - if ($action <> 'edit' && $action <> 're-edit') { + if ($action != 'edit' && $action != 're-edit') { $head = stock_prepare_head($object); print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock'); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 5a49139386b..697e886c2d3 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -195,7 +195,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $dlc = -1; // They are loaded later from serial $dluo = -1; // They are loaded later from serial - if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) { + if (!$error && $id_sw != $id_tw && is_numeric($qty) && $id_product) { $result = $product->fetch($id_product); $product->load_stock('novirtual'); // Load array product->stock_warehouse diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index 873f5a80e50..d484ab49ac1 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -86,7 +86,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $object = new ActionComm($db); // Not older than -if (empty($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) { +if (!getDolGlobalString('MAIN_AGENDA_EXPORT_PAST_DELAY')) { $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; // default limit } diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 39bcc797207..8cc4f573e38 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -247,7 +247,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."
    \n"; } // If the price has been set, name is required for the invoice - if (!GETPOST("societe") && !empty(floatval($project->price_registration))) { + if (!GETPOST("societe") && !empty((float) $project->price_registration)) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Company"))."
    \n"; } @@ -444,7 +444,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen } // If price is empty, no need to create a thirdparty, so we force $resultfetchthirdparty as if we have already found thirdp party. - if (empty(floatval($project->price_registration))) { + if (empty((float) $project->price_registration)) { $resultfetchthirdparty = 1; } @@ -505,7 +505,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen if (!$error) { // If the registration needs a payment - if (!empty(floatval($project->price_registration))) { + if (!empty((float) $project->price_registration)) { $outputlangs = $langs; // TODO Use default language of $thirdparty->default_lang to build $outputlang @@ -576,7 +576,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen // If there is no lines yet, we add one if (empty($facture->lines)) { - $pu_ttc = floatval($project->price_registration); + $pu_ttc = (float) $project->price_registration; $pu_ht = 0; $price_base_type = 'TTC'; @@ -816,16 +816,16 @@ if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS // Company print '' . "\n"; + print 'price_registration) ? '' : ' required').'>' . "\n"; // Email company for invoice if ($project->price_registration) { diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 60c770ed9bb..20be7cf9e5a 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -209,7 +209,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."
    \n"; } - if (!GETPOST("country_id") && !empty(floatval($project->price_booth))) { + if (!GETPOST("country_id") && !empty((float) $project->price_booth)) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country"))."
    \n"; } @@ -414,7 +414,7 @@ if (empty($reshook) && $action == 'add') { $errmsg .= $conforbooth->error; } else { // If this is a paying booth, we have to redirect to payment page and create an invoice - if (!empty(floatval($project->price_booth))) { + if (!empty((float) $project->price_booth)) { $productforinvoicerow = new Product($db); $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_BOOTH_LOCATION); if ($resultprod < 0) { @@ -452,7 +452,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Add line to draft invoice $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id); - $result = $facture->addline($langs->trans("BoothLocationFee", $conforbooth->label, dol_print_date($conforbooth->datep, '%d/%m/%y %H:%M:%S'), dol_print_date($conforbooth->datep2, '%d/%m/%y %H:%M:%S')), floatval($project->price_booth), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1); + $result = $facture->addline($langs->trans("BoothLocationFee", $conforbooth->label, dol_print_date($conforbooth->datep, '%d/%m/%y %H:%M:%S'), dol_print_date($conforbooth->datep2, '%d/%m/%y %H:%M:%S')), (float) $project->price_booth, 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1); if ($result <= 0) { $contact->error = $facture->error; $contact->errors = $facture->errors; diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 1239a6dc2c4..06a0d69ff82 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -629,7 +629,7 @@ $sql .= " WHERE e.entity IN (".getEntity('reception').")"; if ($socid) { $sql .= " AND e.fk_soc = ".((int) $socid); } -if ($search_status <> '' && $search_status >= 0) { +if ($search_status != '' && $search_status >= 0) { $sql .= " AND e.fk_statut = ".((int) $search_status); } if ($search_billed != '' && $search_billed >= 0) { diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 6286b4dcf06..142fbf6eae9 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -754,7 +754,7 @@ class Dolresource extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->trans("ResourceTypeShort".$obj->code) != "ResourceTypeShort".$obj->code ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code; $this->cache_code_type_resource[$obj->rowid]['label'] = $label; $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active; diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 81a08807db7..19092a8383d 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -1029,7 +1029,7 @@ if ($id > 0) { print $paymentsalarytemp->getNomUrl(1); print ''; print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; + $labeltype = $langs->trans("PaymentType".$objp->type_code) != "PaymentType".$objp->type_code ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; if (isModEnabled("banque")) { $bankaccountstatic->id = $objp->baid; diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index f6cebf0c07f..e04f4430225 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -775,18 +775,18 @@ class Salary extends CommonObject //$langs->load("mymodule"); $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid'); $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid'); - if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) { + if ($status == self::STATUS_UNPAID && $alreadypaid != 0) { $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted"); } $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid'); - if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) { + if ($status == self::STATUS_UNPAID && $alreadypaid != 0) { $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted"); } } $statusType = 'status1'; - if ($status == 0 && $alreadypaid <> 0) { + if ($status == 0 && $alreadypaid != 0) { $statusType = 'status3'; } if ($status == 1) { diff --git a/htdocs/salaries/virement_request.php b/htdocs/salaries/virement_request.php index 01d9ca9b186..f51af45622c 100644 --- a/htdocs/salaries/virement_request.php +++ b/htdocs/salaries/virement_request.php @@ -389,7 +389,7 @@ if ($resql) { print ''; print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; + $labeltype = $langs->trans("PaymentType".$objp->type_code) != "PaymentType".$objp->type_code ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; if (isModEnabled("banque")) { $bankaccountstatic->id = $objp->baid; diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 1fc6a5067a7..e4fa05d1b0e 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -61,7 +61,7 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company @@ -72,7 +72,7 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 093b8c896e5..b23df41c5b9 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -56,7 +56,7 @@ if ($this->control->tpl['action_delete']) { @@ -67,7 +67,7 @@ if ($this->control->tpl['action_delete']) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8489ae8d290..3efd92cb089 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3863,7 +3863,7 @@ class Societe extends CommonObject $sum = 0; for ($index = 0; $index < 9; $index++) { $number = (int) $chaine[$index]; - if (($index % 2) != 0) { + if ($index % 2 != 0) { if (($number *= 2) > 9) { $number -= 9; } @@ -3872,7 +3872,7 @@ class Societe extends CommonObject } // le numéro est valide si la somme des chiffres est multiple de 10 - if (($sum % 10) != 0) { + if ($sum % 10 != 0) { return -1; } } @@ -3905,7 +3905,7 @@ class Societe extends CommonObject } // le numéro est valide si la somme des chiffres est multiple de 10 - if (($sum % 10) != 0) { + if ($sum % 10 != 0) { return -1; } } diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 7acf9a45117..55b3b04336f 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -364,7 +364,7 @@ if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") { $handle = opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { + if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 96225b848ed..2ac22024573 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -212,7 +212,7 @@ if ($action == 'getProducts') { if (isset($barcode_value_list['qd'])) { $qty_str .= '.' . $barcode_value_list['qd']; } - $qty = floatval($qty_str); + $qty = (float) $qty_str; } $objProd = new Product($db); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 1380c032c86..5541afa2457 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1425,7 +1425,7 @@ if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) { echo ''; } } ?> - +
    @@ -1471,7 +1471,7 @@ if (getDolGlobalString('TAKEPOS_WEIGHING_SCALE')) { print ''; } } ?> - +
    diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index f76069a7d23..0d8c98a2ec7 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -537,7 +537,7 @@ if (empty($reshook)) { $nbofsuggested = 0; $prod->load_stock('warehouseopen'); $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - if ($prod->stock_warehouse[getDolGlobalString($constantforkey)]->detail_batch!="") { + if ($prod->stock_warehouse[getDolGlobalString($constantforkey)]->detail_batch != "") { if (is_object($prod->stock_warehouse[getDolGlobalString($constantforkey)]) && count($prod->stock_warehouse[getDolGlobalString($constantforkey)]->detail_batch)) { foreach ($prod->stock_warehouse[getDolGlobalString($constantforkey)]->detail_batch as $dbatch) { $nbofsuggested++; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index fe35dfb4b0a..e8c787a1585 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -716,15 +716,15 @@ class Ticket extends CommonObject $this->timing = $obj->timing; $this->type_code = $obj->type_code; - $label_type = ($langs->trans("TicketTypeShort".$obj->type_code) != ("TicketTypeShort".$obj->type_code) ? $langs->trans("TicketTypeShort".$obj->type_code) : ($obj->type_label != '-' ? $obj->type_label : '')); + $label_type = ($langs->trans("TicketTypeShort".$obj->type_code) != "TicketTypeShort".$obj->type_code ? $langs->trans("TicketTypeShort".$obj->type_code) : ($obj->type_label != '-' ? $obj->type_label : '')); $this->type_label = $label_type; $this->category_code = $obj->category_code; - $label_category = ($langs->trans("TicketCategoryShort".$obj->category_code) != ("TicketCategoryShort".$obj->category_code) ? $langs->trans("TicketCategoryShort".$obj->category_code) : ($obj->category_label != '-' ? $obj->category_label : '')); + $label_category = ($langs->trans("TicketCategoryShort".$obj->category_code) != "TicketCategoryShort".$obj->category_code ? $langs->trans("TicketCategoryShort".$obj->category_code) : ($obj->category_label != '-' ? $obj->category_label : '')); $this->category_label = $label_category; $this->severity_code = $obj->severity_code; - $label_severity = ($langs->trans("TicketSeverityShort".$obj->severity_code) != ("TicketSeverityShort".$obj->severity_code) ? $langs->trans("TicketSeverityShort".$obj->severity_code) : ($obj->severity_label != '-' ? $obj->severity_label : '')); + $label_severity = ($langs->trans("TicketSeverityShort".$obj->severity_code) != "TicketSeverityShort".$obj->severity_code ? $langs->trans("TicketSeverityShort".$obj->severity_code) : ($obj->severity_label != '-' ? $obj->severity_label : '')); $this->severity_label = $label_severity; $this->datec = $this->db->jdate($obj->datec); @@ -884,15 +884,15 @@ class Ticket extends CommonObject $line->progress = $obj->progress; $line->timing = $obj->timing; - $label_type = ($langs->trans("TicketTypeShort".$obj->type_code) != ("TicketTypeShort".$obj->type_code) ? $langs->trans("TicketTypeShort".$obj->type_code) : ($obj->type_label != '-' ? $obj->type_label : '')); + $label_type = ($langs->trans("TicketTypeShort".$obj->type_code) != "TicketTypeShort".$obj->type_code ? $langs->trans("TicketTypeShort".$obj->type_code) : ($obj->type_label != '-' ? $obj->type_label : '')); $line->type_label = $label_type; $this->category_code = $obj->category_code; - $label_category = ($langs->trans("TicketCategoryShort".$obj->category_code) != ("TicketCategoryShort".$obj->category_code) ? $langs->trans("TicketCategoryShort".$obj->category_code) : ($obj->category_label != '-' ? $obj->category_label : '')); + $label_category = ($langs->trans("TicketCategoryShort".$obj->category_code) != "TicketCategoryShort".$obj->category_code ? $langs->trans("TicketCategoryShort".$obj->category_code) : ($obj->category_label != '-' ? $obj->category_label : '')); $line->category_label = $label_category; $this->severity_code = $obj->severity_code; - $label_severity = ($langs->trans("TicketSeverityShort".$obj->severity_code) != ("TicketSeverityShort".$obj->severity_code) ? $langs->trans("TicketSeverityShort".$obj->severity_code) : ($obj->severity_label != '-' ? $obj->severity_label : '')); + $label_severity = ($langs->trans("TicketSeverityShort".$obj->severity_code) != "TicketSeverityShort".$obj->severity_code ? $langs->trans("TicketSeverityShort".$obj->severity_code) : ($obj->severity_label != '-' ? $obj->severity_label : '')); $line->severity_label = $label_severity; $line->datec = $this->db->jdate($obj->datec); @@ -1286,7 +1286,7 @@ class Ticket extends CommonObject $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $label = ($langs->trans("TicketTypeShort".$obj->code) != ("TicketTypeShort".$obj->code) ? $langs->trans("TicketTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->trans("TicketTypeShort".$obj->code) != "TicketTypeShort".$obj->code ? $langs->trans("TicketTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_types_tickets[$obj->rowid]['code'] = $obj->code; $this->cache_types_tickets[$obj->rowid]['label'] = $label; $this->cache_types_tickets[$obj->rowid]['use_default'] = $obj->use_default; @@ -1342,7 +1342,7 @@ class Ticket extends CommonObject // If translation exists, we use it to store already translated string. // Warning: You should not use this and recompute the translated string into caller code to get the value into expected language - $label = ($langs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code) ? $langs->trans("TicketCategoryShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->trans("TicketCategoryShort".$obj->code) != "TicketCategoryShort".$obj->code ? $langs->trans("TicketCategoryShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_category_tickets[$obj->rowid]['label'] = $label; $i++; @@ -1382,7 +1382,7 @@ class Ticket extends CommonObject $obj = $this->db->fetch_object($resql); $this->cache_severity_tickets[$obj->rowid]['code'] = $obj->code; - $label = ($langs->trans("TicketSeverityShort".$obj->code) != ("TicketSeverityShort".$obj->code) ? $langs->trans("TicketSeverityShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $label = ($langs->trans("TicketSeverityShort".$obj->code) != "TicketSeverityShort".$obj->code ? $langs->trans("TicketSeverityShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_severity_tickets[$obj->rowid]['label'] = $label; $this->cache_severity_tickets[$obj->rowid]['use_default'] = $obj->use_default; $this->cache_severity_tickets[$obj->rowid]['pos'] = $obj->pos; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 700dd744382..f27a82d84c8 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2034,12 +2034,12 @@ if ($action == 'create' || $action == 'adduserldap') { 'class' => 'classfortooltip' ) ); - if ($user->id <> $id && $candisableuser && $object->statut == 0 && + if ($user->id != $id && $candisableuser && $object->statut == 0 && ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken(), '', true, $params); } // Disable user - if ($user->id <> $id && $candisableuser && $object->statut == 1 && + if ($user->id != $id && $candisableuser && $object->statut == 1 && ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken(), '', true, $params); } else { @@ -2049,7 +2049,7 @@ if ($action == 'create' || $action == 'adduserldap') { } } // Delete - if ($user->id <> $id && $candisableuser && + if ($user->id != $id && $candisableuser && ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', true, $params); diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 915642c7ab6..fea12e1b372 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -207,7 +207,7 @@ if ($id > 0) { */ print '
    '; - if (!empty($user->admin) && $action <> 'edit') { + if (!empty($user->admin) && $action != 'edit') { print ''.$langs->trans("Modify").''; } diff --git a/htdocs/user/document.php b/htdocs/user/document.php index e88017f12cb..2e36a90fdfe 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -77,7 +77,7 @@ $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && !$canreaduser) { +if ($user->id != $id && !$canreaduser) { accessforbidden(); } diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 885774b517a..3418e5a616a 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -326,7 +326,7 @@ if ($object->id > 0) { $isexpanded = ! $ishidden; // Break found, it's a new module to catch - if (isset($obj->module) && ($oldmod <> $obj->module)) { + if (isset($obj->module) && ($oldmod != $obj->module)) { $oldmod = $obj->module; $j++; @@ -424,7 +424,7 @@ if ($object->id > 0) { } // Description of permission (2 columns) - $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); + $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != "PermissionAdvanced".$obj->id) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != "Permission".$obj->id) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); print '
    '.$langs->trans('PaymentMode').''.$labeltype; print $object->num_payment ? ' - '.$object->num_payment : ''; diff --git a/htdocs/fourn/paiement/document.php b/htdocs/fourn/paiement/document.php index 81d08b9be4c..2bd45de41d3 100644 --- a/htdocs/fourn/paiement/document.php +++ b/htdocs/fourn/paiement/document.php @@ -119,7 +119,7 @@ if ($object->id > 0) { // Payment mode $morehtmlref .= '
    '.$langs->trans('PaymentMode').' : '; - $morehtmlref .= $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; + $morehtmlref .= $langs->trans("PaymentType".$object->type_code) != "PaymentType".$object->type_code ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; $morehtmlref .= $object->num_payment ? ' - '.$object->num_payment : ''; // Thirdparty diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 60abc2dcece..cd42464d2f3 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -618,7 +618,7 @@ while ($i < $imaxinloop) { // Pyament type if (!empty($arrayfields['c.libelle']['checked'])) { - $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; + $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != "PaymentType".$objp->paiement_type ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; print '
    '.$payment_type.' '.dol_trunc($objp->num_payment, 32).'
    '; - if (!empty(floatval($project->price_registration))) { + if (!empty((float) $project->price_registration)) { print ''; } print $langs->trans("Company"); - if (!empty(floatval($project->price_registration))) { + if (!empty((float) $project->price_registration)) { print ''; } print ''; print img_picto('', 'company', 'class="pictofixedwidth"'); - print 'price_registration)) ? '' : ' required').'>
    '.dol_print_date($db->jdate($objp->dp), 'dayhour', 'tzuserrel')."".$labeltype.' '.$objp->num_payment."
    '; print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'dayhour', 'tzuserrel')."".$labeltype.' '.$objp->num_payment."
    trans('CustomerCode'); ?> control->tpl['code_client']; ?> - control->tpl['checkcustomercode'] <> 0) { ?> + control->tpl['checkcustomercode'] != 0) { ?> (trans("WrongCustomerCode"); ?>)
    trans('SupplierCode'); ?> control->tpl['code_fournisseur']; ?> - control->tpl['checksuppliercode'] <> 0) { ?> + control->tpl['checksuppliercode'] != 0) { ?> (trans("WrongSupplierCode"); ?>)
    trans('CustomerCode'); ?> control->tpl['code_client']; ?> - control->tpl['checkcustomercode'] <> 0) { ?> + control->tpl['checkcustomercode'] != 0) { ?> (trans("WrongCustomerCode"); ?>)
    trans('SupplierCode'); ?> control->tpl['code_fournisseur']; ?> - control->tpl['checksuppliercode'] <> 0) { ?> + control->tpl['checksuppliercode'] != 0) { ?> (trans("WrongSupplierCode"); ?>) '; print $permlabel; if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index c7264752f92..a0958a4d6fc 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -57,7 +57,7 @@ if ($user->socid > 0) { $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && !$canreaduser) { +if ($user->id != $id && !$canreaduser) { accessforbidden(); } diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 2ff74ba145e..e30e7f19f4f 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -74,7 +74,7 @@ if ($user->id == $id && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user } $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && !$canreaduser) { +if ($user->id != $id && !$canreaduser) { accessforbidden(); } @@ -512,7 +512,7 @@ if ($result) { //var_dump($permsgroupbyentitypluszero); // Break found, it's a new module to catch - if (isset($obj->module) && ($oldmod <> $obj->module)) { + if (isset($obj->module) && ($oldmod != $obj->module)) { $oldmod = $obj->module; $j++; @@ -664,7 +664,7 @@ if ($result) { } // Description of permission (2 columns) - $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); + $permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != "PermissionAdvanced".$obj->id) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != "Permission".$obj->id) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); if (!$user->admin) { print ''; } else { diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 7763146fcda..7a2212ca55b 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -530,8 +530,8 @@ class ProductCombination if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) { $new_type = empty($parent->multiprices_base_type[$i]) ? 'HT' : $parent->multiprices_base_type[$i]; $new_min_price = $parent->multiprices_min[$i]; - $variation_price = floatval(!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price); - $variation_price_percentage = floatval(!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage); + $variation_price = (float) (!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price); + $variation_price_percentage = (float) (!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage); if ($parent->prices_by_qty_list[$i]) { $new_psq = 1; @@ -1144,9 +1144,9 @@ class ProductCombinationLevel } $this->id = $obj->rowid; - $this->fk_product_attribute_combination = floatval($obj->fk_product_attribute_combination); + $this->fk_product_attribute_combination = (float) $obj->fk_product_attribute_combination; $this->fk_price_level = intval($obj->fk_price_level); - $this->variation_price = floatval($obj->variation_price); + $this->variation_price = (float) $obj->variation_price; $this->variation_price_percentage = (bool) $obj->variation_price_percentage; return 1; @@ -1183,7 +1183,7 @@ class ProductCombinationLevel // Update if (!empty($this->id)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET variation_price = '.floatval($this->variation_price).' , variation_price_percentage = '.intval($this->variation_price_percentage); + $sql .= ' SET variation_price = '.(float) $this->variation_price.' , variation_price_percentage = '.intval($this->variation_price_percentage); $sql .= ' WHERE rowid = '.((int) $this->id); $res = $this->db->query($sql); @@ -1201,7 +1201,7 @@ class ProductCombinationLevel $sql .= ") VALUES ("; $sql .= (int) $this->fk_product_attribute_combination; $sql .= ", ".intval($this->fk_price_level); - $sql .= ", ".floatval($this->variation_price); + $sql .= ", ".(float) $this->variation_price; $sql .= ", ".intval($this->variation_price_percentage); $sql .= ")"; diff --git a/htdocs/webservices/server_payment.php b/htdocs/webservices/server_payment.php index 7a3b58b68df..db26fc970e0 100644 --- a/htdocs/webservices/server_payment.php +++ b/htdocs/webservices/server_payment.php @@ -188,7 +188,7 @@ function createPayment($authentication, $payment) $soc->fetch($payment['thirdparty_id']); $new_payment = new Paiement($db); - $new_payment->amount = floatval($payment['amount']); + $new_payment->amount = (float) $payment['amount']; $new_payment->num_payment = $payment['num_payment']; $new_payment->fk_account = intval($payment['bank_account']); $new_payment->paiementid = !empty($payment['payment_mode_id']) ? intval($payment['payment_mode_id']) : $soc->mode_reglement_id; From e2c0a76c117fc2634e6113804563024631578dba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 12:14:45 +0100 Subject: [PATCH 200/315] Fix regex --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 1562b13e1e2..500d30b02bd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -71,7 +71,7 @@ parameters: - '#Caught class Stripe#' - '#Sprain\\SwissQrBill\\#' - '#Constructor of class DolEditor has an unused parameter \$toolbarlocation#' - - '#Constructor of class DoliDB\w+ has an unused parameter $type#' + - '#Constructor of class DoliDB\w+ has an unused parameter \$type#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 From 61c5c6f88d4bd2defe3318dc8fa5a54aa3608d59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 13:09:25 +0100 Subject: [PATCH 201/315] Fix regression --- htdocs/core/class/html.form.class.php | 1 + htdocs/core/lib/functions.lib.php | 12 +++++++++++- test/phpunit/FunctionsLibTest.php | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f5a05e2bf97..2ab753d4272 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8024,6 +8024,7 @@ class Form $InfoFieldList = array(); if ($objectfield) { // We must retreive the objectdesc from the field or extrafield + // Example: $objectfield = 'product:options_package' $tmparray = explode(':', $objectfield); $objectdesc = ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 90e8faf65ed..601723d506c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12148,7 +12148,17 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '') $element_prop = getElementProperties($element_type); - if (is_array($element_prop) && isModEnabled($element_prop['module'])) { + if ($element_prop['module'] == 'product' || $element_prop['module'] == 'service') { + // For example, for an extrafield 'product' (shared for both product and service) that is a link to an object, + // this is called with $element_type = 'product' when we need element properties of a service, we must return a product. If we create the + // extrafield for a service, it is not supported and not found when editing the product/service card. So we must keep 'product' for extrafields + // of service and we will return properties of a product. + $ismodenabled = (isModEnabled('product') || isModEnabled('service')); + } else { + $ismodenabled = isModEnabled($element_prop['module']); + } + + if (is_array($element_prop) && $ismodenabled) { dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); if (class_exists($element_prop['classname'])) { diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 7b8786baae8..ce34604cc32 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1781,4 +1781,20 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase return true; } + + /** + * testFetchObjectByElement + * + * @return boolean; + */ + public function testFetchObjectByElement() + { + global $conf, $langs; + + $result = fetchObjectByElement(0, 'product'); + + $this->assertTrue(is_object($result)); + + return true; + } } From 012e0440e0d422c3a9319c9a8642062e10e32acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Wed, 27 Dec 2023 13:18:55 +0100 Subject: [PATCH 202/315] Fix #27224 --- .../class/emailcollector.class.php | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f808caf4e1d..df404498a61 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1630,7 +1630,7 @@ class EmailCollector extends CommonObject $emailto = $this->decodeSMTPSubject($overview[0]->to); - $operationslog .= '
    ** Process email #'.dol_escape_htmltag($iforemailloop)." - ".dol_escape_htmltag((string) $imapemail)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']); + $operationslog .= '
    ** Process email #'.dol_escape_htmltag($iforemailloop)." - ".dol_escape_htmltag($this->uidAsString($imapemail))." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']); dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']); @@ -3186,8 +3186,8 @@ class EmailCollector extends CommonObject $imapemail->move($targetdir); } } else { - dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); - $operationslog .= '
    Move mail '.((string) $imapemail).' - '.$msgid; + dol_syslog("EmailCollector::doCollectOneCollector move message ".($this->uidAsString($imapemail))." to ".$connectstringtarget, LOG_DEBUG); + $operationslog .= '
    Move mail '.($this->uidAsString($imapemail)).' - '.$msgid; $arrayofemailtodelete[$imapemail] = $msgid; } @@ -3195,7 +3195,7 @@ class EmailCollector extends CommonObject if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("EmailCollector::doCollectOneCollector message '".($imapemail->getHeader()->get('subject'))."' using this->host=".$this->host.", this->access_type=".$this->acces_type." was set to read", LOG_DEBUG); } else { - dol_syslog("EmailCollector::doCollectOneCollector message ".((string) $imapemail)." to ".$connectstringtarget." was set to read", LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector message ".($this->uidAsString($imapemail))." to ".$connectstringtarget." was set to read", LOG_DEBUG); } } } else { @@ -3550,4 +3550,20 @@ class EmailCollector extends CommonObject return $text; } + + /** + * Get UID of message as a string + * + * @param int|Webklex\PHPIMAP\Message $imapemail UID as int (if native IMAP) or as object (if external library) + * @return string UID as string + */ + protected function uidAsString($imapemail) + { + if (is_object($imapemail)) { + return $imapemail->getAttributes()["uid"]; + } + else { + return (string) $imapemail; + } + } } From 0b9673f6518c4a28d454a275999b25efe014b59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Wed, 27 Dec 2023 13:25:39 +0100 Subject: [PATCH 203/315] Update emailcollector.class.php Fix phpcs errors --- htdocs/emailcollector/class/emailcollector.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index df404498a61..05f7c5e7656 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -3550,7 +3550,7 @@ class EmailCollector extends CommonObject return $text; } - + /** * Get UID of message as a string * @@ -3561,8 +3561,7 @@ class EmailCollector extends CommonObject { if (is_object($imapemail)) { return $imapemail->getAttributes()["uid"]; - } - else { + } else { return (string) $imapemail; } } From 5d7005320fcb90623306918fb96e05c5454b9944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Wed, 27 Dec 2023 13:31:22 +0100 Subject: [PATCH 204/315] Fix #27226 --- htdocs/emailcollector/class/emailcollector.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f808caf4e1d..df0ba69242a 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1128,6 +1128,8 @@ class EmailCollector extends CommonObject $this->fetchFilters(); $this->fetchActions(); + $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' + if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if ($this->acces_type == 1) { // Mode OAUth2 with PHP-IMAP @@ -1233,7 +1235,6 @@ class EmailCollector extends CommonObject return -2; } $sourcedir = $this->source_directory; - $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' $connectstringserver = $this->getConnectStringIMAP(); $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); From 784b8a44b76b3ffd65705681bf8b996627ee7ccf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 14:23:41 +0100 Subject: [PATCH 205/315] Update index.php --- htdocs/comm/action/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e05b74fa9a4..2187df8caf4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -316,7 +316,7 @@ if (empty($mode) || $mode == 'show_month') { $next_month = $next['month']; $max_day_in_prev_month = date("t", dol_mktime(12, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(12, 0, 0, $month, 1, $year)); // Nb of days in next month + $max_day_in_month = date("t", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')); // Nb of days in next month // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')) + 2; // date('w') is 0 fo sunday $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); From 46dc2646541f8eb009c092dae833537272cbdc72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 14:40:16 +0100 Subject: [PATCH 206/315] Update dolibarr_changes.txt --- dev/dolibarr_changes.txt | 61 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 7c31d61cc46..ebfc2890e39 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -152,9 +152,9 @@ with elseif (strpos($filename, '://') === false) * To avoid to have QRcode changed because generated with a random mask, replace -define('QR_FIND_FROM_RANDOM', 2); -with -define('QR_FIND_FROM_RANDOM', false); + define('QR_FIND_FROM_RANDOM', 2); + with: + define('QR_FIND_FROM_RANDOM', false); * Removed useless directories ("examples", "tools") @@ -173,15 +173,15 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php * In tecnickcom/tcpdf/include/tcpdf_static, in function intToRoman, right at the beginning of the function, replace: - $roman = ''; + $roman = ''; -with: + with: - $roman = ''; - if ($number >= 4000) { - // do not represent numbers above 4000 in Roman numerals - return strval($number); - } + $roman = ''; + if ($number >= 4000) { + // do not represent numbers above 4000 in Roman numerals + return strval($number); + } @@ -192,14 +192,14 @@ Add fpdf_tpl.php 1.2 Add tcpdi.php Add tcpdi_parser.php and replace: -require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); -with: -require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php'); + require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); + with: + require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php'); * Fix by replacing } elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1] >= 2))) { -with + with } elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1]) >= 2)) { @@ -262,16 +262,22 @@ Change content of file htdocs/includes/restler/framework/Luracast/Restler/explor // @CHANGE LDR if (!is_string($haystack)) return false; -* Add a test into AutoLoader.php to complete function loadThisLoader and test if property exists before calling it +* Add a test into AutoLoader.php to complete function loadThisLoader and test if property exists before calling it. For this replace code - //avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader - //in case of multiple autoloader systems - if(property_exists($b, $loader[1])) { - if (false !== $file = $b::$loader[1]($className) - && $this->exists($className, $b::$loader[1])) { - return $file; - } - } + if (false !== $file = $b::$loader[1]($className) && $this->exists($className, $b::$loader[1])) { + return $file; + } + + with: + + //avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader + //in case of multiple autoloader systems + if(property_exists($b, $loader[1])) { + if (false !== $file = $b::$loader[1]($className) + && $this->exists($className, $b::$loader[1])) { + return $file; + } + } PARSEDOWN @@ -285,11 +291,10 @@ PARSEDOWN ... // @CHANGE LDR - if (preg_match('/{([^}]+)}/', $remainder, $matches2)) - { - $Element['attributes']['class'] = $matches2[1]; - $remainder = preg_replace('/{'.preg_quote($matches2[1],'/').'}/', '', $remainder); - } + if (preg_match('/{([^}]+)}/', $remainder, $matches2)) { + $Element['attributes']['class'] = $matches2[1]; + $remainder = preg_replace('/{'.preg_quote($matches2[1],'/').'}/', '', $remainder); + } // @CHANGE LDR From 32e709a0f4e053423421ef1156d2fc06e0905c93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 14:56:00 +0100 Subject: [PATCH 207/315] Debug v19 --- htdocs/product/stock/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index bc39a97a3d8..eb3a17ffebf 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -598,7 +598,6 @@ if ($action == 'create') { // Show list of products into warehouse - print '
    '; $totalarray = array(); @@ -610,6 +609,7 @@ if ($action == 'create') { // TODO Create $arrayfields with all fields to show print load_fiche_titre($langs->trans("Stock"), '', 'stock'); + print '
    '; print ''; print ''; @@ -617,7 +617,7 @@ if ($action == 'create') { $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); + print_liste_field_titre("Products", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); $totalarray['nbfield'] += 3; From 91f5cae07174a778c5ddb5a17bd0d8f6a1d205db Mon Sep 17 00:00:00 2001 From: Dev2a Date: Wed, 27 Dec 2023 15:48:41 +0100 Subject: [PATCH 208/315] Fix: Add not in operator --- htdocs/core/lib/functions.lib.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 601723d506c..e846a9a085c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12593,20 +12593,22 @@ function dolForgeCriteriaCallback($matches) $operator = strtoupper(preg_replace('/[^a-z<>!=]/i', '', trim($tmp[1]))); - if ($operator == 'NOTLIKE') { - $operator = 'NOT LIKE'; - } - if ($operator == 'ISNOT') { - $operator = 'IS NOT'; - } - if ($operator == '!=') { - $operator = '<>'; + $realOperator = [ + 'NOTLIKE' => 'NOT LIKE', + 'ISNOT' => 'IS NOT', + 'NOTIN' => 'NOT IN', + '!=' => '<>', + ]; + + if (array_key_exists($operator, $realOperator)) { + $operator = $realOperator[$operator]; } + $tmpescaped = $tmp[2]; $regbis = array(); - if ($operator == 'IN') { // IN is allowed for list of ID or code only + if ($operator == 'IN' || $operator == 'NOT IN') { // IN is allowed for list of ID or code only //if (!preg_match('/^\(.*\)$/', $tmpescaped)) { $tmpescaped2 = '('; // Explode and sanitize each element in list From 365e1293ca5b4b6d0ac94260df1d088873aa6617 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 16:02:53 +0100 Subject: [PATCH 209/315] Update clientfourn.php --- htdocs/compta/resultat/clientfourn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 6ea8d305caa..7f45cc3d478 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -90,7 +90,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e // We define date_start and date_end $year_end = $year_start; $month_start = GETPOST("month") ? GETPOST("month", 'int') : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); - $month_end =""; + $month_end = ""; if (!GETPOST('month')) { if (!$year && $month_start > $month_current) { $year_start--; From 1be09f478a77f84c42cc9abda3eb7ef729ec9dc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 16:37:03 +0100 Subject: [PATCH 210/315] Debug v19 --- htdocs/public/members/new.php | 24 ++++++++++++++---------- htdocs/theme/eldy/global.inc.php | 7 +++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 6fe739d4a99..dc479c90cbd 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -533,8 +533,9 @@ dol_htmloutput_events(); // Print form print ''."\n"; -print ''; +print ''; print ''; +print ''; if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFORM_FORCETYPE') || $action == 'create') { print ''; @@ -610,19 +611,21 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR // Company // TODO : optional hide print ''."\n"; // Title - print ''."\n"; - - // Lastname - print ''."\n"; + if (getDolGlobalString('MEMBER_NEWFORM_ASK_TITLE')) { + print ''."\n"; + } // Firstname print ''."\n"; + // Lastname + print ''."\n"; + // EMail print ''; @@ -689,13 +693,13 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR print ''."\n"; // Photo - print ''."\n"; + print ''."\n"; // Public if (getDolGlobalString('MEMBER_PUBLIC_ENABLED')) { $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : ''); $publiclabel = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist); - print ''."\n"; + print ''."\n"; } // Other attributes diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 797f3d5889a..58a2421c0d8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5007,7 +5007,7 @@ table.table-fiche-title { div.backgreypublicpayment { - background-color: var(--colorbacktitle1); + background-color: var(--colorbackgrey); padding: 20px; border-bottom: 1px solid #ddd; text-align: center; @@ -5015,7 +5015,10 @@ div.backgreypublicpayment { top: 0; z-index: 1005; } -.backgreypublicpayment a { color: #222 !important; } +.backgreypublicpayment a { + color: var(--colorblack) !important; + opacity: 0.9; +} .poweredbypublicpayment { float: right; top: 8px; From 3f0c177561d0f94d44139da6f3d64544382cd6f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 16:42:50 +0100 Subject: [PATCH 211/315] Fix test to cancel holiday --- htdocs/holiday/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index f64d9150d6b..7fa981b173b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1559,7 +1559,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // Button Cancel (because we can't approve) if ($cancreate || $cancreateall) { - if (($object->date_debut > dol_now()) || !empty($user->admin)) { + if (($object->date_fin > dol_now()) || !empty($user->admin)) { print ''.$langs->trans("ActionCancelCP").''; } else { print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").''; @@ -1569,7 +1569,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } if ($object->statut == Holiday::STATUS_APPROVED) { // If validated and approved if ($user->id == $object->fk_validator || $user->id == $object->fk_user_approve || $cancreate || $cancreateall) { - if (($object->date_debut > dol_now()) || !empty($user->admin) || $user->id == $object->fk_user_approve) { + if (($object->date_fin > dol_now()) || !empty($user->admin) || $user->id == $object->fk_user_approve) { print ''.$langs->trans("ActionCancelCP").''; } else { print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").''; From 00a8ad9207067b71cdee054c51a8071f82c6a4ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Dec 2023 16:42:50 +0100 Subject: [PATCH 212/315] Fix test to cancel holiday --- htdocs/holiday/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 2f101b1bdf6..9b4b750a6c9 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1541,7 +1541,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // Button Cancel (because we can't approve) if ($cancreate || $cancreateall) { - if (($object->date_debut > dol_now()) || !empty($user->admin)) { + if (($object->date_fin > dol_now()) || !empty($user->admin)) { print ''.$langs->trans("ActionCancelCP").''; } else { print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").''; @@ -1551,7 +1551,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } if ($object->statut == Holiday::STATUS_APPROVED) { // If validated and approved if ($user->id == $object->fk_validator || $user->id == $object->fk_user_approve || $cancreate || $cancreateall) { - if (($object->date_debut > dol_now()) || !empty($user->admin) || $user->id == $object->fk_user_approve) { + if (($object->date_fin > dol_now()) || !empty($user->admin) || $user->id == $object->fk_user_approve) { print ''.$langs->trans("ActionCancelCP").''; } else { print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").''; From b5b8a2a87407e7b70c15847771f9040ee569397a Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 14 Dec 2023 14:51:31 +0100 Subject: [PATCH 213/315] Fix utf8_encoding/decoding (PHP8.2 deprecation) Fix files that were missed in #27018 --- dev/translation/autotranslator.class.php | 2 +- .../class/accountingjournal.class.php | 2 +- .../accountancy/journal/purchasesjournal.php | 18 +++++------ htdocs/accountancy/journal/sellsjournal.php | 22 +++++++------- htdocs/core/lib/ftp.lib.php | 14 ++++----- test/phpunit/ODFTest.php | 30 +++++++++---------- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php index d2ad8d60344..3d6117b3892 100644 --- a/dev/translation/autotranslator.class.php +++ b/dev/translation/autotranslator.class.php @@ -240,7 +240,7 @@ class autoTranslator if ($this->_outputpagecode == 'UTF-8') { $val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)); } else { - $val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2))); + $val=mb_convert_encoding($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)), 'ISO-8859-1'); } } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 0e3dc913917..dd8dd36e2c9 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -1015,7 +1015,7 @@ class AccountingJournal extends CommonObject 'found' => true, 'label' => $accountingaccount->label, 'code_formatted_1' => length_accounta(html_entity_decode($account)), - 'label_formatted_1' => utf8_decode(dol_trunc($accountingaccount->label, 32)), + 'label_formatted_1' => mb_convert_encoding(dol_trunc($accountingaccount->label, 32), 'ISO-8859-1'), 'label_formatted_2' => dol_trunc($accountingaccount->label, 32), ); } else { diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8439ff5ec99..21a624194ca 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -808,12 +808,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -829,12 +829,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; - print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($accountingaccount->label, 32), 'ISO-8859-1').'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -881,12 +881,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -901,12 +901,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["refsologest"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").' NPR"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").' NPR"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b91a7393572..d8097020289 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -869,12 +869,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -888,12 +888,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -909,12 +909,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; - print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($accountingaccount->label, 32), 'ISO-8859-1').'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -938,12 +938,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; @@ -958,12 +958,12 @@ if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; print '"'.$val["ref"].'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 32), 'ISO-8859-1').'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '""'.$sep; print '"'.$langs->trans("RevenueStamp").'"'.$sep; - print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("RevenueStamp").'"'.$sep; + print '"'.mb_convert_encoding(dol_trunc($companystatic->name, 16), 'ISO-8859-1').' - '.$invoicestatic->ref.' - '.$langs->trans("RevenueStamp").'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.$journal.'"'; diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index fb0c0e104c9..89a36297e39 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -71,7 +71,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect //if ($ftp_passive) ftp_pasv($connect_id, true); // Change the dir - $newsectioniso = utf8_decode($section); + $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1'); //ftp_chdir($connect_id, $newsectioniso); $connect_id = ssh2_sftp($tmp_conn_id); if (!$connect_id) { @@ -94,7 +94,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect } // Change the dir - $newsectioniso = utf8_decode($section); + $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1'); ftp_chdir($connect_id, $newsectioniso); } else { $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); @@ -173,7 +173,7 @@ function dol_ftp_delete($connect_id, $file, $newsection) // Remote file $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; - $newremotefileiso = utf8_decode($remotefile); + $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); //print "x".$newremotefileiso; dol_syslog("ftp/index.php ftp_delete ".$newremotefileiso); @@ -204,7 +204,7 @@ function dol_ftp_get($connect_id, $localfile, $file, $newsection) // Remote file $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; - $newremotefileiso = utf8_decode($remotefile); + $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { return fopen('ssh2.sftp://'.intval($connect_id).$newremotefileiso, 'r'); @@ -233,7 +233,7 @@ function dol_ftp_put($connect_id, $file, $localfile, $newsection) // Remote file $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; - $newremotefileiso = utf8_decode($remotefile); + $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { return ssh2_scp_send($connect_id, $localfile, $newremotefileiso, 0644); @@ -261,7 +261,7 @@ function dol_ftp_rmdir($connect_id, $file, $newsection) // Remote file $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; - $newremotefileiso = utf8_decode($remotefile); + $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { return ssh2_sftp_rmdir($connect_id, $newremotefileiso); @@ -289,7 +289,7 @@ function dol_ftp_mkdir($connect_id, $newdir, $newsection) // Remote file $newremotefileiso = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$newdir; - $newremotefileiso = utf8_decode($newremotefileiso); + $newremotefileiso = mb_convert_encoding($newremotefileiso, 'ISO-8859-1'); if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { return ssh2_sftp_mkdir($connect_id, $newremotefileiso, 0777); diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index 87d062a3412..dbfe8d11456 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -194,13 +194,13 @@ class ODFTest extends PHPUnit\Framework\TestCase 'to_convert' => "/a&él'èàüöç€Ğ~<>", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode("/a&él'èàüöç€Ğ~<>"), + 'expected' => mb_convert_encoding("/a&él'èàüöç€Ğ~<>", 'UTF-8', 'ISO-8859-1'), ], 8 => [ 'to_convert' => "/a&él'èàüöç€Ğ~<>", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode("/a&él'èàüöç€Ğ~<>"), + 'expected' => mb_convert_encoding("/a&él'èàüöç€Ğ~<>", 'UTF-8', 'ISO-8859-1'), ], // special chars with non-default charset 9 => [ @@ -219,25 +219,25 @@ class ODFTest extends PHPUnit\Framework\TestCase 'to_convert' => "Greater > than", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode("Greater > than"), + 'expected' => mb_convert_encoding("Greater > than", 'UTF-8', 'ISO-8859-1'), ], 12 => [ 'to_convert' => "Greater > than", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode("Greater > than"), + 'expected' => mb_convert_encoding("Greater > than", 'UTF-8', 'ISO-8859-1'), ], 13 => [ 'to_convert' => "Smaller < than", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode("Smaller < than"), + 'expected' => mb_convert_encoding("Smaller < than", 'UTF-8', 'ISO-8859-1'), ], 14 => [ 'to_convert' => "Smaller < than", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode("Smaller < than"), + 'expected' => mb_convert_encoding("Smaller < than", 'UTF-8', 'ISO-8859-1'), ], /** HTML **/ // break lines @@ -245,25 +245,25 @@ class ODFTest extends PHPUnit\Framework\TestCase 'to_convert' => "Break
    line", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode("Breakline"), + 'expected' => mb_convert_encoding("Breakline", 'UTF-8', 'ISO-8859-1'), ], 16 => [ 'to_convert' => "Break
    line", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode("Breakline"), + 'expected' => mb_convert_encoding("Breakline", 'UTF-8', 'ISO-8859-1'), ], 17 => [ 'to_convert' => "Break
    line", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode("Breakline"), + 'expected' => mb_convert_encoding("Breakline", 'UTF-8', 'ISO-8859-1'), ], 18 => [ 'to_convert' => "Break
    line", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode("Breakline"), + 'expected' => mb_convert_encoding("Breakline", 'UTF-8', 'ISO-8859-1'), ], // HTML tags 19 => [ @@ -282,19 +282,19 @@ class ODFTest extends PHPUnit\Framework\TestCase 'to_convert' => "text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\''), + 'expected' => mb_convert_encoding('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\'', 'UTF-8', 'ISO-8859-1'), ], 22 => [ 'to_convert' => "text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l''), + 'expected' => mb_convert_encoding('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'', 'UTF-8', 'ISO-8859-1'), ], 23 => [ 'to_convert' => "text with intricatedtags", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode('text with intricatedtags'), + 'expected' => mb_convert_encoding('text with intricatedtags', 'UTF-8', 'ISO-8859-1'), ], // One can also pass html-encoded string to the method @@ -320,13 +320,13 @@ class ODFTest extends PHPUnit\Framework\TestCase 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => false, 'charset' => null, - 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\''), + 'expected' => mb_convert_encoding('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l\'', 'UTF-8', 'ISO-8859-1'), ], 28 => [ 'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>", 'encode' => true, 'charset' => null, - 'expected' => utf8_encode('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l''), + 'expected' => mb_convert_encoding('text with strong, emphasis and underlined words with it@lic sp&ciàlchärs éè l'', 'UTF-8', 'ISO-8859-1'), ], // // TODO custom styles are not tested for now : the custom style have a custom ID based on time. Not random, but hard to mock or predict. generated in _replaceHtmlWithOdtTag() case 'span'. From 3d23322556a9c3f8bee1d5080e3a7f6e2bf852ff Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 28 Dec 2023 08:59:44 +0100 Subject: [PATCH 214/315] FIX: bad accountancy code autoselection for supplier ventilation --- htdocs/accountancy/class/accountingaccount.class.php | 2 +- htdocs/accountancy/supplier/list.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 8e5f7690dd1..22713357ff8 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -839,7 +839,7 @@ class AccountingAccount extends CommonObject } $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) { + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale if ($type == 'customer' && !empty($product->accountancy_code_sell_intra)) { $code_p = $product->accountancy_code_sell_intra; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index aae34a51e03..85f64242c64 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -623,6 +623,7 @@ if ($result) { $code_buy_t=$return['code_t']; } //var_dump($return); + //exit; if (!empty($code_buy_p)) { // Value was defined previously From 39d986ae591d64b892ce44c7d3bff2534229271f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 28 Dec 2023 09:00:39 +0100 Subject: [PATCH 215/315] FIX: bad accountancy code autoselection for supplier ventilation --- htdocs/accountancy/supplier/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 85f64242c64..aae34a51e03 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -623,7 +623,6 @@ if ($result) { $code_buy_t=$return['code_t']; } //var_dump($return); - //exit; if (!empty($code_buy_p)) { // Value was defined previously From a2d584a4ad0e670ed773d76a25c1e3a9bac2337a Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 28 Dec 2023 09:40:35 +0100 Subject: [PATCH 216/315] fix functions name --- scripts/company/sync_contacts_dolibarr2ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index bdfb856e255..962e0e6d951 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -103,7 +103,7 @@ if (!$confirmed) { } /* - * if (!getDolGlobalSring('LDAP_CONTACT_ACTIVE')) { + * if (!getDolGlobalString('LDAP_CONTACT_ACTIVE')) { * print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); * exit(-1); * } From a2a9d8d9ad763b6e9d516843187714a9828bfcfa Mon Sep 17 00:00:00 2001 From: Idayat NOUFOU Date: Thu, 28 Dec 2023 10:49:45 +0100 Subject: [PATCH 217/315] Fix: Unsupported operand types --- htdocs/core/lib/date.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index cebf9ac7b3e..95106821eed 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -122,6 +122,9 @@ function getServerTimeZoneInt($refgmtdate = 'now') function dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth = 0) { global $conf; + if (empty($duration_value)){ + return $time; + } if ($duration_unit == 's') { return $time + ($duration_value); } From 16feb2fe6edcbeee5fdd5c1c4eb12db7fb013f66 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 28 Dec 2023 11:19:55 +0100 Subject: [PATCH 218/315] fix: add missing hook in supplier tab of thirdparty (same as in customer/prospect tab) --- htdocs/fourn/card.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 66becc1fd45..6b7628abadf 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -870,6 +870,15 @@ if ($object->id > 0) { } } + // Allow external modules to add their own shortlist of recent objects + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } else { + print $hookmanager->resPrint; + } + print ''; print '
    '; From f5f1543dac4466d7162bed67f54c6e1c1545320a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 28 Dec 2023 11:49:19 +0100 Subject: [PATCH 219/315] fix : Warning: Undefined property: stdClass:: in /home/httpd/vhosts/aflac.fr/domains/dev.aflac.fr/httpdocs/core/lib/functions.lib.php on line 138 --- 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 e846a9a085c..dad79b1704c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -134,11 +134,11 @@ function getMultidirOutput($object, $module = '') if ($module == 'fichinter') { $module = 'ficheinter'; } - if (isset($conf->$module)) { - return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; - } else { - return 'error-diroutput-not-defined-ffor-this-object='.$module; - } + if (isset($conf->$module) && property_exists($conf->$module, 'multidir_output')) { + return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; + } else { + return 'error-diroutput-not-defined-for-this-object='.$module; + } } /** From 7a6a91621838c4c1bac8a45522fe7fc9e174b263 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 28 Dec 2023 11:54:48 +0100 Subject: [PATCH 220/315] fix : Warning: Undefined property: stdClass:: in /home/httpd/vhosts/aflac.fr/domains/dev.aflac.fr/httpdocs/core/lib/functions.lib.php on line 138 and correct tabs --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dad79b1704c..ae72651d6e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -135,9 +135,9 @@ function getMultidirOutput($object, $module = '') $module = 'ficheinter'; } if (isset($conf->$module) && property_exists($conf->$module, 'multidir_output')) { - return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; - } else { - return 'error-diroutput-not-defined-for-this-object='.$module; + return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; + } else { + return 'error-diroutput-not-defined-for-this-object='.$module; } } From 96e46d189010a1ea38a362d543581d873b0dc916 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 12:32:48 +0100 Subject: [PATCH 221/315] Clean code --- dev/tools/github_authors_and_commits_peryear.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dev/tools/github_authors_and_commits_peryear.sh b/dev/tools/github_authors_and_commits_peryear.sh index bdba2a2a6ed..bf1d1c61037 100755 --- a/dev/tools/github_authors_and_commits_peryear.sh +++ b/dev/tools/github_authors_and_commits_peryear.sh @@ -1,6 +1,7 @@ #!/bin/sh # # Count number of different contributors and number of commits for a given year. +# Can be used for statistics (for example to generate the inforgraphy of the year) # if [ "x$1" = "x" ]; then @@ -12,10 +13,11 @@ fi FROM=$1-01-01 TO=$1-12-31 -echo "Number of contributors for the year" + +echo "--- Number of contributors for the year" echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l -echo "Number of commit for the year" +echo "--- Number of commit for the year" git log --pretty='format:%cd' --date=format:'%Y' | uniq -c | awk '{print "Year: "$2", commits: "$1}' | grep "Year: $1" From 9484953b7ab6e06770562750c263c5751229670b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 12:34:09 +0100 Subject: [PATCH 222/315] Update functions.lib.php --- 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 ae72651d6e6..f505756ddb2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -138,7 +138,7 @@ function getMultidirOutput($object, $module = '') return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; } else { return 'error-diroutput-not-defined-for-this-object='.$module; - } + } } /** From 163a09d6fd0a619fcfb958ae70b15483363a2596 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 12:37:34 +0100 Subject: [PATCH 223/315] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop --- htdocs/commande/document.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/class/html.formfile.class.php | 10 +++++----- htdocs/core/lib/functions.lib.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 66964b2636a..c354e9f34ec 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -177,7 +177,7 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'commande'; $permissiontoadd = $user->rights->commande->creer; $permtoedit = $user->rights->commande->creer; - $param = '&id='.$object->id.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity); + $param = '&id='.$object->id.'&entity='.(empty($object->entity) ? $conf->entity : $object->entity); include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { dol_print_error($db); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2ab753d4272..04029a8ccd3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9797,8 +9797,8 @@ class Form { global $conf, $langs; - $entity = (!empty($object->entity) ? $object->entity : $conf->entity); - $id = (!empty($object->id) ? $object->id : $object->rowid); + $entity = (empty($object->entity) ? $conf->entity : $object->entity); + $id = (empty($object->id) ? $object->rowid : $object->id); $ret = ''; $dir = ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 3f5172c3e91..024e67bb371 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -391,7 +391,7 @@ class FormFile // Add entity in $param if not already exists if (!preg_match('/entity\=[0-9]+/', $param)) { - $param .= ($param ? '&' : '').'entity='.(!empty($object->entity) ? $object->entity : $conf->entity); + $param .= ($param ? '&' : '').'entity='.(empty($object->entity) ? $conf->entity : $object->entity); } $printer = 0; @@ -1401,7 +1401,7 @@ class FormFile } // Preview link if (!$editline) { - print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); + print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(empty($object->entity) ? $conf->entity : $object->entity)); } print "\n"; @@ -1435,14 +1435,14 @@ class FormFile } //print $file['path'].'/'.$smallfile.'
    '; - $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(empty($object->entity) ? $conf->entity : $object->entity)); if (empty($urlforhref)) { - $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(empty($object->entity) ? $conf->entity : $object->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); print ''; } else { print ''; } - print ''; + print ''; print ''; } else { print ' '; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e846a9a085c..4682853b58f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -135,7 +135,7 @@ function getMultidirOutput($object, $module = '') $module = 'ficheinter'; } if (isset($conf->$module)) { - return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)]; + return $conf->$module->multidir_output[(empty($object->entity) ? $conf->entity : $object->entity)]; } else { return 'error-diroutput-not-defined-ffor-this-object='.$module; } From e5f5c499a4b75944be66e0df5ebe46ea7cd8e185 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 12:42:15 +0100 Subject: [PATCH 224/315] Update date.lib.php --- htdocs/core/lib/date.lib.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 95106821eed..be7a7c5996b 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -122,15 +122,12 @@ function getServerTimeZoneInt($refgmtdate = 'now') function dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth = 0) { global $conf; - if (empty($duration_value)){ + if (empty($duration_value)) { return $time; } if ($duration_unit == 's') { return $time + ($duration_value); } - if ($duration_value == 0) { - return $time; - } if ($duration_unit == 'i') { return $time + (60 * $duration_value); } From 46511ae3159fb6c5f08fc261c4deafe8ab278cec Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 28 Dec 2023 16:27:26 +0100 Subject: [PATCH 225/315] Fix #18713 sort on p.label --- htdocs/mrp/mo_list.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 62d9babd6bb..1c8e2669e12 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -240,6 +240,7 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mrp_production as lineparent ON t.fk_parent_line = lineparent.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mrp_mo as moparent ON lineparent.fk_mo = moparent.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON t.fk_product = p.rowid"; // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -567,7 +568,12 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + if ($key == "fk_product") { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'p.label', '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + + } else { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + } $totalarray['nbfield']++; } } From 72ac76d4cfa4ab5ad6cd47dad04b27c3cbb12e8d Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 28 Dec 2023 16:29:07 +0100 Subject: [PATCH 226/315] fix field --- htdocs/mrp/mo_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 1c8e2669e12..01262f21100 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -569,7 +569,7 @@ foreach ($object->fields as $key => $val) { } if (!empty($arrayfields['t.'.$key]['checked'])) { if ($key == "fk_product") { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'p.label', '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'p.ref', '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } else { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; From ec9b048e2ec61795f8ba7045d67467e078e4eecf Mon Sep 17 00:00:00 2001 From: vmaury Date: Thu, 28 Dec 2023 16:34:47 +0100 Subject: [PATCH 227/315] Fix #23248 Prices not updated when external user (client) create a propal or command --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index cb4c4e50afb..42964f17ce1 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -59,7 +59,7 @@ $warehouseStatus = GETPOST('warehousestatus', 'alpha'); $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); // Security check -restrictedArea($user, 'produit|service', 0, 'product&product'); +restrictedArea($user, 'produit|service|commande|propal', 0, 'product&product'); /* From 459f6eb529068643b2e189ab06ff9da68fccac98 Mon Sep 17 00:00:00 2001 From: iznomip <155090186+iznomip@users.noreply.github.com> Date: Thu, 28 Dec 2023 16:51:58 +0100 Subject: [PATCH 228/315] fix(tcpdf): implicit conversion from float --- htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index 5fc00e57f75..70af2dc0f3e 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -7460,7 +7460,7 @@ class TCPDF $color = imagecolorat($img, $xpx, $ypx); // get and correct gamma color $alpha = $this->getGDgamma($img, $color); - imagesetpixel($imgalpha, $xpx, $ypx, $alpha); + imagesetpixel($imgalpha, $xpx, $ypx, (int)$alpha); } } imagepng($imgalpha, $tempfile_alpha); From c5205d0297ae9f1f6d712c3f7e5170c65e777fd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 18:58:01 +0100 Subject: [PATCH 229/315] Fix perm --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 42964f17ce1..31ea346c566 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -59,7 +59,7 @@ $warehouseStatus = GETPOST('warehousestatus', 'alpha'); $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); // Security check -restrictedArea($user, 'produit|service|commande|propal', 0, 'product&product'); +restrictedArea($user, 'produit|service|commande|propal|facture', 0, 'product&product'); /* From f6acd6dfe11eb7929a055ce4e3006dcb0fa99a4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 19:04:23 +0100 Subject: [PATCH 230/315] Update tcpdf.php --- htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index 70af2dc0f3e..a1f7453294d 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -7460,7 +7460,7 @@ class TCPDF $color = imagecolorat($img, $xpx, $ypx); // get and correct gamma color $alpha = $this->getGDgamma($img, $color); - imagesetpixel($imgalpha, $xpx, $ypx, (int)$alpha); + imagesetpixel($imgalpha, $xpx, $ypx, (int) $alpha); } } imagepng($imgalpha, $tempfile_alpha); From 6a9f6049d4bfa6ff0a77e8db8b5d55a70e2b8bab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 19:07:27 +0100 Subject: [PATCH 231/315] Add patch comment --- dev/dolibarr_changes.txt | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index e8af4cd420d..32c47fc9b17 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -66,14 +66,12 @@ NUSOAP: TCPDF: ------ * Replace in tcpdf.php: - if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { unlink($file); } } with - if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { // DOL CHANGE If we keep this, source image files are physically destroyed @@ -81,8 +79,7 @@ with } } -* Replace in tcpdf.php - +* Replace in tcpdf.php: $preserve = array( 'file_id', 'internal_encoding', @@ -90,9 +87,7 @@ with 'bufferlen', 'buffer', 'cached_files', - with - $preserve = array( 'file_id', 'internal_encoding', @@ -103,14 +98,11 @@ with // @CHANGE DOL 'imagekeys', -* Replace in tcpdf.php - +* Replace in tcpdf.php: if (!@TCPDF_STATIC::file_exists($file)) { return false; } - with - if (!@TCPDF_STATIC::file_exists($file)) { // DOL CHANGE If we keep this, the image is not visible on pages after the first one. //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); @@ -121,12 +113,9 @@ with } } -* Replace in tcpdf.php - +* Replace in tcpdf.php: if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) { - with - // @CHANGE LDR Add support for src="file://..." links if (strpos($imgsrc, 'file://') === 0) { $imgsrc = str_replace('file://', '/', $imgsrc); @@ -143,12 +132,9 @@ with elseif (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) { -* In tecnickcom/tcpdf/include/tcpdf_static.php, in function fopenLocal, replace - +* In tecnickcom/tcpdf/include/tcpdf_static.php, in function fopenLocal, replace: if (strpos($filename, '://') === false) { - with - if (strpos($filename, '//') === 0) { // Share folder on a (windows) server // e.g.: "//[MyServerName]/[MySharedFolder]/" @@ -157,11 +143,16 @@ with } elseif (strpos($filename, '://') === false) -* To avoid to have QRcode changed because generated with a random mask, replace -define('QR_FIND_FROM_RANDOM', 2); +* To avoid to have QRcode changed because generated with a random mask, replace: + define('QR_FIND_FROM_RANDOM', 2); with -define('QR_FIND_FROM_RANDOM', false); + define('QR_FIND_FROM_RANDOM', false); +* Change line: + imagesetpixel($imgalpha, $xpx, $ypx, $alpha); +into + imagesetpixel($imgalpha, $xpx, $ypx, (int) $alpha); + * Removed useless directories ("examples", "tools") * Optionnaly, removed all fonts except From 47a633cf2e71ba1708ace70f2fe2a11aa5e65184 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 19:28:28 +0100 Subject: [PATCH 232/315] Update card.php --- htdocs/commande/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b3a2495fd1b..a6384f4969a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -166,7 +166,7 @@ if (empty($reshook)) { } } - $selectedLines = ""; + $selectedLines = GETPOST('toselect', 'array'); if ($cancel) { if (!empty($backtopageforcancel)) { @@ -267,7 +267,6 @@ if (empty($reshook)) { // Add order $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); - $selectedLines = GETPOST('toselect', 'array'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); From aa0057d8d78360a514eb51a7ad5df62bb1e42bfd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 19:39:27 +0100 Subject: [PATCH 233/315] Clean code --- htdocs/comm/propal/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 97e2a1d4307..e69c7898724 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -327,7 +327,6 @@ if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $search_categ = ''; $search_user = ''; $search_sale = ''; $search_ref = ''; From 4ea3dd9dc2d3150931df950f2374d2306b9ce5c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Dec 2023 19:55:35 +0100 Subject: [PATCH 234/315] Debug v19 --- htdocs/comm/propal/list.php | 31 ++++++------- htdocs/commande/list.php | 88 +++++++++++++++++++++---------------- 2 files changed, 64 insertions(+), 55 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e69c7898724..7f5e0a8ce26 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -75,13 +75,13 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'pr $mode = GETPOST('mode', 'alpha'); // Search Fields +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_refcustomer = GETPOST('search_refcustomer', 'alpha'); $search_refproject = GETPOST('search_refproject', 'alpha'); $search_project = GETPOST('search_project', 'alpha'); - $search_societe = GETPOST('search_societe', 'alpha'); $search_societe_alias = GETPOST('search_societe_alias', 'alpha'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); @@ -130,8 +130,6 @@ $search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int'); $search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int'); $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int'); $search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); -$search_btn = GETPOST('button_search', 'alpha'); -$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_date_signature_startday = GETPOST('search_date_signature_startday', 'int'); $search_date_signature_startmonth = GETPOST('search_date_signature_startmonth', 'int'); $search_date_signature_startyear = GETPOST('search_date_signature_startyear', 'int'); @@ -140,23 +138,20 @@ $search_date_signature_endmonth = GETPOST('search_date_signature_endmonth', 'int $search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int'); $search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear); $search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear); - $search_status = GETPOST('search_status', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $object_statut = GETPOST('search_statut', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); - // Pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { +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; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -562,7 +557,7 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $sql = 'SELECT'; -if ($sall || $search_user > 0) { +if ($search_all || $search_user > 0) { $sql = 'SELECT DISTINCT'; } $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax , s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,'; @@ -601,7 +596,7 @@ $sql .= ', '.MAIN_DB_PREFIX.'propal as p'; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; } -if ($sall) { +if ($search_all) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid = pd.fk_propal'; } $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; @@ -689,8 +684,8 @@ if ($search_multicurrency_montant_vat != '') { if ($search_multicurrency_montant_ttc != '') { $sql .= natural_search('p.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); } -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } if ($search_fk_cond_reglement > 0) { $sql .= " AND p.fk_cond_reglement = ".((int) $search_fk_cond_reglement); @@ -871,7 +866,7 @@ if ($socid > 0) { $arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $sall) { +if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -893,8 +888,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } -if ($sall) { - $param .= '&sall='.urlencode($sall); +if ($search_all) { + $param .= '&search_all='.urlencode($search_all); } if ($search_date_startday) { $param .= '&search_date_startday='.urlencode($search_date_startday); @@ -1134,11 +1129,11 @@ if ($search_date_signature_endyear) { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassNoSignature"), $langs->trans("ConfirmMassNoSignatureQuestion"), "nosign", null, '', 0, 200, 500, 1); } - if ($sall) { + if ($search_all) { foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); } - print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; + print '
    '.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
    '; } $i = 0; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index aec3c8390f1..36270401bb5 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -76,6 +76,8 @@ $search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_mon $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int')); $search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int')); +$socid = GETPOST('socid', 'int'); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_product_category = GETPOST('search_product_category', 'int'); $search_ref = GETPOST('search_ref', 'alpha') != '' ? GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); @@ -87,8 +89,6 @@ $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST('search_state', 'alpha'); $search_country = GETPOST('search_country', 'int'); $search_type_thirdparty = GETPOST('search_type_thirdparty', 'int'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$socid = GETPOST('socid', 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); @@ -107,8 +107,6 @@ $search_categ_cus = GETPOST("search_categ_cus", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $search_billed = GETPOST('search_billed', 'int'); $search_status = GETPOST('search_status', 'int'); -$search_btn = GETPOST('button_search', 'alpha'); -$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_project = GETPOST('search_project', 'alpha'); $search_shippable = GETPOST('search_shippable', 'aZ09'); @@ -255,7 +253,6 @@ if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $search_categ = ''; $search_user = ''; $search_sale = ''; $search_product_category = ''; @@ -599,8 +596,14 @@ if (empty($reshook)) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } - if ($sall) { - $param .= '&sall='.urlencode($sall); + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_all) { + $param .= '&search_all='.urlencode($search_all); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); } if ($socid > 0) { $param .= '&socid='.urlencode($socid); @@ -653,14 +656,8 @@ if (empty($reshook)) { if ($search_project_ref >= 0) { $param .= "&search_project_ref=".urlencode($search_project_ref); } - if ($show_files) { - $param .= '&show_files='.urlencode($show_files); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($billed != '') { - $param .= '&billed='.urlencode($billed); + if ($search_billed != '') { + $param .= '&search_billed='.urlencode($search_billed); } header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); @@ -789,7 +786,6 @@ if (!$error && $massaction === 'setbilled' && $permissiontoclose) { * View */ - $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); @@ -813,7 +809,7 @@ $help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_P // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT'; -if ($sall || $search_user > 0) { +if ($search_all || $search_user > 0) { $sql = 'SELECT DISTINCT'; } $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,'; @@ -830,9 +826,6 @@ $sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label, $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,'; $sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,'; $sql .= ' c.fk_input_reason, c.import_key'; -if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { - $sql .= ", cc.fk_categorie, cc.fk_soc"; -} // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -854,14 +847,11 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s2.rowid = s.parent"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -} $sql .= ', '.MAIN_DB_PREFIX.'commande as c'; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; } -if ($sall) { +if ($search_all) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; @@ -887,8 +877,8 @@ if ($search_ref) { if ($search_ref_customer) { $sql .= natural_search('c.ref_client', $search_ref_customer); } -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } if ($search_billed != '' && $search_billed >= 0) { $sql .= ' AND c.facture = '.((int) $search_billed); @@ -997,12 +987,6 @@ if ($search_project_ref != '') { if ($search_project != '') { $sql .= natural_search("p.title", $search_project); } -if ($search_categ_cus > 0) { - $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus); -} -if ($search_categ_cus == -2) { - $sql .= " AND cc.fk_categorie IS NULL"; -} if ($search_fk_cond_reglement > 0) { $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement); } @@ -1023,6 +1007,36 @@ if ($search_sale && $search_sale != '-1') { $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; } } +// Search for tag/category ($searchCategoryCustomerList is an array of ID) +$searchCategoryCustomerOperator = -1; +$searchCategoryCustomerList = array($search_categ_cus); +if (!empty($searchCategoryCustomerList)) { + $searchCategoryCustomerSqlList = array(); + $listofcategoryid = ''; + foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { + if (intval($searchCategoryCustomer) == -2) { + $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc)"; + } elseif (intval($searchCategoryCustomer) > 0) { + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } + } + } + if ($listofcategoryid) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + } + if ($searchCategoryCustomerOperator == 1) { + if (!empty($searchCategoryCustomerSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")"; + } + } else { + if (!empty($searchCategoryCustomerSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")"; + } + } +} // Search for tag/category ($searchCategoryProductList is an array of ID) $searchCategoryProductOperator = -1; $searchCategoryProductList = array($search_product_category); @@ -1138,7 +1152,7 @@ $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $sall) { +if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id); @@ -1162,8 +1176,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } -if ($sall) { - $param .= '&sall='.urlencode($sall); +if ($search_all) { + $param .= '&search_all='.urlencode($search_all); } if ($socid > 0) { $param .= '&socid='.((int) $socid); @@ -1415,14 +1429,14 @@ if ($massaction == 'createbills') { print '

    '; } -if ($sall) { +if ($search_all) { $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } print ''."\n"; - print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; + print '
    '.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
    '; } $moreforfilter = ''; From 48f4e52a22671bc1035f839ba3fbceb5014745c2 Mon Sep 17 00:00:00 2001 From: routmoute Date: Fri, 29 Dec 2023 02:30:32 +0100 Subject: [PATCH 235/315] fix: Display of the list of merged pdf --- htdocs/adherents/list.php | 2 +- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/mails_senderprofile_list.php | 2 +- htdocs/asset/list.php | 2 +- htdocs/asset/model/list.php | 2 +- htdocs/bom/bom_list.php | 2 +- htdocs/bookcal/availabilities_list.php | 2 +- htdocs/bookcal/booking_list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- htdocs/eventorganization/conferenceorboothattendee_list.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/hrm/evaluation_list.php | 2 +- htdocs/hrm/job_list.php | 2 +- htdocs/hrm/position.php | 4 ++-- htdocs/hrm/position_list.php | 2 +- htdocs/hrm/skill_card.php | 2 +- htdocs/hrm/skill_list.php | 2 +- htdocs/knowledgemanagement/knowledgerecord_list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/mo_list.php | 2 +- htdocs/opensurvey/list.php | 2 +- htdocs/partnership/partnership_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/product/stock/stocktransfer/stocktransfer_list.php | 2 +- htdocs/recruitment/recruitmentcandidature_list.php | 2 +- htdocs/recruitment/recruitmentjobposition_list.php | 2 +- htdocs/societe/website.php | 2 +- htdocs/ticket/list.php | 2 +- htdocs/variants/list.php | 2 +- htdocs/webhook/target_list.php | 2 +- htdocs/workstation/workstation_list.php | 2 +- 36 files changed, 37 insertions(+), 37 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 52ef9109f9c..71c908f4533 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1431,7 +1431,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 39e7d4f67c8..131b41dcb1d 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -728,7 +728,7 @@ print '
    '; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 734b64d3331..6ee898a2745 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -685,7 +685,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index adbb6afd400..0c14cbd2d3a 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -654,7 +654,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index 6a7928e0a1e..9e95f29989e 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -660,7 +660,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 07f0879589a..3d0f001eb1b 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -814,7 +814,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index c53ff3bd17d..d7f4c1f2423 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -769,7 +769,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index d8c333a8f61..0eb1fa7b9cd 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -769,7 +769,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4b66c407f04..9c26feab750 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2773,7 +2773,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 80d8b3d58e1..1e3a905d1b9 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -712,7 +712,7 @@ print ''."\n"; print ''."\n"; /* -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 1f575c28a12..83780568b34 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1031,7 +1031,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 0b525072831..216f78a4ce7 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -1080,7 +1080,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 9979cf8923b..557b8545803 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -982,7 +982,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php index f0cb2265e9b..d37031fd5f3 100644 --- a/htdocs/hrm/evaluation_list.php +++ b/htdocs/hrm/evaluation_list.php @@ -741,7 +741,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index 369796130e8..8ac949d8af5 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -736,7 +736,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index e10e34b6198..ff4cd9727de 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -749,7 +749,7 @@ if ($job->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create' print '' . "\n"; - if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; @@ -1311,7 +1311,7 @@ function DisplayPositionList() print '' . "\n"; - if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index dad14763a7d..8d5a96620ae 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -768,7 +768,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index c081ef3a664..9acaf041e47 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -812,7 +812,7 @@ if ($action != "create" && $action != "edit") { print '' . "\n"; - // if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + // if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { // $hidegeneratedfilelistifempty = 1; // if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { // $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php index b4dee2ee3aa..4970ff4f895 100644 --- a/htdocs/hrm/skill_list.php +++ b/htdocs/hrm/skill_list.php @@ -757,7 +757,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 25f41a0c719..1f946a56cda 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -832,7 +832,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index cc9fa67c193..bc2a23382d0 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -858,7 +858,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 01262f21100..b4348ca6606 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -762,7 +762,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 78c20146414..71c7af538df 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -551,7 +551,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index bcfabe92e71..a25b7839170 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -1043,7 +1043,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 089387cd9a2..2f02e545ff9 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -783,7 +783,7 @@ print ''."\n"; print ''."\n"; // no inventory docs yet /* -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 41ee4189a3d..69211355b0d 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -910,7 +910,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index c0e37902b6c..d34aa5379c3 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -1611,7 +1611,7 @@ if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) { //print ''; } -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 6a38300b19a..121d2a238de 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -731,7 +731,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_list.php b/htdocs/product/stock/stocktransfer/stocktransfer_list.php index 0a3dc0b8767..4f649401a76 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_list.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_list.php @@ -514,7 +514,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index ecb15194ab8..18a43f1a8ed 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -884,7 +884,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 4b468fbb317..5c16b263e5f 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -727,7 +727,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 2c38ad02770..e514fed5cde 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -596,7 +596,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 763df3df2fe..8e0caca606f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -1243,7 +1243,7 @@ print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index c49e87cebd2..54b40461b9a 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -876,7 +876,7 @@ $tagidfortablednd = (empty($tagidfortablednd) ? 'tableattributes' : $tagidfortab '."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index e67d231bb18..14b20dc5ad8 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -795,7 +795,7 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; From f0ebe74fba97aff213a924e23eaa1222ba272703 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Dec 2023 04:01:55 +0100 Subject: [PATCH 236/315] FIX Test if email is an answer by emailcollector --- htdocs/emailcollector/class/emailcollector.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 5172278b658..df07651e7af 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1718,12 +1718,17 @@ class EmailCollector extends CommonObject dol_syslog(" Discarded - Email is not an answer (no In-Reply-To header)"); continue; // Exclude email } - // Note: we can have - // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) $isanswer = 0; - if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) { + if (preg_match('/^(Re|AW)\s*:\s+/i', $headers['Subject'])) { $isanswer = 1; } + if (getDolglobalString('EMAILCOLLECTOR_USE_IN_REPLY_TO_TO_DETECT_ANSWERS')) { + // Note: "In-Reply-To" to detect if mail is an answer of another mail is not reliable because we can have: + // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer but may be NOT (for example a transfer of an email rewriten) + if (!empty($headers['In-Reply-To'])) { + $isanswer = 1; + } + } //if ($headers['In-Reply-To'] != $headers['Message-ID'] && empty($headers['References'])) $isanswer = 1; // If in-reply-to differs of message-id, this is a reply //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; From 9c3a52d1ea32aa4e8e61f3ce45d35c603414b075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:12:13 +0100 Subject: [PATCH 237/315] FIX : php 8.1 suppress strftime --- htdocs/compta/bank/annuel.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index ef64c1746f1..c6513038854 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Charles-Fr BENKE + * Copyright (C) 2013-2023 Charlene BENKE * * 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 @@ -51,7 +51,8 @@ if ($user->socid) { $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); $year_start = GETPOST('year_start'); -$year_current = strftime("%Y", time()); +//$year_current = strftime("%Y", time()); +$year_current = dol_print_date(time(), "%Y"); if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; From 77be41720d88523248b97137687ccae6dc0f517d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:13:26 +0100 Subject: [PATCH 238/315] Update graph.php --- htdocs/compta/bank/graph.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 490107e4893..065fc11fecc 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -188,7 +188,8 @@ if ($result < 0) { $subtotal = 0; $day = dol_mktime(12, 0, 0, $month, 1, $year); - $textdate = strftime("%Y%m%d", $day); + //$textdate = strftime("%Y%m%d", $day); + $textdate = dol_print_date($day, "%Y%m%d"); $xyear = substr($textdate, 0, 4); $xday = substr($textdate, 6, 2); $xmonth = substr($textdate, 4, 2); From 2dfb2cc7c498380bbc854689d47fc85e11f34b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:16:19 +0100 Subject: [PATCH 239/315] Update graph.php --- htdocs/compta/bank/graph.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 065fc11fecc..c7be41eed61 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -208,7 +208,8 @@ if ($result < 0) { $labels[$i] = $xday; $day += 86400; - $textdate = strftime("%Y%m%d", $day); + //$textdate = strftime("%Y%m%d", $day); + $textdate = dol_print_date($day, "%Y%m%d"); $xyear = substr($textdate, 0, 4); $xday = substr($textdate, 6, 2); $xmonth = substr($textdate, 4, 2); @@ -333,7 +334,8 @@ if ($result < 0) { $subtotal = 0; $now = time(); $day = dol_mktime(12, 0, 0, 1, 1, $year); - $textdate = strftime("%Y%m%d", $day); + //$textdate = strftime("%Y%m%d", $day); + $textdate = dol_print_date($day, "%Y%m%d"); $xyear = substr($textdate, 0, 4); $xday = substr($textdate, 6, 2); @@ -353,7 +355,8 @@ if ($result < 0) { }*/ $labels[$i] = dol_print_date($day, "%Y%m"); $day += 86400; - $textdate = strftime("%Y%m%d", $day); + //$textdate = strftime("%Y%m%d", $day); + $textdate = dol_print_date($day, "%Y%m%d"); $xyear = substr($textdate, 0, 4); $xday = substr($textdate, 6, 2); $i++; @@ -450,7 +453,8 @@ if ($result < 0) { $subtotal = 0; $day = $min; - $textdate = strftime("%Y%m%d", $day); + //$textdate = strftime("%Y%m%d", $day); + $textdate = dol_print_date($day, "%Y%m%d"); //print "x".$textdate; $i = 0; while ($day <= ($max + 86400)) { // On va au dela du dernier jour @@ -470,7 +474,8 @@ if ($result < 0) { $labels[$i] = substr($textdate, 0, 6); $day += 86400; - $textdate = strftime("%Y%m%d", $day); + //$textdate = strftime("%Y%m%d", $day); + $textdate = dol_print_date($day, "%Y%m%d"); $i++; } From 3a168767cd5ff3638956a191685569433fa66861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:17:34 +0100 Subject: [PATCH 240/315] Update purchasesjournal.php --- htdocs/compta/journal/purchasesjournal.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 49925556725..09e52081228 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -75,7 +75,8 @@ llxHeader('', $langs->trans("PurchasesJournal"), '', '', 0, 0, '', '', $morequer $form = new Form($db); $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$pastmonth = strftime("%m", dol_now()) - 1; +//$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonth = dol_print_date(dol_now(), "%m") - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; From 6707f355560b545866bb1fa57d468044c4410ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:18:27 +0100 Subject: [PATCH 241/315] Update sellsjournal.php --- htdocs/compta/journal/sellsjournal.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 6f76ebfcedb..0ecdf3b2f0c 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -79,7 +79,8 @@ llxHeader('', $langs->trans("SellsJournal"), '', '', 0, 0, '', '', $morequery); $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$pastmonth = strftime("%m", dol_now()) - 1; +//$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonth = dol_print_date(dol_now(), "%m") - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; From e953da37116e11543e6c74b530655de417e9ee1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:21:05 +0100 Subject: [PATCH 242/315] Update index.php --- htdocs/compta/resultat/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 059084dec0e..a2ff6a8eafa 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -1044,8 +1044,8 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { if ($mois > 12) { $annee_decalage = $annee + 1; } - $case = strftime("%Y-%m", dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage)); - + //$case = strftime("%Y-%m", dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage)); + $case = dol_print_date( dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage), "%Y-%m") ; print '
    "; foreach ($list as $entry) { - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($permission) { $href = $_SERVER["PHP_SELF"]; From 1dfc95fd40408d5912ce1506af59b03e4e801e5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Dec 2023 16:08:22 +0100 Subject: [PATCH 248/315] Enhace statistics tool --- dev/tools/github_authors_and_commits_peryear.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dev/tools/github_authors_and_commits_peryear.sh b/dev/tools/github_authors_and_commits_peryear.sh index bf1d1c61037..ab7ed8d7c2b 100755 --- a/dev/tools/github_authors_and_commits_peryear.sh +++ b/dev/tools/github_authors_and_commits_peryear.sh @@ -5,7 +5,7 @@ # if [ "x$1" = "x" ]; then - echo "Usage: $0 YEAR" + echo "Usage: $0 YEARSTART [YEAREND]" exit fi @@ -13,6 +13,9 @@ fi FROM=$1-01-01 TO=$1-12-31 +if [ "x$2" != "x" ]; then + TO=$2-12-31 +fi echo "--- Number of contributors for the year" echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" @@ -20,4 +23,4 @@ git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l echo "--- Number of commit for the year" -git log --pretty='format:%cd' --date=format:'%Y' | uniq -c | awk '{print "Year: "$2", commits: "$1}' | grep "Year: $1" +git log --pretty='format:%cd' --date=format:'%Y' | uniq -c | awk '{ if ($2 >= '$1') { print "Year: "$2", commits: "$1 } }' From 5eef510a8ed12f720d849c2bd06da9775a921be1 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 29 Dec 2023 16:18:20 +0100 Subject: [PATCH 249/315] Fix html.form warnings --- htdocs/core/class/html.form.class.php | 108 +++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 04029a8ccd3..c7255e0db83 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1062,7 +1062,7 @@ class Form * @param string $htmloption Options html on select object * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param array $events 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'))) - * @param array $disableautocomplete Disable autocomplete + * @param int $disableautocomplete Disable autocomplete * @return string HTML string with select and input */ public function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array(), $disableautocomplete = 0) @@ -1764,7 +1764,7 @@ class Form * @param integer $disableifempty Set tag 'disabled' on select if there is no choice * @return int|string Return integer <0 if KO, HTML with select string if OK. */ - public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0) + public function selectcontacts($socid, $selected = array(), $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0) { global $conf, $langs, $hookmanager, $action; @@ -1973,13 +1973,13 @@ class Form * @param array $exclude Array list of users id to exclude * @param int $disabled If select list must be disabled * @param array|string $include Array list of users id to include. User '' for all users or 'hierarchy' to have only supervised users or 'hierarchyme' to have supervised + me - * @param int $enableonly Array list of users id to be enabled. All other must be disabled + * @param array|int $enableonly Array list of users id to be enabled. All other must be disabled * @param string $force_entity '0' or Ids of environment to force * @return void * @deprecated Use select_dolusers instead * @see select_dolusers() */ - public function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0') + public function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = array(), $force_entity = '0') { // phpcs:enable print $this->select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity); @@ -2011,7 +2011,7 @@ class Form * @return array|string HTML select string * @see select_dolgroups() */ - public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = 0, $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $notdisabled = 0, $outputmode = 0, $multiple = false, $forcecombo = 0) + public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $notdisabled = 0, $outputmode = 0, $multiple = false, $forcecombo = 0) { // phpcs:enable global $conf, $user, $langs, $hookmanager; @@ -2262,8 +2262,8 @@ class Form * @param array $exclude Array list of users id to exclude * @param int $disabled If select list must be disabled * @param array $include Array list of users id to include or 'hierarchy' to have only supervised users - * @param array $enableonly Array list of users id to be enabled. All other must be disabled - * @param int $force_entity '0' or Ids of environment to force + * @param array|int $enableonly Array list of users id to be enabled. All other must be disabled + * @param string $force_entity '0' or Ids of environment to force * @param int $maxlength Maximum length of string into list (0=no limit) * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param string $morefilter Add more filters into sql request @@ -2274,7 +2274,7 @@ class Form * @return string HTML select string * @see select_dolgroups() */ - public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array()) + public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array()) { // phpcs:enable global $langs; @@ -2357,7 +2357,7 @@ class Form * @param int $disabled If select list must be disabled * @param array $include Array list of users id to include or 'hierarchy' to have only supervised users * @param array $enableonly Array list of users id to be enabled. All other must be disabled - * @param int $force_entity '0' or Ids of environment to force + * @param string $force_entity '0' or Ids of environment to force * @param int $maxlength Maximum length of string into list (0=no limit) * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param string $morefilter Add more filters into sql request @@ -2365,7 +2365,7 @@ class Form * @param array $listofresourceid Array with properties of each resource * @return string HTML select string */ - public function select_dolresources_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofresourceid = array()) + public function select_dolresources_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofresourceid = array()) { // phpcs:enable global $langs; @@ -2460,11 +2460,11 @@ class Form * 'warehouseclosed' = count products from closed warehouses, * 'warehouseinternal' = count products from warehouses for internal correct/transfer only * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) - * @param string $nooutput No print, return the output into a string + * @param int $nooutput No print, return the output into a string * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase * @return void|string */ - public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1) + public function select_produits($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1) { // phpcs:enable global $langs, $conf; @@ -2611,7 +2611,7 @@ class Form /** * Return list of BOM for customer in Ajax if Ajax activated or go to select_produits_list * - * @param int $selected Preselected BOM id + * @param string $selected Preselected BOM id * @param string $htmlname Name of HTML select field (must be unique in page). * @param int $limit Limit on number of returned lines * @param int $status Sell status -1=Return all bom, 0=Draft BOM, 1=Validated BOM @@ -3454,7 +3454,7 @@ class Form * Return list of suppliers products * * @param int $socid Id of supplier thirdparty (0 = no filter) - * @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') + * @param stringc $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') * @param string $htmlname Name of HTML select * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param string $filtre Generic filter. Data must not come from user input. @@ -3906,7 +3906,7 @@ class Form * @param int $selected_supplier Pre-selected supplier if more than 1 result * @return string */ - public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') + public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = 0) { // phpcs:enable global $langs, $conf; @@ -4107,7 +4107,7 @@ class Form /** * Retourne la liste des types de delais de livraison possibles * - * @param int $selected Id du type de delais pre-selectionne + * @param string $selected Id du type de delais pre-selectionne * @param string $htmlname Nom de la zone select * @param string $filtertype To add a filter * @param int $addempty Add empty entry @@ -4197,7 +4197,7 @@ class Form * Return list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...) * List found into table c_input_reason loaded by loadCacheInputReason * - * @param int $selected Id or code of type origin to select by default + * @param string $selected Id or code of type origin to select by default * @param string $htmlname Nom de la zone select * @param string $exclude To exclude a code value (Example: SRC_PROP) * @param int $addempty Add an empty entry @@ -4301,7 +4301,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @return void @@ -4325,7 +4325,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @return string String for the HTML select component @@ -4522,7 +4522,7 @@ class Form * * @param string $selected Id pre-selectionne * @param string $htmlname Nom de la zone select - * @param string $addjscombo Add js combo + * @param int $addjscombo Add js combo * @return string Code of HTML select to chose tax or not */ public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type', $addjscombo = 0) @@ -4737,7 +4737,7 @@ class Form * Display form to select shipping mode * * @param string $page Page - * @param int $selected Id of shipping mode + * @param string $selected Id of shipping mode * @param string $htmlname Name of select html field * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void @@ -5028,7 +5028,7 @@ class Form * Display form to select bank account * * @param string $page Page - * @param int $selected Id of bank account + * @param string $selected Id of bank account * @param string $htmlname Name of select html field * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void @@ -5184,7 +5184,7 @@ class Form * @deprecated * @see formconfirm() */ - public function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) + public function form_confirm($page, $title, $question, $action, $formquestion = array(), $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) { // phpcs:enable dol_syslog(__METHOD__ . ': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); @@ -5623,7 +5623,7 @@ class Form * * @param int $page Page * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id pre-selected project + * @param string $selected Id pre-selected project * @param string $htmlname Name of select field * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable) * @param int $maxlength Max length @@ -5683,7 +5683,7 @@ class Form * @param int $addempty Add empty entry * @param string $type Type ('direct-debit' or 'bank-transfer') * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates) - * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int $nooutput No print is done. String is returned. @@ -5863,7 +5863,7 @@ class Form * @param array $include List of users id to include * @return void */ - public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') + public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = array(), $include = array()) { // phpcs:enable global $langs; @@ -5894,7 +5894,7 @@ class Form * Show form with payment mode * * @param string $page Page - * @param int $selected Id mode pre-selectionne + * @param string $selected Id mode pre-selectionne * @param string $htmlname Name of select html field * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) * @param int $active Active or not, -1 = all @@ -5940,7 +5940,7 @@ class Form * Show form with transport mode * * @param string $page Page - * @param int $selected Id mode pre-select + * @param string $selected Id mode pre-select * @param string $htmlname Name of select html field * @param int $active Active or not, -1 = all * @param int $addempty 1=Add empty entry @@ -6004,7 +6004,7 @@ class Form * @param string $currency Currency code to explain the rate * @return void */ - public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') + public function form_multicurrency_rate($page, $rate = 0.0, $htmlname = 'multicurrency_tx', $currency = '') { // phpcs:enable global $langs, $mysoc, $conf; @@ -6142,7 +6142,7 @@ class Form * * @param string $page Page * @param Societe $societe Filter on third party - * @param int $selected Id contact pre-selectionne + * @param string $selected Id contact pre-selectionne * @param string $htmlname Name of HTML select. If 'none', we just show contact link. * @return void */ @@ -6250,7 +6250,7 @@ class Form * * @param string $selected preselected currency code * @param string $htmlname name of HTML select list - * @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code + * @param int $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code * @param string $useempty '1'=Allow empty value * @return string */ @@ -6468,7 +6468,7 @@ class Form * @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key * @return string */ - public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) + public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = null, $societe_acheteuse = null, $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) { // phpcs:enable global $langs, $conf, $mysoc; @@ -6653,7 +6653,7 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param integer|string $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty @@ -6670,7 +6670,7 @@ class Form * @deprecated * @see selectDate(), form_date(), select_month(), select_year(), select_dayofweek() */ - public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') + public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = 0, $addplusone = '', $adddateof = '') { // phpcs:enable dol_syslog(__METHOD__ . ': using select_date is deprecated. Use selectDate instead.', LOG_WARNING); @@ -6690,11 +6690,11 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). - * @param integer $set_time_end Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param integer|string $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param integer|string $set_time_end Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name - * @param string $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only - * @param string $forcenewline Force new line between the 2 dates. + * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only + * @param int $forcenewline Force new line between the 2 dates. * @return string Html for selectDate * @see form_date(), select_month(), select_year(), select_dayofweek() */ @@ -6726,7 +6726,7 @@ class Form * @param int $d 1=Show days, month, years * @param int $addnowlink Add a link "Now", 1 with server time, 2 with local computer time * @param int $disabled Disable input fields - * @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') + * @param int|string $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. * @param int|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) * @param string $openinghours Specify hour start and hour end for the select ex 8,20 @@ -7222,7 +7222,7 @@ class Form * Function to show a form to select a duration on a page * * @param string $prefix Prefix for input fields - * @param int $iSecond Default preselected duration (number of seconds or '') + * @param int|string $iSecond Default preselected duration (number of seconds or '') * @param int $disabled Disable the combo box * @param string $typehour If 'select' then input hour and input min is a combo, * If 'text' input hour is in text and input min is a text, @@ -7312,7 +7312,7 @@ class Form /** * Return list of tickets in Ajax if Ajax activated or go to selectTicketsList * - * @param int $selected Preselected tickets + * @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 @@ -7325,7 +7325,7 @@ class Form * @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 string $nooutput No print, return the output into a string + * @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) @@ -7382,7 +7382,7 @@ class Form * Return list of tickets. * Called by selectTickets. * - * @param int $selected Preselected ticket + * @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 @@ -7538,7 +7538,7 @@ class Form /** * Return list of projects in Ajax if Ajax activated or go to selectTicketsList * - * @param int $selected Preselected tickets + * @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 @@ -7551,7 +7551,7 @@ class Form * @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 string $nooutput No print, return the output into a string + * @param int $nooutput No print, return the output into a string * @return string */ public function selectProjects($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0) @@ -7607,7 +7607,7 @@ class Form * Return list of projects. * Called by selectProjects. * - * @param int $selected Preselected project + * @param string $selected Preselected project * @param string $htmlname Name of select html * @param string $filtertype Filter on project type * @param int $limit Limit on number of returned lines @@ -7767,7 +7767,7 @@ class Form /** * Return list of members in Ajax if Ajax activated or go to selectTicketsList * - * @param int $selected Preselected tickets + * @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 @@ -7780,7 +7780,7 @@ class Form * @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 string $nooutput No print, return the output into a string + * @param int $nooutput No print, return the output into a string * @return string */ public function selectMembers($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0) @@ -7840,7 +7840,7 @@ class Form * Return list of adherents. * Called by selectMembers. * - * @param int $selected Preselected adherent + * @param string $selected Preselected adherent * @param string $htmlname Name of select html * @param string $filtertype Filter on adherent type * @param int $limit Limit on number of returned lines @@ -9037,7 +9037,7 @@ class Form * @param string $title Title * @return int Return integer <0 if KO, >=0 if OK */ - public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false, $title = 'RelatedObjects') + public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = array(), $title = 'RelatedObjects') { global $conf, $langs, $hookmanager; global $bc, $action; @@ -9993,14 +9993,14 @@ class Form * @param string|array $exclude Array list of groups id to exclude * @param int $disabled If select list must be disabled * @param string|array $include Array list of groups id to include - * @param int $enableonly Array list of groups id to be enabled. All other must be disabled + * @param array $enableonly Array list of groups id to be enabled. All other must be disabled * @param string $force_entity '0' or Ids of environment to force * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter) * @param string $morecss More css to add to html component * @return string * @see select_dolusers() */ - public function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $multiple = false, $morecss = '') + public function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = array(), $force_entity = '0', $multiple = false, $morecss = '') { // phpcs:enable global $conf, $user, $langs; @@ -10364,7 +10364,7 @@ class Form * Output a combo list with invoices qualified for a third party * * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id invoice preselected + * @param string $selected Id invoice preselected * @param string $htmlname Name of HTML select * @param int $maxlength Maximum length of label * @param int $option_only Return only html options lines without the select tag @@ -10515,7 +10515,7 @@ class Form /** * Output a combo list with invoices qualified for a third party * - * @param int $selected Id invoice preselected + * @param string $selected Id invoice preselected * @param string $htmlname Name of HTML select * @param int $maxlength Maximum length of label * @param int $option_only Return only html options lines without the select tag From 7b42e2d7c2c0ad264a1706cb80d33ced46025910 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Dec 2023 16:28:10 +0100 Subject: [PATCH 250/315] Enhance statistics tool --- dev/tools/github_authors_and_commits_peryear.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tools/github_authors_and_commits_peryear.sh b/dev/tools/github_authors_and_commits_peryear.sh index ab7ed8d7c2b..9b6d299601e 100755 --- a/dev/tools/github_authors_and_commits_peryear.sh +++ b/dev/tools/github_authors_and_commits_peryear.sh @@ -18,9 +18,10 @@ if [ "x$2" != "x" ]; then fi echo "--- Number of contributors for the year" -echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" -git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l +echo "git log --since $FROM --before $TO | grep ^Author | awk -F'<' '{ print $1 }' | iconv -f UTF-8 -t ASCII//TRANSLIT | sort -u -f -i -b | wc -l" +git log --since $FROM --before $TO | grep '^Author' | awk -F"<" '{ print $1 }' | iconv -f UTF-8 -t ASCII//TRANSLIT | sort -u -f -i -b | wc -l echo "--- Number of commit for the year" -git log --pretty='format:%cd' --date=format:'%Y' | uniq -c | awk '{ if ($2 >= '$1') { print "Year: "$2", commits: "$1 } }' +echo "git log --pretty='format:%cd' --date=format:'%Y' | sort | uniq -c | awk '{ if (\$2 >= '"$1"') { print \"Year: \"\$2\", commits: \"\$1 } }'" +git log --pretty='format:%cd' --date=format:'%Y' | sort | uniq -c | awk '{ if ($2 >= '$1') { print "Year: "$2", commits: "$1 } }' From ab3737e56929f90f7a444e076b6a2cbfcfb13ae4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Dec 2023 17:55:09 +0100 Subject: [PATCH 251/315] Fix libxml_disable_entity_loader(true) must be called only if LIBXML is lower than 20900 (disabled by default for libxml 2.9.0) --- htdocs/admin/system/dolibarr.php | 6 ++++++ htdocs/admin/system/filecheck.php | 6 ++++++ htdocs/admin/tools/update.php | 6 ++++++ htdocs/api/class/api_setup.class.php | 6 ++++++ htdocs/core/class/rssparser.class.php | 8 ++++++-- htdocs/core/lib/functions.lib.php | 6 +++++- htdocs/core/tpl/login.tpl.php | 6 ++++++ 7 files changed, 41 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index cc7fc970529..c7f07ad0040 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -52,6 +52,12 @@ if ($action == 'getlastversion') { $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); if (function_exists('simplexml_load_string')) { + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } + $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } else { setEventMessages($langs->trans("ErrorPHPDoesNotSupport", "xml"), null, 'errors'); diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index b0abc81cf7a..a1e04d8db07 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -176,6 +176,12 @@ if (GETPOST('target') == 'remote') { if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."xmlfileend"; + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } + $xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } else { $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].(($xmlarray['http_code'] == 400 && $xmlarray['content']) ? ' '.$xmlarray['content'] : '').' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 2bed274fd72..d2b5ed921a8 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -63,6 +63,12 @@ if ($action == 'getlastversion') { $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); if (function_exists('simplexml_load_string')) { + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } + $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } else { $sfurl = 'xml_not_available'; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 09837376096..5ec9c9a34aa 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -2052,6 +2052,12 @@ class Setup extends DolibarrApi throw new RestException(500, $langs->trans("ErrorURLMustEndWith", $xmlremote, '.xml')); } + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } + if ($target == 'local') { if (dol_is_file($xmlfile)) { $xml = simplexml_load_file($xmlfile); diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 69ee72acb2c..1a85d324b90 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -260,9 +260,13 @@ class RssParser if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) { //print 'xx'.LIBXML_NOCDATA; libxml_use_internal_errors(false); - libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900 + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } - $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA|LIBXML_NOENT); + $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA); } else { if (!function_exists('xml_parser_create')) { $this->error = 'Function xml_parser_create are not supported by your PHP'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b0386e12ceb..b706c895368 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7613,7 +7613,11 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' if (!empty($out) && getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check != 'restricthtmlallowunvalid') { try { libxml_use_internal_errors(false); // Avoid to fill memory with xml errors - libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900 + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } $dom = new DOMDocument(); // Add a trick to solve pb with text without parent tag diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 9e247fc1947..05496f0cd57 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -422,6 +422,12 @@ if (getDolGlobalString('MAIN_EASTER_EGG_COMMITSTRIP')) { $resgetcommitstrip = getURLContent("https://www.commitstrip.com/en/feed/"); } if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200') { + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } + $xml = simplexml_load_string($resgetcommitstrip['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); $little = $xml->channel->item[0]->children('content', true); print preg_replace('/width="650" height="658"/', '', $little->encoded); From 544f8413cd08ce948ad7e316744e3a7eb42aa1d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Dec 2023 18:41:46 +0100 Subject: [PATCH 252/315] FIX #yogosha19721 --- htdocs/core/ajax/fileupload.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index fc89b77c56b..25ea79b1939 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -38,6 +38,7 @@ if (!defined('NOREQUIRESOC')) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php'; // Class to upload common files require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $id = GETPOST('fk_element', 'int'); $element = GETPOST('element', 'alpha'); // 'myobject' (myobject=mymodule) or 'myobject@mymodule' or 'myobject_mysubobject' (myobject=mymodule) @@ -83,7 +84,7 @@ header('Pragma: no-cache'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Content-Disposition: inline; filename="files.json"'); header('X-Content-Type-Options: nosniff'); -header('Access-Control-Allow-Origin: *'); +header('Access-Control-Allow-Origin: '.getRootURLFromURL(DOL_MAIN_URL_ROOT)); header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE'); header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); From cbe860f88f56e7927cecb5931cb5fd7b86af70b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Dec 2023 18:55:07 +0100 Subject: [PATCH 253/315] Update html.form.class.php --- 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 c7255e0db83..cc0bd501dbe 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3454,7 +3454,7 @@ class Form * Return list of suppliers products * * @param int $socid Id of supplier thirdparty (0 = no filter) - * @param stringc $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') + * @param string $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') * @param string $htmlname Name of HTML select * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param string $filtre Generic filter. Data must not come from user input. From 1d38a3b7b80c430b3c88e456814b1b68f3a0078a Mon Sep 17 00:00:00 2001 From: routmoute Date: Fri, 29 Dec 2023 20:19:17 +0100 Subject: [PATCH 254/315] fix conflict with develop branch --- htdocs/adherents/list.php | 2 +- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/mails_senderprofile_list.php | 2 +- htdocs/asset/list.php | 2 +- htdocs/asset/model/list.php | 2 +- htdocs/bom/bom_list.php | 2 +- htdocs/bookcal/availabilities_list.php | 2 +- htdocs/bookcal/booking_list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- htdocs/eventorganization/conferenceorboothattendee_list.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/hrm/evaluation_list.php | 2 +- htdocs/hrm/job_list.php | 2 +- htdocs/hrm/position.php | 4 ++-- htdocs/hrm/position_list.php | 2 +- htdocs/hrm/skill_card.php | 2 +- htdocs/hrm/skill_list.php | 2 +- htdocs/knowledgemanagement/knowledgerecord_list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/mo_list.php | 2 +- htdocs/opensurvey/list.php | 2 +- htdocs/partnership/partnership_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/product/stock/stocktransfer/stocktransfer_list.php | 2 +- htdocs/recruitment/recruitmentcandidature_list.php | 2 +- htdocs/recruitment/recruitmentjobposition_list.php | 2 +- htdocs/societe/website.php | 2 +- htdocs/ticket/list.php | 2 +- htdocs/variants/list.php | 2 +- htdocs/webhook/target_list.php | 2 +- htdocs/workstation/workstation_list.php | 2 +- 36 files changed, 37 insertions(+), 37 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 71c908f4533..490453d7298 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1431,7 +1431,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 131b41dcb1d..cdd0000292d 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -728,7 +728,7 @@ print '
    '; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 6ee898a2745..ef5649d344b 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -685,7 +685,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 0c14cbd2d3a..bc000717b55 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -654,7 +654,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index 9e95f29989e..12dec5c2cc6 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -660,7 +660,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 3d0f001eb1b..61b246f4447 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -814,7 +814,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index d7f4c1f2423..038dd20b4f1 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -769,7 +769,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index 0eb1fa7b9cd..3ef558257d9 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -769,7 +769,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9c26feab750..a71212a517c 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2773,7 +2773,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 1e3a905d1b9..5d5ee2ea298 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -712,7 +712,7 @@ print ''."\n"; print ''."\n"; /* -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 83780568b34..fb0c72b591b 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1031,7 +1031,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 216f78a4ce7..148cd91bd11 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -1080,7 +1080,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 557b8545803..ebe4239dbde 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -982,7 +982,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php index d37031fd5f3..0549f44cab1 100644 --- a/htdocs/hrm/evaluation_list.php +++ b/htdocs/hrm/evaluation_list.php @@ -741,7 +741,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index 8ac949d8af5..818e8a4a1d5 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -736,7 +736,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index ff4cd9727de..fbc65a685a4 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -749,7 +749,7 @@ if ($job->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create' print '' . "\n"; - if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; @@ -1311,7 +1311,7 @@ function DisplayPositionList() print '' . "\n"; - if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 8d5a96620ae..5486ea67f59 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -768,7 +768,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 9acaf041e47..deaef1889a1 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -812,7 +812,7 @@ if ($action != "create" && $action != "edit") { print '' . "\n"; - // if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + // if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { // $hidegeneratedfilelistifempty = 1; // if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { // $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php index 4970ff4f895..08fd84eca59 100644 --- a/htdocs/hrm/skill_list.php +++ b/htdocs/hrm/skill_list.php @@ -757,7 +757,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 1f946a56cda..c76d4b29d03 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -832,7 +832,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index bc2a23382d0..aee8a2b5197 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -858,7 +858,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index b4348ca6606..4ab210390c2 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -762,7 +762,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 71c7af538df..26bf4473a3d 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -551,7 +551,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index a25b7839170..3d455376f58 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -1043,7 +1043,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 2f02e545ff9..4cdb56b25e0 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -783,7 +783,7 @@ print ''."\n"; print ''."\n"; // no inventory docs yet /* -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 69211355b0d..8c32ae17694 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -910,7 +910,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index d34aa5379c3..e7b2e3dec79 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -1611,7 +1611,7 @@ if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) { //print '
    '; } -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 121d2a238de..ff9ba693300 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -731,7 +731,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_list.php b/htdocs/product/stock/stocktransfer/stocktransfer_list.php index 4f649401a76..a6bca735c44 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_list.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_list.php @@ -514,7 +514,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 18a43f1a8ed..c8165a88a2a 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -884,7 +884,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 5c16b263e5f..44b8aa15f1a 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -727,7 +727,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index e514fed5cde..bca6bbaa375 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -596,7 +596,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 8e0caca606f..d0b25421b37 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -1243,7 +1243,7 @@ print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 54b40461b9a..961e396826d 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -876,7 +876,7 @@ $tagidfortablednd = (empty($tagidfortablednd) ? 'tableattributes' : $tagidfortab '."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 14b20dc5ad8..e665d14807c 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -795,7 +795,7 @@ print ''."\n"; print ''."\n"; -if (array_key_exists('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { $hidegeneratedfilelistifempty = 0; From 6aad6e1e5d05cdbc06c89661c36b6e6e722e29d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Dec 2023 04:27:23 +0100 Subject: [PATCH 255/315] FIX public user photo not visible if $dolibarr_main_instance_unique_id not defined into conf file. --- htdocs/core/lib/files.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e30931b3305..9f6abcfdeb1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2672,14 +2672,15 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessok = false; $reg = array(); if (preg_match('/^(\d+)\/photos\//', $original_file, $reg)) { - if ($reg[0]) { + if ($reg[1]) { $tmpobject = new User($db); - $tmpobject->fetch($reg[0], '', '', 1); + $tmpobject->fetch($reg[1], '', '', 1); if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $tmpobject)) { $securekey = GETPOST('securekey', 'alpha', 1); // Security check - global $dolibarr_main_instance_unique_id; - $encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$tmpobject->id.'-'.$tmpobject->login, 'md5'); + global $dolibarr_main_cookie_cryptkey, $dolibarr_main_instance_unique_id; + $valuetouse = $dolibarr_main_instance_unique_id ? $dolibarr_main_instance_unique_id : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey + $encodedsecurekey = dol_hash($valuetouse.'uservirtualcard'.$tmpobject->id.'-'.$tmpobject->login, 'md5'); if ($encodedsecurekey == $securekey) { $accessok = true; } From ed3ef01e37e02d85429943b8773586aa2c5c78ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Dec 2023 04:27:23 +0100 Subject: [PATCH 256/315] FIX public user photo not visible if $dolibarr_main_instance_unique_id not defined into conf file. --- htdocs/core/lib/files.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 925e9683fd4..7c031801369 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2664,14 +2664,15 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessok = false; $reg = array(); if (preg_match('/^(\d+)\/photos\//', $original_file, $reg)) { - if ($reg[0]) { + if ($reg[1]) { $tmpobject = new User($db); - $tmpobject->fetch($reg[0], '', '', 1); + $tmpobject->fetch($reg[1], '', '', 1); if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $tmpobject)) { $securekey = GETPOST('securekey', 'alpha', 1); // Security check - global $dolibarr_main_instance_unique_id; - $encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$tmpobject->id.'-'.$tmpobject->login, 'md5'); + global $dolibarr_main_cookie_cryptkey, $dolibarr_main_instance_unique_id; + $valuetouse = $dolibarr_main_instance_unique_id ? $dolibarr_main_instance_unique_id : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey + $encodedsecurekey = dol_hash($valuetouse.'uservirtualcard'.$tmpobject->id.'-'.$tmpobject->login, 'md5'); if ($encodedsecurekey == $securekey) { $accessok = true; } From 33f3e6bf6eff9a20d96f498dad878cb2d1069feb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Dec 2023 04:46:21 +0100 Subject: [PATCH 257/315] Use stripe version 2022-11-15 by default. --- htdocs/stripe/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 59341f535d7..bdf8d2545db 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -52,4 +52,4 @@ if (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha')) { \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version -\Stripe\Stripe::setApiVersion(!getDolGlobalString('STRIPE_FORCE_VERSION') ? "2020-08-27" : $conf->global->STRIPE_FORCE_VERSION); // force version API +\Stripe\Stripe::setApiVersion(!getDolGlobalString('STRIPE_FORCE_VERSION') ? "2022-11-15" : $conf->global->STRIPE_FORCE_VERSION); // force version API From de020ca4ab2459757d5d8e07332c6b183db1e00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:13:16 +0100 Subject: [PATCH 258/315] php 8.1 depreciated strftime --- htdocs/core/modules/asset/mod_asset_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/asset/mod_asset_standard.php b/htdocs/core/modules/asset/mod_asset_standard.php index 7fa0e4a6491..549575f4adf 100644 --- a/htdocs/core/modules/asset/mod_asset_standard.php +++ b/htdocs/core/modules/asset/mod_asset_standard.php @@ -151,7 +151,7 @@ class mod_asset_standard extends ModeleNumRefAsset //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 612062d7ab4828ff53d6fe96e2a9a55949ec44f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:13:51 +0100 Subject: [PATCH 259/315] Update mod_bom_standard.php --- htdocs/core/modules/bom/mod_bom_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 49c1bec0948..4c40082336a 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -142,7 +142,7 @@ class mod_bom_standard extends ModeleNumRefBoms //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 64f0656051c86cf6748c67443e47ddf3a52afde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:14:22 +0100 Subject: [PATCH 260/315] Update mod_chequereceipt_mint.php --- htdocs/core/modules/cheque/mod_chequereceipt_mint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 7edddab5f26..723786ed485 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -139,7 +139,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts //$date=time(); $date = $object->date_bordereau; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 259e61b34f36f594760431a9d01dfd7e2f18ffbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:14:43 +0100 Subject: [PATCH 261/315] Update mod_commande_marbre.php --- htdocs/core/modules/commande/mod_commande_marbre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index ddb1b689ddb..6bc537c7039 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -154,7 +154,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes //$date=time(); $date = $object->date; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 1a0e475705a87f0d37b7e00c7504564de28d2688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:15:09 +0100 Subject: [PATCH 262/315] Update mod_contract_serpis.php --- htdocs/core/modules/contract/mod_contract_serpis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 37b357ddc63..aba9d6df710 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -150,7 +150,7 @@ class mod_contract_serpis extends ModelNumRefContracts } $date = $contract->date_contrat; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 00110f11c9fdf6c6870bf1d0147d0af4a49dfdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:15:32 +0100 Subject: [PATCH 263/315] Update mod_delivery_jade.php --- htdocs/core/modules/delivery/mod_delivery_jade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index 1d5b7edda29..7a0713025cf 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -157,7 +157,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder if (empty($date)) { $date = dol_now(); } - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From c32b1c4ed04d5c4eb67e5a151623565907d27f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:15:57 +0100 Subject: [PATCH 264/315] Update mod_expedition_safor.php --- htdocs/core/modules/expedition/mod_expedition_safor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 29c9299fb73..ca265082d1a 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -145,7 +145,7 @@ class mod_expedition_safor extends ModelNumRefExpedition } $date = $shipment->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From ed35c637c12f27ad35ce34f8b8a38b4f3b9d93d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:16:24 +0100 Subject: [PATCH 265/315] Update mod_expensereport_jade.php --- htdocs/core/modules/expensereport/mod_expensereport_jade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index 7cc024575d2..8121a235182 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -202,7 +202,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport return 0; } - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 09ec073782e846d6c6933d3990bd6ebd7cffa7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:16:49 +0100 Subject: [PATCH 266/315] Update mod_facture_mars.php --- htdocs/core/modules/facture/mod_facture_mars.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 62ca719be0c..f35e1f8f62b 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -223,7 +223,7 @@ class mod_facture_mars extends ModeleNumRefFactures return $ref; } elseif ($mode == 'next') { $date = $invoice->date; // This is invoice date (not creation date) - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 66788f7f5b957699b0e59df3c308516354164ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:17:15 +0100 Subject: [PATCH 267/315] Update mod_pacific.php --- htdocs/core/modules/fichinter/mod_pacific.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 85411d143b9..5152250a838 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -147,7 +147,7 @@ class mod_pacific extends ModeleNumRefFicheinter //$date=time(); $date = $object->datec; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 9800ce0bcadd39d8ca7a94f9ec31511d889a4afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:18:05 +0100 Subject: [PATCH 268/315] Update mod_holiday_madonna.php --- htdocs/core/modules/holiday/mod_holiday_madonna.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 110e27b755e..e1729839b60 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2018-2023 Charlene Benke * * 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,7 +151,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays } $date = $holiday->date_debut; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 8e7ad7dce45d91cb174bf0b63ec3ba48da1d4fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:18:34 +0100 Subject: [PATCH 269/315] Update mod_evaluation_standard.php --- htdocs/core/modules/hrm/mod_evaluation_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/hrm/mod_evaluation_standard.php b/htdocs/core/modules/hrm/mod_evaluation_standard.php index ced3fe35e23..c00b8e62a55 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_standard.php +++ b/htdocs/core/modules/hrm/mod_evaluation_standard.php @@ -150,7 +150,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From f9b00c244ed79558ae73483ed785d7eccbfb7497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:19:22 +0100 Subject: [PATCH 270/315] Update mod_payment_cicada.php --- htdocs/core/modules/payment/mod_payment_cicada.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index 466bb81ea09..3c6164bdb0b 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -149,7 +149,7 @@ class mod_payment_cicada extends ModeleNumRefPayments //$date=time(); $date = $object->datepaye; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 58087b56fc9929f3986fd5f6b139ad6c2a0a0138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:20:25 +0100 Subject: [PATCH 271/315] Update mod_task_simple.php --- htdocs/core/modules/project/task/mod_task_simple.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index cc08c0ad20e..55f9472ab17 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -150,9 +150,7 @@ class mod_task_simple extends ModeleNumRefTask } $date = empty($object->date_c) ? dol_now() : $object->date_c; - - //$yymm = strftime("%y%m",time()); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 1b4153708784f4b0b026a140baea08fc38e7f75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:21:02 +0100 Subject: [PATCH 272/315] Update mod_propale_marbre.php --- htdocs/core/modules/propale/mod_propale_marbre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index b9638dc904b..c85e0d3bc91 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -151,7 +151,7 @@ class mod_propale_marbre extends ModeleNumRefPropales } $date = time(); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From c74546295acefb1316fef3cbd15dc9b8182410b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:21:26 +0100 Subject: [PATCH 273/315] Update mod_reception_beryl.php --- htdocs/core/modules/reception/mod_reception_beryl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 816946651e8..905cd90e662 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -125,7 +125,7 @@ class mod_reception_beryl extends ModelNumRefReception } $date = time(); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 132df2c8aeabd321fab3e54233f0778fbe7ad8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:22:08 +0100 Subject: [PATCH 274/315] Update mod_stocktransfer_standard.php --- .../modules/stocktransfer/mod_stocktransfer_standard.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php index 192260118aa..113da55c576 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -151,7 +151,7 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; From 3bfc95bdb82f209da7edfa20e4453c0d4196da48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:22:42 +0100 Subject: [PATCH 275/315] Update mod_facture_fournisseur_cactus.php --- .../modules/supplier_invoice/mod_facture_fournisseur_cactus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index bfb1d006106..5c8bda2e854 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -236,7 +236,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices return $ref; } elseif ($mode == 'next') { $date = $object->date; // This is invoice date (not creation date) - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 383b1ff3cb4d3a7fa3d822d435cb069ada86d0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:23:32 +0100 Subject: [PATCH 276/315] Update mod_commande_fournisseur_muguet.php --- .../modules/supplier_order/mod_commande_fournisseur_muguet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 2f6604e6d10..3f03b6c1b16 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -160,7 +160,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders if (empty($date)) { $date = $object->date; // Creation date is order date for suppliers orders } - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 064aca2825f582735f0294fe676650bc46a1652a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:23:59 +0100 Subject: [PATCH 277/315] Update mod_supplier_payment_bronan.php --- .../modules/supplier_payment/mod_supplier_payment_bronan.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index d436d96fde0..d853273a05e 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -149,7 +149,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments //$date=time(); $date = $object->datepaye; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From cd711535f4418b82d14a763726018f7dfac77ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:24:22 +0100 Subject: [PATCH 278/315] Update mod_supplier_proposal_marbre.php --- .../modules/supplier_proposal/mod_supplier_proposal_marbre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index f9b91800153..9d87e91fcfd 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -151,7 +151,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal } $date = time(); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 3ac7c8646f906fb2376679e804a8a083fa842f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:24:52 +0100 Subject: [PATCH 279/315] Update mod_takepos_ref_simple.php --- htdocs/core/modules/takepos/mod_takepos_ref_simple.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index 85398f67c31..ed0727a5ebf 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -188,7 +188,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos return $ref; } elseif ($mode == 'next') { $date = $invoice->date; // This is invoice date (not creation date) - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 0b841b9d111603e54ae91e4556571afbc394b42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:25:19 +0100 Subject: [PATCH 280/315] Update mod_knowledgerecord_standard.php --- .../knowledgemanagement/mod_knowledgerecord_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php index a94ab504be1..20ba2817501 100644 --- a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php +++ b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php @@ -149,7 +149,7 @@ class mod_knowledgerecord_standard extends ModeleNumRefKnowledgeRecord //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From d5c7d8dcdf8e60122b1fe31a95d485cb09f78e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:26:04 +0100 Subject: [PATCH 281/315] Update mod_myobject_standard.php --- .../template/core/modules/mymodule/mod_myobject_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index b8362e973f0..4260d258ccb 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -149,7 +149,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 64cba23a3799254550d3b5f511b7c60f69882647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:26:40 +0100 Subject: [PATCH 282/315] Update mod_partnership_standard.php --- .../core/modules/partnership/mod_partnership_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index 895f28ab753..f5caef8307b 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -149,7 +149,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From c2262f76f1dae3b0b9fec692f2ed8ab8a0be18de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:27:15 +0100 Subject: [PATCH 283/315] Update mod_recruitmentcandidature_standard.php --- .../modules/recruitment/mod_recruitmentcandidature_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php index 359ec4a486b..24e3120c20f 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php @@ -149,7 +149,7 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 3d825833538b4322d7e6b7772b80da52fd0266f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 30 Dec 2023 08:27:32 +0100 Subject: [PATCH 284/315] Update mod_recruitmentjobposition_standard.php --- .../modules/recruitment/mod_recruitmentjobposition_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php index c1067d5e0d4..ba63ad8395c 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php @@ -149,7 +149,7 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is From 14cc6c0332703bc510960cdd7391a44261ca27c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Dec 2023 13:09:41 +0100 Subject: [PATCH 285/315] Fix phpunit --- test/phpunit/CMailFileTest.php | 44 +++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 96d6e195b41..7413c28ae8c 100644 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -208,14 +208,20 @@ class CMailFileTest extends PHPUnit\Framework\TestCase return $result; } + /** + * testCMailFileHTMLWithImage + * + * @return int + */ public function testCMailFileHTMLWithImage() { - global $conf, $user, $langs, $db; + $conf = $this->savconf; $user = $this->savuser; $langs = $this->savlangs; $db = $this->savdb; + $conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS = 1; $conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1; @@ -237,29 +243,29 @@ class CMailFileTest extends PHPUnit\Framework\TestCase foreach ($localobject->html_images as $i => $val) - if ($localobject->html_images[$i]) { - if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) { - print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); + if ($localobject->html_images[$i]) { + if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) { + print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); - print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl'); + print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl'); - $fileSize = 9744; - print __METHOD__ . " File size must be =" . $fileSize . "\n"; - $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); - } elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) { - print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); + $fileSize = 9744; + print __METHOD__ . " File size must be =" . $fileSize . "\n"; + $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); + } elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) { + print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); - print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n"; - $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata'); + print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n"; + $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata'); - $fileSize = 85; - print __METHOD__ . " File size must be =" . $fileSize . "\n"; - $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); - } + $fileSize = 85; + print __METHOD__ . " File size must be =" . $fileSize . "\n"; + $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); } + } return $result; } From 8da8db215a83385b757b2790b88f636e40ad87f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Dec 2023 15:25:15 +0100 Subject: [PATCH 286/315] Fix phpunit --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 290ff4691c9..5a68987162c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5058,7 +5058,7 @@ div.ui-tooltip.mytooltip { color: var(--tooltipfontcolor); line-height: 1.6em; min-width: 550px; - pointer-events: none; + pointer-events: none; } Date: Sat, 30 Dec 2023 15:48:13 +0100 Subject: [PATCH 287/315] Fix phpcs --- htdocs/mrp/mo_list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 01262f21100..6eb71b7cd76 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -570,7 +570,6 @@ foreach ($object->fields as $key => $val) { if (!empty($arrayfields['t.'.$key]['checked'])) { if ($key == "fk_product") { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'p.ref', '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - } else { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } From 5d159e82314bf9312a947d6d1c8328a2228dffa2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Dec 2023 19:39:48 +0100 Subject: [PATCH 288/315] Fix js error --- htdocs/projet/activity/perday.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 16728c2e1ca..dbd73f8167b 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -803,7 +803,7 @@ if (!empty($conf->use_javascript_ajax)) { print "\n\n"; print ''; } diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 93321333222..d3bd7d0e316 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -567,7 +567,7 @@ if (count($tasksarray) > 0) { $timeonothertasks = ($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); if ($timeonothertasks) { - print ''; } @@ -619,7 +619,7 @@ if ($conf->use_javascript_ajax) { });'."\n"; foreach ($TWeek as $week_number) { - print ' updateTotal('.$week_number.',\''.$modeinput.'\');'; + print " updateTotal(".((int) $week_number).", '".dol_escape_js($modeinput)."');"; } print "\n});\n"; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 064d7538068..37ff7f3014b 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -725,7 +725,7 @@ if ($conf->use_javascript_ajax) { } elseif (!$isavailable[$tmpday]['afternoon']) { $cssonholiday .= 'onholidayafternoon '; } - print ''; + print ''; } print ''; print ''; @@ -805,7 +805,7 @@ if (count($tasksarray) > 0) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { - print ''; } @@ -877,7 +877,7 @@ if ($conf->use_javascript_ajax) { $idw = 0; while ($idw < 7) { - print ' updateTotal('.$idw.',\''.$modeinput.'\');'; + print " updateTotal(".((int) $idw).", '".dol_escape_js($modeinput)."');"; $idw++; } print "\n});\n"; From aa43e18d56f40847e0a476b527a525c9549c940b Mon Sep 17 00:00:00 2001 From: Fabian Heinz Date: Sun, 31 Dec 2023 14:05:21 +0100 Subject: [PATCH 290/315] API status code fix apis currently returning 404 if no entry found fixed --- htdocs/adherents/class/api_members.class.php | 3 --- htdocs/expedition/class/api_shipments.class.php | 4 +--- htdocs/fourn/class/api_supplier_invoices.class.php | 4 +--- htdocs/fourn/class/api_supplier_orders.class.php | 4 +--- .../class/api_knowledgemanagement.class.php | 4 +--- htdocs/multicurrency/class/api_multicurrencies.class.php | 3 --- htdocs/projet/class/api_projects.class.php | 4 +--- htdocs/projet/class/api_tasks.class.php | 4 +--- htdocs/reception/class/api_receptions.class.php | 4 +--- .../supplier_proposal/class/api_supplier_proposals.class.php | 4 +--- htdocs/zapier/class/api_zapier.class.php | 4 +--- 11 files changed, 9 insertions(+), 33 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 4de525281b1..44024b951b3 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -271,9 +271,6 @@ class Members extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No member found'); - } return $obj_ret; } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 51527c5f6e3..5076132bf4e 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -179,9 +179,7 @@ class Shipments extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No shipment found'); - } + return $obj_ret; } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 87127b34010..701a9a80462 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -193,9 +193,7 @@ class SupplierInvoices extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve supplier invoice list : ' . $this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No supplier invoice found'); - } + return $obj_ret; } diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 2e5568c0cbe..66fb7248bcd 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -215,9 +215,7 @@ class SupplierOrders extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve supplier order list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No supplier order found'); - } + return $obj_ret; } diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 03d83c00365..c87c1da87a0 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -231,9 +231,7 @@ class KnowledgeManagement extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving knowledgerecord list: '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No knowledgerecord found'); - } + return $obj_ret; } diff --git a/htdocs/multicurrency/class/api_multicurrencies.class.php b/htdocs/multicurrency/class/api_multicurrencies.class.php index dbca10b1d24..5e02c43a319 100644 --- a/htdocs/multicurrency/class/api_multicurrencies.class.php +++ b/htdocs/multicurrency/class/api_multicurrencies.class.php @@ -102,9 +102,6 @@ class MultiCurrencies extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve currencies list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No currencies found'); - } return $obj_ret; } diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index fa3233a7286..638c500a2ea 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -190,9 +190,7 @@ class Projects extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve project list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No project found'); - } + return $obj_ret; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index a0b44d398af..bd53ae007eb 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -185,9 +185,7 @@ class Tasks extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve task list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No task found'); - } + return $obj_ret; } diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 61da0df1de0..95a0318202a 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -178,9 +178,7 @@ class Receptions extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No reception found'); - } + return $obj_ret; } diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 77279d98128..7bc8f9a8a3f 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -171,9 +171,7 @@ class SupplierProposals extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving supplier proposal list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No supplier proposal found'); - } + return $obj_ret; } diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index f0f458f7868..b84534412cf 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -230,9 +230,7 @@ class Zapier extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve hook list'); } - if (!count($obj_ret)) { - throw new RestException(404, 'No hook found'); - } + return $obj_ret; } From b78632a20e31c57606c1db0996baf3659bc2c00a Mon Sep 17 00:00:00 2001 From: Fabian Heinz Date: Sun, 31 Dec 2023 14:11:05 +0100 Subject: [PATCH 291/315] api fixes According to [RFC2616](https://www.rfc-editor.org/rfc/rfc2616#section-10.2), APIs should return 2xx status codes if the request was correct. The response should be status 200 with an empty result array. --- htdocs/adherents/class/api_members.class.php | 4 ---- .../class/api_memberstypes.class.php | 3 --- .../class/api_subscriptions.class.php | 3 --- htdocs/api/class/api_setup.class.php | 4 ---- htdocs/bom/class/api_boms.class.php | 4 +--- .../categories/class/api_categories.class.php | 7 +------ .../action/class/api_agendaevents.class.php | 4 +--- .../comm/propal/class/api_proposals.class.php | 4 +--- htdocs/commande/class/api_orders.class.php | 4 +--- .../facture/class/api_invoices.class.php | 4 +--- htdocs/contrat/class/api_contracts.class.php | 4 +--- htdocs/don/class/api_donations.class.php | 3 --- .../class/api_expensereports.class.php | 4 +--- .../class/api_interventions.class.php | 4 +--- .../class/api_knowledgemanagement.class.php | 4 ---- .../template/class/api_mymodule.class.php | 4 +--- htdocs/mrp/class/api_mos.class.php | 4 +--- .../class/api_partnerships.class.php | 4 +--- htdocs/product/class/api_products.class.php | 19 +------------------ .../stock/class/api_stockmovements.class.php | 4 +--- .../stock/class/api_warehouses.class.php | 4 +--- .../class/api_recruitments.class.php | 8 ++------ htdocs/societe/class/api_contacts.class.php | 4 ---- htdocs/ticket/class/api_tickets.class.php | 4 +--- htdocs/user/class/api_users.class.php | 8 ++------ 25 files changed, 20 insertions(+), 103 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 44024b951b3..435f6a7e24e 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -540,10 +540,6 @@ class Members extends DolibarrApi $result = $categories->getListForItem($id, 'member', $sortfield, $sortorder, $limit, $page); - if (empty($result)) { - throw new RestException(404, 'No category found'); - } - if ($result < 0) { throw new RestException(503, 'Error when retrieve category list : '.$categories->error); } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 5f1a1aec7b6..302270d5c5f 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -136,9 +136,6 @@ class MembersTypes extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No member type found'); - } return $obj_ret; } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 9c051ac6a41..77c7a8b933a 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -133,9 +133,6 @@ class Subscriptions extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No Subscription found'); - } return $obj_ret; } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 5ec9c9a34aa..0135fb5c413 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1156,10 +1156,6 @@ class Setup extends DolibarrApi throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); } - if (!count($list)) { - throw new RestException(404, 'No extrafield found'); - } - return $list; } diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 658543e68c3..89633e0ac6e 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -182,9 +182,7 @@ class Boms extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve bom list'); } - if (!count($obj_ret)) { - throw new RestException(404, 'No bom found'); - } + return $obj_ret; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5d2a9d0862a..b1d0ff392d6 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -182,9 +182,7 @@ class Categories extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No category found'); - } + return $obj_ret; } @@ -342,9 +340,6 @@ class Categories extends DolibarrApi $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); if (!is_array($categories)) { - if ($categories == 0) { - throw new RestException(404, 'No category found for this object'); - } throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); } return $categories; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 50fb1882aaf..d1c013bc59c 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -192,9 +192,7 @@ class AgendaEvents extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No Agenda Event found'); - } + return $obj_ret; } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 05cb33a17df..be45153fb10 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -245,9 +245,7 @@ class Proposals extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve propal list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No proposal found'); - } + return $obj_ret; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index c5119a51f6e..31daad85e9b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -259,9 +259,7 @@ class Orders extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No order found'); - } + return $obj_ret; } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 94de562a3c2..35e81b82f82 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -281,9 +281,7 @@ class Invoices extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve invoice list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No invoice found'); - } + return $obj_ret; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 523eb59ea03..51c3d63d412 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -181,9 +181,7 @@ class Contracts extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve contrat list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No contract found'); - } + return $obj_ret; } diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index ad4be19f012..e734be8efff 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -165,9 +165,6 @@ class Donations extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve donation list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No donation found'); - } return $obj_ret; } diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index e7e7dc462aa..7372f9f98f8 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -151,9 +151,7 @@ class ExpenseReports extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve Expense Report list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No Expense Report found'); - } + return $obj_ret; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index e9717982c73..114a8613c43 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -190,9 +190,7 @@ class Interventions extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve intervention list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No intervention found'); - } + return $obj_ret; } diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index c87c1da87a0..8e4a2cac6e1 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -109,10 +109,6 @@ class KnowledgeManagement extends DolibarrApi $result = $categories->getListForItem($id, 'knowledgemanagement', $sortfield, $sortorder, $limit, $page); - if (empty($result)) { - throw new RestException(404, 'No category found'); - } - if ($result < 0) { throw new RestException(503, 'Error when retrieve category list : '.join(',', array_merge(array($categories->error), $categories->errors))); } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 449312deeab..62ad513d307 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -190,9 +190,7 @@ class MyModuleApi extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving myobject list: '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No myobject found'); - } + return $obj_ret; } diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index c3900271e42..ff49948d284 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -180,9 +180,7 @@ class Mos extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve MO list'); } - if (!count($obj_ret)) { - throw new RestException(404, 'No MO found'); - } + return $obj_ret; } diff --git a/htdocs/partnership/class/api_partnerships.class.php b/htdocs/partnership/class/api_partnerships.class.php index c66076c2866..e3ca8f23e2e 100644 --- a/htdocs/partnership/class/api_partnerships.class.php +++ b/htdocs/partnership/class/api_partnerships.class.php @@ -187,9 +187,7 @@ class Partnerships extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving partnership list: '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No partnership found'); - } + return $obj_ret; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index afa78b10622..4023309ef35 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -277,9 +277,6 @@ class Products extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve product list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No product found'); - } //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) if ($pagination_data) { @@ -601,10 +598,6 @@ class Products extends DolibarrApi $result = $categories->getListForItem($id, 'product', $sortfield, $sortorder, $limit, $page); - if (empty($result)) { - throw new RestException(404, 'No category found'); - } - if ($result < 0) { throw new RestException(503, 'Error when retrieve category list : '.join(',', array_merge(array($categories->error), $categories->errors))); } @@ -953,9 +946,7 @@ class Products extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve product list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No product found'); - } + return $obj_ret; } @@ -1080,10 +1071,6 @@ class Products extends DolibarrApi $return[] = $this->_filterObjectProperties($this->_cleanObjectDatas($tmp), $properties); } - if (!count($return)) { - throw new RestException(404, 'No product attribute found'); - } - return $return; } @@ -1949,10 +1936,6 @@ class Products extends DolibarrApi } } - if (empty($stockData)) { - throw new RestException(404, 'No stock found'); - } - return array('stock_warehouses'=>$stockData); } diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 369d24b9536..1f47339c3c4 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -144,9 +144,7 @@ class StockMovements extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve stock movement list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No stock movement found'); - } + return $obj_ret; } diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index 8056e59ac67..6fa256454b9 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -150,9 +150,7 @@ class Warehouses extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve warehouse list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No warehouse found'); - } + return $obj_ret; } diff --git a/htdocs/recruitment/class/api_recruitments.class.php b/htdocs/recruitment/class/api_recruitments.class.php index 526d25c4aa8..a5cc43d6854 100644 --- a/htdocs/recruitment/class/api_recruitments.class.php +++ b/htdocs/recruitment/class/api_recruitments.class.php @@ -226,9 +226,7 @@ class Recruitments extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No jobposition found'); - } + return $obj_ret; } @@ -333,9 +331,7 @@ class Recruitments extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No candidature found'); - } + return $obj_ret; } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index a91455aabe7..4ea6f184fe7 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -465,10 +465,6 @@ class Contacts extends DolibarrApi $result = $categories->getListForItem($id, 'contact', $sortfield, $sortorder, $limit, $page); - if (empty($result)) { - throw new RestException(404, 'No category found'); - } - if ($result < 0) { throw new RestException(503, 'Error when retrieve category list : '.$categories->error); } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 18e8b74aee9..b8e37707138 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -285,9 +285,7 @@ class Tickets extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve ticket list'); } - if (!count($obj_ret)) { - throw new RestException(404, 'No ticket found'); - } + return $obj_ret; } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index b75cc5339bf..e1424796c63 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -134,9 +134,7 @@ class Users extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve User list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No User found'); - } + return $obj_ret; } @@ -590,9 +588,7 @@ class Users extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve Group list : '.$this->db->lasterror()); } - if (!count($obj_ret)) { - throw new RestException(404, 'No Group found'); - } + return $obj_ret; } From e1fccda141c6112e32af42942e19a49c5c759cc7 Mon Sep 17 00:00:00 2001 From: Fabian Heinz Date: Sun, 31 Dec 2023 15:25:18 +0100 Subject: [PATCH 292/315] Removed white spaces after lines --- .../knowledgemanagement/class/api_knowledgemanagement.class.php | 2 +- htdocs/zapier/class/api_zapier.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 8e4a2cac6e1..32791ffcc7a 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -227,7 +227,7 @@ class KnowledgeManagement extends DolibarrApi } else { throw new RestException(503, 'Error when retrieving knowledgerecord list: '.$this->db->lasterror()); } - + return $obj_ret; } diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index b84534412cf..89a7b808e6d 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -230,7 +230,7 @@ class Zapier extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve hook list'); } - + return $obj_ret; } From b221ff35b2b11de7cb7edb663ad537a375c5eef9 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 31 Dec 2023 17:16:53 +0100 Subject: [PATCH 293/315] FIX #27262 Recurrent invoice - user to string conversion --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index bad8edf3a66..a44bb305455 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -1323,7 +1323,7 @@ class FactureFournisseurRec extends CommonInvoice } if (!$error && ($facturerec->auto_validate || $forcevalidation)) { $result = $new_fac_fourn->validate($user); - $laststep="Validate by user $user"; + $laststep="Validate by user {$user->login}"; if ($result <= 0) { $this->errors = $new_fac_fourn->errors; $this->error = $new_fac_fourn->error; From 08ed421a03562903c4a8ff74a6b7c2b3e7b8e117 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Jan 2024 20:02:26 +0100 Subject: [PATCH 294/315] css --- htdocs/opensurvey/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index dddbb7fc49b..ed95a60d577 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -538,7 +538,7 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } From 77306d7155fc75521f5e84c3be46d480a2108e03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Jan 2024 20:14:11 +0100 Subject: [PATCH 295/315] Fix sql --- htdocs/install/mysql/tables/llx_mailing-mailing.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_mailing-mailing.sql b/htdocs/install/mysql/tables/llx_mailing-mailing.sql index 2632d1505c7..809054cc879 100644 --- a/htdocs/install/mysql/tables/llx_mailing-mailing.sql +++ b/htdocs/install/mysql/tables/llx_mailing-mailing.sql @@ -55,6 +55,6 @@ create table llx_mailing joined_file2 varchar(255), joined_file3 varchar(255), joined_file4 varchar(255), - note_private text, -- - note_public text, -- + note_private text, + note_public text )ENGINE=innodb; From 6f4f38e168370b55477a997115cb22cc22b2ff3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Jan 2024 20:53:08 +0100 Subject: [PATCH 296/315] Fix sql error --- htdocs/opensurvey/class/opensurveysondage.class.php | 1 - htdocs/opensurvey/results.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 66cbacc4717..4fd68649ef6 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -338,7 +338,6 @@ class Opensurveysondage extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $conf, $langs; $error = 0; // Clean parameters diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 0ebab6abc0b..da364497a80 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -89,8 +89,8 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // bo setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors'); $error++; } else { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; - $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, date_creation)'; + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."', '".$db->escape($nouveauchoix)."', '".$db->idate(dol_now())."')"; $resql = $db->query($sql); if (!$resql) { dol_print_error($db); From bb44bb32f84dba323009faa9212a6524c0613cf8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 00:47:56 +0100 Subject: [PATCH 297/315] Fix message --- htdocs/opensurvey/results.php | 4 ++-- htdocs/public/opensurvey/studs.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index da364497a80..3e48b2b07c6 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -1157,9 +1157,9 @@ if ($nbofcheckbox >= 2) { print '

    '."\n"; if (isset($meilleurecolonne) && $compteursujet == "1") { - print " ".$langs->trans('TheBestChoice').": ".$meilleursujet." ".$langs->trans("with")." ".$meilleurecolonne." ".$vote_str.".\n"; + print ' '.$langs->trans('TheBestChoice').": ".$meilleursujet." - ".$meilleurecolonne." ".$vote_str.".\n"; } elseif (isset($meilleurecolonne)) { - print " ".$langs->trans('TheBestChoices').": ".$meilleursujet." ".$langs->trans("with")." ".$meilleurecolonne." ".$vote_str.".\n"; + print ' '.$langs->trans('TheBestChoices').": ".$meilleursujet." - ".$meilleurecolonne." ".$vote_str.".\n"; } print '


    '."\n"; } diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index c6171867557..c05a1653d2d 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -813,9 +813,9 @@ if ($object->allow_spy) { print '

    '."\n"; if (isset($meilleurecolonne) && $compteursujet == "1") { - print ' '.$langs->trans('TheBestChoice').": ".$meilleursujet." ".$langs->trans('with')." ".$meilleurecolonne."".$vote_str.".\n"; + print ' '.$langs->trans('TheBestChoice').": ".$meilleursujet." - ".$meilleurecolonne." ".$vote_str.".\n"; } elseif (isset($meilleurecolonne)) { - print ' '.$langs->trans('TheBestChoices').": ".$meilleursujet." ".$langs->trans('with')." ".$meilleurecolonne."".$vote_str.".\n"; + print ' '.$langs->trans('TheBestChoices').": ".$meilleursujet." - ".$meilleurecolonne." ".$vote_str.".\n"; } print '


    '."\n"; From 938cb8eee5a326784ec9b2631ca48516fa9edaf4 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 2 Jan 2024 09:53:49 +0100 Subject: [PATCH 298/315] add constant VATUPDATE_NO_TRANSACTION --- htdocs/product/admin/product_tools.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 3faa9d44643..47c089bdc29 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -65,7 +65,9 @@ if ($action == 'convert') { $nbrecordsmodified = 0; - $db->begin(); + if (!getDolGlobalInt('VATUPDATE_NO_TRANSACTION') { + $db->begin(); + } // Clean vat code old $vat_src_code_old = ''; @@ -259,10 +261,12 @@ if ($action == 'convert') { dol_print_error($db); } - if (!$error) { - $db->commit(); - } else { - $db->rollback(); + if (!getDolGlobalInt('VATUPDATE_NO_TRANSACTION') { + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } } // Output result From 5610ba0d53de48c6a0703dfab05d08678a552e6a Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 2 Jan 2024 09:55:38 +0100 Subject: [PATCH 299/315] fix typo --- htdocs/product/admin/product_tools.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 47c089bdc29..44d28eeb95b 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -65,7 +65,7 @@ if ($action == 'convert') { $nbrecordsmodified = 0; - if (!getDolGlobalInt('VATUPDATE_NO_TRANSACTION') { + if (!getDolGlobalInt('VATUPDATE_NO_TRANSACTION')) { $db->begin(); } @@ -261,7 +261,7 @@ if ($action == 'convert') { dol_print_error($db); } - if (!getDolGlobalInt('VATUPDATE_NO_TRANSACTION') { + if (!getDolGlobalInt('VATUPDATE_NO_TRANSACTION')) { if (!$error) { $db->commit(); } else { From 041de86b680fa214298e887fbd5e8bff8cc11ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Jan 2024 12:21:44 +0100 Subject: [PATCH 300/315] undefined variable $user --- 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 04029a8ccd3..10bc226f415 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8017,7 +8017,7 @@ class Form */ public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '', $objectfield = '') { - global $conf, $extrafields; + global $conf, $extrafields, $user; $objectdescorig = $objectdesc; $objecttmp = null; From 5ae29f405299fde7c3016e86b35cb6dc80bf119f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 12:58:40 +0100 Subject: [PATCH 301/315] Fix check php native imap only if php <= 8.3 --- htdocs/install/check.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index a5f571fec0b..d434a5bdad2 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -200,12 +200,14 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc } // Check if Imap is supported -if (!function_exists("imap_open")) { - $langs->load("errors"); - print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "IMAP")."
    \n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) -} else { - print 'Ok '.$langs->trans("PHPSupport", "IMAP")."
    \n"; +if (PHP_VERSION_ID <= 80300) { + if (!function_exists("imap_open")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "IMAP")."
    \n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + } else { + print 'Ok '.$langs->trans("PHPSupport", "IMAP")."
    \n"; + } } // Check if Zip is supported From 54d81a4e746584d313880530027a268603136dac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 13:16:41 +0100 Subject: [PATCH 302/315] Fix value for date of survey was truncated --- htdocs/opensurvey/results.php | 2 +- htdocs/public/opensurvey/studs.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 3e48b2b07c6..c3a6bc4d4ec 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -1148,7 +1148,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { $compteursujet++; } } -$meilleursujet = substr($meilleursujet, 1); +//$meilleursujet = substr($meilleursujet, 1); $meilleursujet = str_replace("°", "'", $meilleursujet); // Show best choice diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index c05a1653d2d..a0b5b39732e 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -804,7 +804,7 @@ if ($object->allow_spy) { } } - $meilleursujet = substr("$meilleursujet", 1); + //$meilleursujet = substr($meilleursujet, 1); $meilleursujet = str_replace("°", "'", $meilleursujet); // Show best choice From 9357278bac5a8f668d65da8e44dee0f2486793a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 13:17:38 +0100 Subject: [PATCH 303/315] Fix var not used --- htdocs/opensurvey/results.php | 1 - htdocs/public/opensurvey/studs.php | 1 - 2 files changed, 2 deletions(-) diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index c3a6bc4d4ec..2656500fbc3 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -1132,7 +1132,6 @@ for ($i = 0; $i < $nbcolonnes; $i++) { $meilleursujet .= ($meilleursujet ? ", " : ""); if ($object->format == "D") { - $meilleursujetexport = $toutsujet[$i]; //var_dump($toutsujet); if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index a0b5b39732e..73245eb75e4 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -788,7 +788,6 @@ if ($object->allow_spy) { if (isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { $meilleursujet .= ($meilleursujet ? ", " : ""); if ($object->format == "D") { - $meilleursujetexport = $toutsujet[$i]; if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').' ('.dol_print_date($toutsujetdate[0], '%A').') - '.$toutsujetdate[1]; From 1eb5cd137c58a0ddd957d1a80ea81571ca841515 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 13:36:37 +0100 Subject: [PATCH 304/315] Clean code --- htdocs/core/tpl/contacts.tpl.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index d55be8afe21..e1dff2a711d 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -204,8 +204,8 @@ foreach (array('internal', 'external') as $source) { $entry->thirdparty_name = ""; $entry->contact_html = ""; $entry->contact_name = ""; - $entry->status_id = $contact['statuscontact']; - $entry->status = ""; + $entry->status = 0; + $entry->status_html = ""; if ($contact['source'] == 'internal') { $entry->nature = $langs->trans("User"); @@ -236,9 +236,11 @@ foreach (array('internal', 'external') as $source) { } if ($contact['source'] == 'internal') { - $entry->status = $userstatic->LibStatut($contact['statuscontact'], 3); + $entry->status = $contact['statuscontact']; + $entry->status_html = $userstatic->LibStatut($contact['statuscontact'], 3); } elseif ($contact['source'] == 'external') { - $entry->status = $contactstatic->LibStatut($contact['statuscontact'], 3); + $entry->status = $contact['statuscontact']; + $entry->status_html = $contactstatic->LibStatut($contact['statuscontact'], 3); } $list[] = $entry; @@ -298,11 +300,11 @@ print ""; foreach ($list as $entry) { print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($permission) { $href = $_SERVER["PHP_SELF"]; From 47994f8cd913ac06940df5820eaca519d272cded Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 13:45:08 +0100 Subject: [PATCH 305/315] Clean code --- htdocs/core/tpl/contacts.tpl.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e1dff2a711d..31514673a21 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -200,6 +200,7 @@ foreach (array('internal', 'external') as $source) { $entry->type_id = $contact['fk_c_type_contact']; $entry->type = $contact['libelle']; $entry->nature = ""; + $entry->nature_html = ""; $entry->thirdparty_html = ""; $entry->thirdparty_name = ""; $entry->contact_html = ""; @@ -208,9 +209,11 @@ foreach (array('internal', 'external') as $source) { $entry->status_html = ""; if ($contact['source'] == 'internal') { - $entry->nature = $langs->trans("User"); + $entry->nature = 'user'; + $entry->nature_html = $langs->trans("User"); } elseif ($contact['source'] == 'external') { - $entry->nature = $langs->trans("ThirdPartyContact"); + $entry->nature = 'thirdparty'; + $entry->nature_html = $langs->trans("ThirdPartyContact"); } if ($contact['socid'] > 0) { @@ -302,7 +305,7 @@ foreach ($list as $entry) { print ''; print ''; - print ''; + print ''; print ''; print ''; From e2180cba42ad403a46c2a1b49fac97a789487bd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 13:57:41 +0100 Subject: [PATCH 306/315] Fix warning --- htdocs/main.inc.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6bf70b996fe..1dda738d1a7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1664,7 +1664,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) * @param int $disablenoindex Disable noindex tag for meta robots * @return void */ -function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0) +function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0) { global $db, $conf, $langs, $user, $mysoc, $hookmanager; @@ -2062,20 +2062,20 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr /** * Show an HTML header + a BODY + The top menu bar * - * @param string $head Lines in the HEAD - * @param string $title Title of web page - * @param string $target Target to use in menu links (Example: '' or '_top') - * @param int $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax) - * @param int $disablehead Do not output head section - * @param array $arrayofjs Array of js files to add in header - * @param array $arrayofcss Array of css files to add in header - * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) - * @param string $helppagename Name of wiki page for help ('' by default). - * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage - * For other external page: http://server/url + * @param string $head Lines in the HEAD + * @param string $title Title of web page + * @param string $target Target to use in menu links (Example: '' or '_top') + * @param int $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax) + * @param int $disablehead Do not output head section + * @param array $arrayofjs Array of js files to add in header + * @param array $arrayofcss Array of css files to add in header + * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @param string $helppagename Name of wiki page for help ('' by default). + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage + * For other external page: http://server/url * @return void */ -function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $helppagename = '') +function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $morequerystring = '', $helppagename = '') { global $user, $conf, $langs, $db, $form; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -3082,7 +3082,7 @@ function top_menu_search() * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return void */ -function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_array_after = '', $leftmenuwithoutmainarea = 0, $title = '', $acceptdelayedhtml = 0) +function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_array_after = array(), $leftmenuwithoutmainarea = 0, $title = '', $acceptdelayedhtml = 0) { global $user, $conf, $langs, $db, $form; global $hookmanager, $menumanager; From 7d6ef6b809b3f135170fdb9c675414445627b897 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 13:59:05 +0100 Subject: [PATCH 307/315] Fix warning --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1dda738d1a7..1fd788b490b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3450,8 +3450,8 @@ function getHelpParamFor($helppagename, $langs) * @param string $accesskey Accesskey * @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page * @param string $img Image to use - * @param string $showtitlebefore Show title before input text instead of into placeholder. This can be set when output is dedicated for text browsers. - * @param string $autofocus Set autofocus on field + * @param int $showtitlebefore Show title before input text instead of into placeholder. This can be set when output is dedicated for text browsers. + * @param int $autofocus Set autofocus on field * @return string */ function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey = '', $prefhtmlinputname = '', $img = '', $showtitlebefore = 0, $autofocus = 0) From 728c4b7f059c08866b9e8749ec0941b2bedf9730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Jan 2024 14:20:35 +0100 Subject: [PATCH 308/315] Update init_menu_auguria.sql --- htdocs/core/menus/init_menu_auguria.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index d9e6ad3f370..7bc635f225d 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -15,7 +15,7 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 1__+MAX_llx_menu__, '', '1', __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (!getDolGlobalString("SOCIETE_DISABLE_PROSPECTS") || !getDolGlobalString("SOCIETE_DISABLE_CUSTOMERS") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->hasRight("societe","lire") || $user->hasRight("societe","contact","lire")', '', 2, 20, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 3__+MAX_llx_menu__, 'product|service', 'isModEnabled("product") || isModEnabled("service")', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->hasRight("produit","lire") || $user->hasRight("service","lire")', '', 0, 30, __ENTITY__, ''); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 16__+MAX_llx_menu__, 'bom|mrp', 'isModEnabled("bom") || isModEnabled("mrp")', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->hasRight("bom","read") || $user->hasRight("mrp","read")', '', 0, 31, __ENTITY__, ''); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 16__+MAX_llx_menu__, 'bom|mrp', 'isModEnabled("bom") || isModEnabled("mrp")', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'TMenuMRP', -1, 'mrp', '$user->hasRight("bom","read") || $user->hasRight("mrp","read")', '', 0, 31, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 7__+MAX_llx_menu__, 'projet', 'isModEnabled("project")', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->hasRight("projet","lire")', '', 2, 32, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 5__+MAX_llx_menu__, 'propal|commande|fournisseur|supplier_order|supplier_invoice|contrat|ficheinter', 'isModEnabled("propal") || isModEnabled("commande") || isModEnabled("supplier_order") || isModEnabled("contrat") || isModEnabled("ficheinter")', __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->hasRight("societe","lire") || $user->hasRight("societe","contact","lire")', '', 2, 40, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 6__+MAX_llx_menu__, 'facture|don|tax|salaries|loan|banque', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("facture") || isModEnabled("don") || isModEnabled("tax") || isModEnabled("salaries") || isModEnabled("supplier_invoice") || isModEnabled("loan") || isModEnabled("banque")', __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->hasRight("facture","lire") || $user->hasRight("don","lire") || $user->hasRight("tax","charges","lire") || $user->hasRight("salaries","read") || $user->hasRight("loan","read") || $user->hasRight("banque","lire") || $user->hasRight("fournisseur","facture","lire") || $user->hasRight("supplier_invoice","read")', '', 2, 50, __ENTITY__, ''); From 0dffaa53dd7b14abc897df3fcbff22066182e6f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 14:45:49 +0100 Subject: [PATCH 309/315] Fix doc --- dev/dolibarr_changes.txt | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index be467e8eadf..3cca5c44724 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -188,17 +188,10 @@ Add file fpdf_tpl.php 1.2 Add file tcpdi.php -<<<<<<< HEAD Add file tcpdi_parser.php and replace: require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); with: require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php'); -======= -Add tcpdi_parser.php and replace: - require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); - with: - require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php'); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git * Fix syntax error by replacing @@ -218,21 +211,12 @@ with window.location.href=pRef * Replace -<<<<<<< HEAD vTmpDiv=this.newNode(vTmpCell, 'div', null, null, vTaskList[i].getResource()); with var vTmpNode=this.newNode(vTmpCell, 'div', null, ''); vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); vTmpNode.setAttribute('href',vTaskList[i].getLink()); -======= -vTmpDiv=this.newNode(vTmpCell, 'div', null, null, vTaskList[i].getResource()); -with -var vTmpNode=this.newNode(vTmpCell, 'div', null, ''); -vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); -vTmpNode.setAttribute('href',vTaskList[i].getLink()); - ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git * Replace '% Comp.' to have a smaller text column header 'comp':'% Comp.' with @@ -272,7 +256,6 @@ RESTLER: // @CHANGE LDR if (!is_string($haystack)) return false; -<<<<<<< HEAD * Replace $loaders = array_unique(static::$rogueLoaders); @@ -282,12 +265,6 @@ RESTLER: $loaders = array_unique(static::$rogueLoaders, SORT_REGULAR); -+With swagger 2 provided into /explorer: ----------------------------------------- - -Change content of file htdocs/includes/restler/framework/Luracast/Restler/explorer/index.html - -======= * Add a test into AutoLoader.php to complete function loadThisLoader and test if property exists before calling it. For this replace code if (false !== $file = $b::$loader[1]($className) && $this->exists($className, $b::$loader[1])) { @@ -304,7 +281,13 @@ Change content of file htdocs/includes/restler/framework/Luracast/Restler/explor return $file; } } ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git + + ++With swagger 2 provided into /explorer: +---------------------------------------- + +Change content of file htdocs/includes/restler/framework/Luracast/Restler/explorer/index.html + PARSEDOWN From 3fae1cc0992596df493217e4846eac904a6c7fc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2024 14:47:18 +0100 Subject: [PATCH 310/315] Fix doc --- dev/dolibarr_changes.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index cd64efe58e7..bd826f56938 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -110,15 +110,11 @@ with if (!@TCPDF_STATIC::file_exists($file)) { // DOL CHANGE If we keep this, the image is not visible on pages after the first one. //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); -<<<<<<< HEAD //return false; $tfile = str_replace(' ', '%20', $file); if (@TCPDF_STATIC::file_exists($tfile)) { $file = $tfile; } -======= - //return false; ->>>>>>> branch '15.0' of git@github.com:Dolibarr/dolibarr.git } * Replace in tcpdf.php From 1ba089f353171693d9aa695ea76269b4d9af1eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Jan 2024 21:02:25 +0100 Subject: [PATCH 311/315] fix phpdoc --- htdocs/core/lib/company.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index d899c86a22f..b02869edd9f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -517,17 +517,17 @@ function societe_admin_prepare_head() /** * Return country label, code or id from an id, code or label * - * @param int $searchkey Id or code of country to search - * @param string $withcode '0'=Return label, + * @param int|string $searchkey Id or code of country to search + * @param string $withcode '0'=Return label, * '1'=Return code + label, * '2'=Return code from id, * '3'=Return id from code, * 'all'=Return array('id'=>,'code'=>,'label'=>) - * @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features) - * @param Translate $outputlangs Langs object for output translation - * @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output - * @param int $searchlabel Label of country to search (warning: searching on label is not reliable) - * @return mixed Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined' + * @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features) + * @param Translate $outputlangs Langs object for output translation + * @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output + * @param int $searchlabel Label of country to search (warning: searching on label is not reliable) + * @return mixed Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined' */ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '') { From 6ff56f1bf706964033e7c190e6bce6c8e8fc6b82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jan 2024 00:37:08 +0100 Subject: [PATCH 312/315] Enhance rector --- dev/tools/rector/rector.php | 20 +++++++++++++++---- .../rector/src/Renaming/GlobalToFunction.php | 20 ++++++++++++++++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php index acdc4cade86..5b07d1da6cc 100644 --- a/dev/tools/rector/rector.php +++ b/dev/tools/rector/rector.php @@ -5,6 +5,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; +use Rector\Set\ValueObject\SetList; return static function (RectorConfig $rectorConfig): void { $rectorConfig->phpVersion(PhpVersion::PHP_71); @@ -55,8 +56,19 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); - // Add all predefined rules to migrate to up to php 71 - // $rectorConfig->sets([ - // LevelSetList::UP_TO_PHP_71 - // ]); + // Add all predefined rules to migrate to up to php 71. + // Warning this break tab spacing of arrays on several lines + /*$rectorConfig->sets([ + LevelSetList::UP_TO_PHP_70 + ]);*/ + // Add predefined rules for a given version only + //$rectorConfig->import(SetList::PHP_70); + //$rectorConfig->import(SetList::PHP_71); + //$rectorConfig->import(SetList::PHP_72); + //$rectorConfig->import(SetList::PHP_73); + //$rectorConfig->import(SetList::PHP_74); + //$rectorConfig->import(SetList::PHP_80); + //$rectorConfig->import(SetList::PHP_81); + //$rectorConfig->import(SetList::PHP_82); + //$rectorConfig->import(SetList::PHP_83); }; diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index 03760b6fe48..ea5b2718f8c 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -4,6 +4,7 @@ namespace Dolibarr\Rector\Renaming; use PhpParser\Node; use PhpParser\Node\Arg; +use PhpParser\Node\Expr\ArrayItem; use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\BinaryOp\BooleanAnd; use PhpParser\Node\Expr\BinaryOp\Concat; @@ -73,7 +74,7 @@ class GlobalToFunction extends AbstractRector */ public function getNodeTypes(): array { - return [FuncCall::class, MethodCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; + return [FuncCall::class, MethodCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayItem::class, ArrayDimFetch::class]; } /** @@ -85,6 +86,23 @@ class GlobalToFunction extends AbstractRector */ public function refactor(Node $node) { + if ($node instanceof Node\Expr\ArrayItem) { + if (!isset($node->key)) { + return; + } + if ($this->isGlobalVar($node->value)) { + $constName = $this->getConstName($node->value); + if (empty($constName)) { + return; + } + $node->value = new FuncCall( + new Name('getDolGlobalString'), + [new Arg($constName)] + ); + } + return $node; + } + if ($node instanceof Node\Expr\ArrayDimFetch) { if (!isset($node->dim)) { return; From e6fe8ec1a60aa0ed88ba37826a329812b6784127 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jan 2024 14:46:56 +0100 Subject: [PATCH 313/315] Prepare v20 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 48288cf2de4..e46e2f23fad 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '19.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '20.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { From f8375a526257f2bfe03393c33f8c8d8434359d48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jan 2024 16:02:08 +0100 Subject: [PATCH 314/315] Add 19.0.0 to 20.0.0 --- .../install/mysql/migration/19.0.0-20.0.0.sql | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 htdocs/install/mysql/migration/19.0.0-20.0.0.sql 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 new file mode 100644 index 00000000000..97a75020b68 --- /dev/null +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -0,0 +1,35 @@ +-- +-- This file is executed by calling /install/index.php page +-- when current version is higher than the name of this file. +-- Be carefull in the position of each SQL request. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex ON llx_table; +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex; +-- To make pk to be auto increment (mysql): +-- -- VMYSQL4.3 ALTER TABLE llx_table ADD PRIMARY KEY(rowid); +-- -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- To rebuild sequence for postgresql after insert, by forcing id autoincrement fields: +-- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); + + + From 6484f49fd87857d9fef7a4081d88cecb05855c41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jan 2024 16:16:44 +0100 Subject: [PATCH 315/315] Fix missing hook --- htdocs/commande/list.php | 22 +++++++++++++------ .../modulebuilder/template/myobject_list.php | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 36270401bb5..962fbf318b5 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -165,15 +165,15 @@ if (empty($user->socid)) { $checkedtypetiers = 0; $arrayfields = array( - 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), - 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5, 'searchall'=>1), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10, 'searchall'=>1), 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>20), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>25), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), - 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30, 'searchall'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31, 'searchall'=>1), 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0), - 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), - 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40), + 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35, 'searchall'=>1), + 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40, 'searchall'=>1), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), @@ -200,7 +200,7 @@ $arrayfields = array( 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), - 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>135), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>135, 'searchall'=>1), 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>140), 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled("expedition")), 'position'=>990), 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position'=>995), @@ -208,6 +208,14 @@ $arrayfields = array( 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) ); +$parameters = array('fieldstosearchall'=>$fieldstosearchall); +$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook > 0) { + $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']; +} elseif ($reshook == 0) { + $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']); +} + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index e0b191c195a..5ebb8808848 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -152,8 +152,8 @@ foreach ($object->fields as $key => $val) { } } +$fieldstosearchall = array(); // List of fields to search into when doing a "search in all" -// $fieldstosearchall = array(); // foreach ($object->fields as $key => $val) { // if (!empty($val['searchall'])) { // $fieldstosearchall['t.'.$key] = $val['label'];
    '.$langs->trans("Company").''; - print img_picto('', 'company', 'class="pictofixedwidth"'); + print img_picto('', 'company', 'class="pictofixedwidth paddingright"'); print '
    '.$langs->trans('UserTitle').''; - print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
    '.$langs->trans("Lastname").' *
    '.$langs->trans('UserTitle').''; + print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
    '.$langs->trans("Firstname").' *
    '.$langs->trans("Lastname").' *
    '.$langs->trans("Email").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? ' *' : '').''; //print img_picto('', 'email', 'class="pictofixedwidth"'); @@ -655,7 +658,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR // Country print '
    '.$langs->trans('Country').''; - print img_picto('', 'country', 'class="pictofixedwidth"'); + print img_picto('', 'country', 'class="pictofixedwidth paddingright"'); $country_id = GETPOST('country_id', 'int'); if (!$country_id && getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE')) { $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); @@ -678,6 +681,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) { print '
    '.$langs->trans('State').''; if ($country_code) { + print img_picto('', 'state', 'class="pictofixedwidth paddingright"'); print $formcompany->select_state(GETPOST("state_id"), $country_code); } print '
    '.$langs->trans("URLPhoto").'
    '.$langs->trans("URLPhoto").'
    '.$publiclabel.'
    '.$form->textwithpicto($langs->trans("MembershipPublic"), $publiclabel).'
    '; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'BOOKKEEPING') { if (isset($decaiss[$case]) && $decaiss[$case] != 0) { From c4d1aaa09e1985cce0f8b18d4cc669b4741b7187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:22:46 +0100 Subject: [PATCH 243/315] Update index.php --- htdocs/compta/stats/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 7b5b23f726f..835d8a999fe 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -377,7 +377,8 @@ $now_show_delta = 0; $minyear = substr($minyearmonth, 0, 4); $maxyear = substr($maxyearmonth, 0, 4); $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$nowyearmonth = strftime("%Y-%m", dol_now()); +$nowyearmonth = dol_print_date(dol_now(), "%Y%m"); +//$nowyearmonth = strftime("%Y-%m", dol_now()); $maxyearmonth = max($maxyearmonth, $nowyearmonth); $now = dol_now(); $casenow = dol_print_date($now, "%Y-%m"); From f4329d2eb1dd3a6ebc1a444088c9bf8a1ce2b50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:24:03 +0100 Subject: [PATCH 244/315] Update supplier_turnover.php --- htdocs/compta/stats/supplier_turnover.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index 245967dcd8b..3a78dc0c6a4 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -328,7 +328,8 @@ $now_show_delta = 0; $minyear = substr($minyearmonth, 0, 4); $maxyear = substr($maxyearmonth, 0, 4); $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$nowyearmonth = strftime("%Y-%m", dol_now()); +//$nowyearmonth = strftime("%Y-%m", dol_now()); +$nowyearmonth = dol_print_date(dol_now(), "%Y-%m"); $maxyearmonth = max($maxyearmonth, $nowyearmonth); $now = dol_now(); $casenow = dol_print_date($now, "%Y-%m"); From 9ec73724185c90fa7867363a985f3427735e4bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:48:43 +0100 Subject: [PATCH 245/315] Update index.php --- htdocs/compta/resultat/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index a2ff6a8eafa..adbaf56ad61 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -1045,7 +1045,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $annee_decalage = $annee + 1; } //$case = strftime("%Y-%m", dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage)); - $case = dol_print_date( dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage), "%Y-%m") ; + $case = dol_print_date( dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage), "%Y-%m"); print ''; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'BOOKKEEPING') { if (isset($decaiss[$case]) && $decaiss[$case] != 0) { From 0d7bbcb996a0f9050b8c80e98497b51f65be5973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Fri, 29 Dec 2023 11:50:51 +0100 Subject: [PATCH 246/315] Update index.php --- htdocs/compta/resultat/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index adbaf56ad61..5f70269512d 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -1045,7 +1045,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $annee_decalage = $annee + 1; } //$case = strftime("%Y-%m", dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage)); - $case = dol_print_date( dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage), "%Y-%m"); + $case = dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage), "%Y-%m"); print ''; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'BOOKKEEPING') { if (isset($decaiss[$case]) && $decaiss[$case] != 0) { From 0c75288c6583af1c21ed3c400ec3b3c4b84f6c09 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 29 Dec 2023 15:51:52 +0100 Subject: [PATCH 247/315] #27249 [TPL] add: JS element target for contact line in contact tpl --- htdocs/core/tpl/contacts.tpl.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 957da647102..d55be8afe21 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -197,12 +197,14 @@ foreach (array('internal', 'external') as $source) { foreach ($contactlist as $contact) { $entry = new stdClass(); $entry->id = $contact['rowid']; + $entry->type_id = $contact['fk_c_type_contact']; $entry->type = $contact['libelle']; $entry->nature = ""; $entry->thirdparty_html = ""; $entry->thirdparty_name = ""; $entry->contact_html = ""; $entry->contact_name = ""; + $entry->status_id = $contact['statuscontact']; $entry->status = ""; if ($contact['source'] == 'internal') { @@ -213,6 +215,7 @@ foreach (array('internal', 'external') as $source) { if ($contact['socid'] > 0) { $companystatic->fetch($contact['socid']); + $entry->thirdparty_id = $companystatic->id; $entry->thirdparty_html = $companystatic->getNomUrl(1); $entry->thirdparty_name = strtolower($companystatic->getFullName($langs)); } elseif ($contact['socid'] < 0) { @@ -222,10 +225,12 @@ foreach (array('internal', 'external') as $source) { if ($contact['source'] == 'internal') { $userstatic->fetch($contact['id']); + $entry->contact_id = $userstatic->id; $entry->contact_html = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); $entry->contact_name = strtolower($userstatic->getFullName($langs)); } elseif ($contact['source'] == 'external') { $contactstatic->fetch($contact['id']); + $entry->contact_id = $contactstatic->id; $entry->contact_html = $contactstatic->getNomUrl(1, '', 0, '', 0, 0); $entry->contact_name = strtolower($contactstatic->getFullName($langs)); } @@ -291,13 +296,13 @@ if ($permission) { print "
    '.$entry->thirdparty_html.''.$entry->contact_html.''.$entry->nature.''.$entry->type.''.$entry->status.''.$entry->thirdparty_html.''.$entry->contact_html.''.$entry->nature.''.$entry->type.''.$entry->status.'
     
     
     
    '.$langs->trans("NoRecordFound").'
    '.$langs->trans("NoRecordFound").'
    '.$entry->thirdparty_html.''.$entry->contact_html.''.$entry->nature.''.$entry->type.''.$entry->status.''.$entry->thirdparty_html.''.$entry->contact_html.''.dol_escape_htmltag($entry->nature).''.dol_escape_htmltag($entry->type).''.$entry->status_html.''.$entry->thirdparty_html.''.$entry->contact_html.''.dol_escape_htmltag($entry->nature).''.dol_escape_htmltag($entry->nature_html).''.dol_escape_htmltag($entry->type).''.$entry->status_html.'