From 524aa9688003944c275f2650fd8496d7eb7738ae Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 19 Nov 2020 14:14:43 +0100 Subject: [PATCH 01/10] FIX to preserve order of multiprices fields --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d4ab94d9c2fde..9794e21858597 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -237,7 +237,7 @@ } else { $labelp = $langs->trans("SellingPrice")." ".$i; } - $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>40); + $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>'40.'.$i); $arraypricelevel[$i] = array($i); } } From 65e14617a04c27d32ac47547516e16d30a75d76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 20:50:58 +0100 Subject: [PATCH 02/10] doxygen --- htdocs/fichinter/class/fichinter.class.php | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d86c1b21abf61..f147677647efb 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -95,7 +95,10 @@ class Fichinter extends CommonObject */ protected $table_ref_field = 'ref'; - public $socid; // Id client + /** + * @var int Thirdparty Id + */ + public $socid; public $author; @@ -118,7 +121,14 @@ class Fichinter extends CommonObject */ public $datem; + /** + * @var int duration + */ public $duration; + + /** + * @var int status + */ public $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate /** @@ -127,17 +137,23 @@ class Fichinter extends CommonObject public $description; /** - * @var int ID + * @var int Contract ID */ public $fk_contrat = 0; /** - * @var int ID + * @var int Project ID */ public $fk_project = 0; + /** + * @var array extraparams + */ public $extraparams = array(); + /** + * @var array lines + */ public $lines = array(); /** @@ -328,8 +344,7 @@ public function create($user, $notrigger = 0) // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { From 3056197848d6749fb5fc806e48d7fd0ecaf81a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 20:57:26 +0100 Subject: [PATCH 03/10] remove warnings --- htdocs/fichinter/card.php | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index da1de06cc16ce..51cc56b408d65 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -8,6 +8,7 @@ * Copyright (C) 2014-2018 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir * Copyright (C) 2018 Philippe Grand + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,8 +58,8 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$socid = GETPOST('socid', 'int'); -$contratid = GETPOST('contratid', 'int'); +$socid = (int) GETPOST('socid', 'int'); +$contratid = (int) GETPOST('contratid', 'int'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); @@ -175,8 +176,7 @@ } else { $mesg = $object->error; } - } elseif ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer) { $result = $object->setDraft($user); if ($result >= 0) { @@ -187,8 +187,7 @@ $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) - { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -200,14 +199,13 @@ } else { $mesg = $object->error; } - } elseif ($action == 'add' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'add' && $user->rights->ficheinter->creer) { $object->socid = $socid; - $object->duration = GETPOST('duration', 'int'); - $object->fk_project = GETPOST('projectid', 'int'); - $object->fk_contrat = GETPOST('contratid', 'int'); + $object->duration = (int) GETPOST('duration', 'int'); + $object->fk_project = (int) GETPOST('projectid', 'int'); + $object->fk_contrat = (int) GETPOST('contratid', 'int'); $object->author = $user->id; - $object->description = GETPOST('description', 'restricthtml'); + $object->description = GETPOST('description', 'restricthtml'); $object->ref = $ref; $object->model_pdf = GETPOST('model', 'alpha'); $object->note_private = GETPOST('note_private', 'restricthtml'); @@ -409,13 +407,12 @@ $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")); $action = 'create'; } - } elseif ($action == 'update' && $user->rights->ficheinter->creer) - { + } elseif ($action == 'update' && $user->rights->ficheinter->creer) { $object->socid = $socid; - $object->fk_project = GETPOST('projectid', 'int'); - $object->fk_contrat = GETPOST('contratid', 'int'); + $object->fk_project = (int) GETPOST('projectid', 'int'); + $object->fk_contrat = (int) GETPOST('contratid', 'int'); $object->author = $user->id; - $object->description = GETPOST('description', 'restricthtml'); + $object->description = GETPOST('description', 'restricthtml'); $object->ref = $ref; $result = $object->update($user); @@ -520,8 +517,7 @@ elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) { $result = $object->setStatut(2); - if ($result > 0) - { + if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { From bf535c0dec208aa102de26e553837f3dea30cf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 21:12:16 +0100 Subject: [PATCH 04/10] remove warnings --- htdocs/product/price.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 9c9fa653a60a7..1dac893807f7b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI * * This program is free software; you can redistribute it and/or modify @@ -49,7 +49,9 @@ // Load translation files required by the page $langs->loadLangs(array('products', 'bills', 'companies', 'other')); -$mesg = ''; $error = 0; $errors = array(); +$mesg = ''; +$error = 0; +$errors = array(); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -474,8 +476,7 @@ } } - if ($action == 'delete_all_price_by_qty') - { + if ($action == 'delete_all_price_by_qty') { $priceid = GETPOST('priceid', 'int'); if (!empty($rowid)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; @@ -483,7 +484,7 @@ $result = $db->query($sql); } else { - setEventMessages(('delete_price_by_qty'.$langs->transnoentities(MissingIds)), null, 'errors'); + setEventMessages(('delete_price_by_qty'.$langs->transnoentities('MissingIds')), null, 'errors'); } } From 19a64a8350f24f34b69dee56763fa97f18a9dc0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 21:19:54 +0100 Subject: [PATCH 05/10] add filters --- htdocs/product/stock/card.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index d2f9494e857ba..258e90e875e47 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -93,18 +93,18 @@ // Ajout entrepot if ($action == 'add' && $user->rights->stock->creer) { - $object->ref = GETPOST("ref"); - $object->fk_parent = GETPOST("fk_parent"); - $object->label = GETPOST("libelle"); - $object->description = GETPOST("desc"); + $object->ref = (string) GETPOST("ref", "alpha"); + $object->fk_parent = (int) GETPOST("fk_parent", "int"); + $object->label = (string) GETPOST("libelle", "alpha"); + $object->description = (string) GETPOST("desc", "alpha"); $object->statut = GETPOST("statut"); - $object->lieu = GETPOST("lieu"); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); - $object->town = GETPOST("town"); + $object->lieu = (string) GETPOST("lieu", "alpha"); + $object->address = (string) GETPOST("address", "alpha"); + $object->zip = (string) GETPOST("zipcode", "alpha"); + $object->town = (string) GETPOST("town", "alpha"); $object->country_id = GETPOST("country_id"); - $object->phone = GETPOST("phone"); - $object->fax = GETPOST("fax"); + $object->phone = (string) GETPOST("phone", "alpha"); + $object->fax = (string) GETPOST("fax", "alpha"); if (!empty($object->label)) { // Fill array 'array_options' with data from add form From cac91211c94153c9b6b4182b0e1453a30d6d0378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 21:27:20 +0100 Subject: [PATCH 06/10] remove deprecated --- htdocs/contact/class/contact.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 1185ce5ecf8d5..59423ec2b42ca 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1513,7 +1513,6 @@ public function initAsSpecimen() $this->country_code = 'FR'; $this->country = 'France'; $this->email = 'specimen@specimen.com'; - $this->skype = 'tom.hanson'; $this->socialnetworks = array( 'skype' => 'tom.hanson', ); From 81eb4b2222d06c6287b1851fe45bfdf0af4dc138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 21:44:11 +0100 Subject: [PATCH 07/10] doxygen --- htdocs/fichinter/class/fichinterrec.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 23940c04e707c..377b97b2abbc6 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -53,6 +53,9 @@ class FichinterRec extends Fichinter */ public $picto = 'intervention'; + /** + * @var string title + */ public $title; public $number; public $date; @@ -60,14 +63,28 @@ class FichinterRec extends Fichinter public $remise; public $tva; public $total; - public $db_table; + + /** + * @var int Proposal Id + */ public $propalid; public $date_last_gen; public $date_when; + + /** + * @var int number of generation done + */ public $nb_gen_done; + + /** + * @var int number of maximum generation + */ public $nb_gen_max; + /** + * int rank + */ public $rang; public $special_code; From efa5c89c45d7b21073c33049baaad57115153064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 22:03:13 +0100 Subject: [PATCH 08/10] Update rssparser.class.php The variable $**** does not seem to be defined for all execution paths leading up to this point. --- htdocs/core/class/rssparser.class.php | 48 +++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index cc278713c63dd..578e180edffa7 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -308,11 +308,9 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') $items = array(); // Save description entries - if ($rss->_format == 'rss') - { + if ($rss->_format == 'rss') { //var_dump($rss); - if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) - { + if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { if (!empty($rss->channel->language)) $this->_language = (string) $rss->channel->language; if (!empty($rss->channel->generator)) $this->_generator = (string) $rss->channel->generator; if (!empty($rss->channel->copyright)) $this->_copyright = (string) $rss->channel->copyright; @@ -336,8 +334,7 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) $items = $rss->channel->item; // With simplexml else $items = $rss->items; // With xmlparse //var_dump($items);exit; - } elseif ($rss->_format == 'atom') - { + } elseif ($rss->_format == 'atom') { //var_dump($rss); if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { @@ -370,15 +367,11 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') $i = 0; // Loop on each record - if (is_array($items)) - { - foreach ($items as $item) - { + if (is_array($items)) { + foreach ($items as $item) { //var_dump($item);exit; - if ($rss->_format == 'rss') - { - if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) - { + if ($rss->_format == 'rss') { + if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { $itemLink = (string) $item->link; $itemTitle = (string) $item->title; $itemDescription = (string) $item->description; @@ -396,17 +389,13 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') // Loop on each category $itemCategory = array(); - if (is_array($item->category)) - { - foreach ($item->category as $cat) - { + if (is_array($item->category)) { + foreach ($item->category as $cat) { $itemCategory[] = (string) $cat; } } - } elseif ($rss->_format == 'atom') - { - if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) - { + } elseif ($rss->_format == 'atom') { + if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { $itemLink = (isset($item['link']) ? (string) $item['link'] : ''); $itemTitle = (string) $item['title']; $itemDescription = $this->getAtomItemDescription($item); @@ -421,7 +410,17 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') $itemId = (string) $item['id']; $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']); } - } else print 'ErrorBadFeedFormat'; + $itemCategory = array(); + } else { + $itemCategory = array(); + $itemLink = ''; + $itemTitle = ''; + $itemDescription = ''; + $itemPubDate = ''; + $itemId = ''; + $itemAuthor = ''; + print 'ErrorBadFeedFormat'; + } // Add record to result array $this->_rssarray[$i] = array( @@ -431,7 +430,8 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') 'pubDate'=>$itemPubDate, 'category'=>$itemCategory, 'id'=>$itemId, - 'author'=>$itemAuthor); + 'author'=>$itemAuthor + ); //var_dump($this->_rssarray); $i++; From 5d4d7c99d661cd3b83ab3d1ecf26ff15e5c85ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 Nov 2020 22:07:32 +0100 Subject: [PATCH 09/10] Update ldap.class.php The variable $result seems to be never defined. --- htdocs/core/class/ldap.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 9011d9b54f79f..1bd25e123a358 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -984,14 +984,12 @@ public function getRecords($search, $userDn, $useridentifier, $attributeArray, $ // Define filter if (!empty($activefilter)) { - if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) - { + if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) { $filter = '('.$this->filter.')'; - } elseif (((string) $activefilter == 'member') && $this->filter) - { + } elseif (((string) $activefilter == 'member') && $this->filter) { $filter = '('.$this->filtermember.')'; - } else // If this->filter is empty, make fiter on * (all) - { + } else { + // If this->filter is empty, make fiter on * (all) $filter = '('.$useridentifier.'=*)'; } } else { @@ -1070,6 +1068,7 @@ public function getRecords($search, $userDn, $useridentifier, $attributeArray, $ */ public function littleEndian($hex) { + $result = ''; for ($x = dol_strlen($hex) - 2; $x >= 0; $x = $x - 2) { $result .= substr($hex, $x, 2); } From 265d19f5639928e36c40cbc52cc7d280c50e278b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Nov 2020 08:07:44 +0100 Subject: [PATCH 10/10] FIX better method to preserve order --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 9794e21858597..b1dbb2609e12f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -237,7 +237,7 @@ } else { $labelp = $langs->trans("SellingPrice")." ".$i; } - $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>'40.'.$i); + $arrayfields['p.sellprice'.$i] = array('label'=>$labelp, 'checked'=>1, 'enabled'=>$conf->global->PRODUIT_MULTIPRICES, 'position'=>floatval('40.'.sprintf('%03s', $i))); $arraypricelevel[$i] = array($i); } }