diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 9694e175b00..f9350ca0bb9 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1212,7 +1212,7 @@ class Categorie extends CommonObject * - string (categories ids separated by comma) * - array (list of categories ids) * @param int<0,1> $include [=0] Removed or 1=Keep only - * @param string $forcelangcode Lang code to force ('fr_FR', 'en_US', ...) + * @param string $forcelangcode Lang code to force ('fr_FR', 'en_US', ...) or 'none' * @return int<-1,-1>|array Array of categories. this->cats and this->motherof are set, -1 on error */ public function get_full_arbo($type, $fromid = 0, $include = 0, $forcelangcode = '') @@ -1254,12 +1254,12 @@ class Categorie extends CommonObject // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.position, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && $current_lang !== 'none') { $sql .= ", t.label as label_trans, t.description as description_trans"; } $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; - if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang = '".$this->db->escape($current_lang)."'"; + if (getDolGlobalInt('MAIN_MULTILANGS') && $current_lang !== 'none') { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category = c.rowid AND t.lang = '".$this->db->escape($current_lang)."'"; } $sql .= " WHERE c.entity IN (".getEntity('category').")"; $sql .= " AND c.type = ".(int) $type; @@ -1293,9 +1293,10 @@ class Categorie extends CommonObject // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG); + foreach ($this->cats as $key => $val) { //print 'key='.$key.'
'."\n"; - $this->buildPathFromId($key, $nbcateg); // Process a branch from the root category key (this category has no parent) and adds kevek to $this->cats items + $this->buildPathFromId($key, $nbcateg); // Process a branch from the root category key (this category has no parent) and adds level to $this->cats items } // Include or exclude leaf (including $fromid) from tree @@ -1345,9 +1346,6 @@ class Categorie extends CommonObject return -1; } - // First build full array $motherof - //$this->load_motherof(); // Disabled because already done by caller of buildPathFromId - // $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel // Define fullpath and fulllabel