From 55d2f3d9fcb6869e47a643ff3ebfc0bd3c19d374 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 May 2024 10:00:18 +0200 Subject: [PATCH] Debug v20 --- htdocs/categories/class/categorie.class.php | 30 ++++++++++----------- htdocs/core/class/html.form.class.php | 8 +++--- htdocs/user/card.php | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ca6ce726289..b901874f5a6 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1132,15 +1132,15 @@ class Categorie extends CommonObject * fullpath = Full path built with the id's * * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...) - * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. - * $markafterid can be an : + * @param int|string|array $fromid Keep only or Exclude (depending on $include parameter) all categories (including the leaf $fromid) into the tree after this id $fromid. + * $fromid can be an : * - int (id of category) * - string (categories ids separated by comma) * - array (list of categories ids) * @param int $include [=0] Removed or 1=Keep only * @return int<-1,-1>|array Array of categories. this->cats and this->motherof are set, -1 on error */ - public function get_full_arbo($type, $markafterid = 0, $include = 0) + public function get_full_arbo($type, $fromid = 0, $include = 0) { // phpcs:enable global $langs; @@ -1153,16 +1153,16 @@ class Categorie extends CommonObject return -1; } - if (is_string($markafterid)) { - $markafterid = explode(',', $markafterid); - } elseif (is_numeric($markafterid)) { - if ($markafterid > 0) { - $markafterid = array($markafterid); + if (is_string($fromid)) { + $fromid = explode(',', $fromid); + } elseif (is_numeric($fromid)) { + if ($fromid > 0) { + $fromid = array($fromid); } else { - $markafterid = array(); + $fromid = array(); } - } elseif (!is_array($markafterid)) { - $markafterid = array(); + } elseif (!is_array($fromid)) { + $fromid = array(); } $this->cats = array(); @@ -1218,11 +1218,11 @@ class Categorie extends CommonObject $this->buildPathFromId($key, $nbcateg); // Process a branch from the root category key (this category has no parent) } - // Include or exclude leaf including $markafterid from tree - if (count($markafterid) > 0) { - $keyfiltercatid = '('.implode('|', $markafterid).')'; + // Include or exclude leaf (including $fromid) from tree + if (count($fromid) > 0) { + $keyfiltercatid = '('.implode('|', $fromid).')'; - //print "Look to discard category ".$markafterid."\n"; + //print "Look to discard category ".$fromid."\n"; $keyfilter1 = '^'.$keyfiltercatid.'$'; $keyfilter2 = '_'.$keyfiltercatid.'$'; $keyfilter3 = '^'.$keyfiltercatid.'_'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fac5784aa6d..c24dc3ae8a7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5119,8 +5119,8 @@ class Form * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element). Not used if $outputmode = 1. * @param string $htmlname HTML field name * @param int $maxlength Maximum length for labels - * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. - * $markafterid can be an : + * @param int|string|array $fromid Keep only or Exclude (depending on $include parameter) all categories (including the leaf $fromid) into the tree after this id $fromid. + * $fromid can be an : * - int (id of category) * - string (categories ids separated by comma) * - array (list of categories ids) @@ -5131,7 +5131,7 @@ class Form * @return string|array|array|array String list or Array of categories * @see select_categories() */ - public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '', $useempty = 1) + public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $fromid = 0, $outputmode = 0, $include = 0, $morecss = '', $useempty = 1) { // phpcs:enable global $conf, $langs; @@ -5168,7 +5168,7 @@ class Form } } else { $cat = new Categorie($this->db); - $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); + $cate_arbo = $cat->get_full_arbo($type, $fromid, $include); } $outarray = array(); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6a9de020112..350d34f210f 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1269,7 +1269,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Categories if (isModEnabled('category') && $user->hasRight("categorie", "read")) { print ''.$form->editfieldkey('Categories', 'usercats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); + $cate_arbo = $form->select_all_categories('user', '', 'parent', 0, 0, 3); print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), 0, 0, 'maxwdith300 widthcentpercentminusx', 0, '90%'); print ""; }