Debug v20

This commit is contained in:
Laurent Destailleur 2024-05-06 10:00:18 +02:00
parent 335d56c479
commit 55d2f3d9fc
3 changed files with 20 additions and 20 deletions

View File

@ -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<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string}> 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.'_';

View File

@ -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<int,string>|array<int,array{id:int,fulllabel:string,color:string,picto:string}>|array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string}> 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();

View File

@ -1269,7 +1269,7 @@ if ($action == 'create' || $action == 'adduserldap') {
// Categories
if (isModEnabled('category') && $user->hasRight("categorie", "read")) {
print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td><td>';
$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 "</td></tr>";
}