From 106b4a669f203f2791ff1a607ca691d298e4b43d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Oct 2014 11:15:13 +0100 Subject: [PATCH] id_parent and id_children was not set. So introduce new method to return same with no risk to break current working code to address this. --- htdocs/user/class/user.class.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6f59ac5eadf..afb53bb5a5e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2220,8 +2220,6 @@ class User extends CommonObject * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_parent',...) trie selon arbre et avec: * id = id du user - * id_parent = id du user parent - * id_children = tableau des id enfant * name = nom du user * fullname = nom avec chemin complet du user * fullpath = chemin complet compose des id @@ -2306,6 +2304,29 @@ class User extends CommonObject return $this->users; } + /** + * Return list of all childs users in herarchy. + * + * @return array Array of user id lower than user. This overwrite this->users. + */ + function getAllChildIds() + { + // Init this->users + $this->get_full_tree(); + + $idtoscan=$this->id; + $childids=array(); + + dol_syslog("Build childid for id = ".$idtoscan); + foreach($this->users as $id => $val) + { + //var_dump($val['fullpath']); + if (preg_match('/_'.$idtoscan.'_/', $val['fullpath'])) $childids[$val['id']]=$val['id']; + } + + return $childids; + } + /** * For user id_user and its childs available in this->users, define property fullpath and fullname *