Fix: get_full_tree was not working correctly.

This commit is contained in:
Laurent Destailleur 2014-08-07 20:11:39 +02:00
parent de76fe4951
commit 159d0c7057

View File

@ -2192,8 +2192,8 @@ class User extends CommonObject
// Load array[child]=parent // Load array[child]=parent
$sql = "SELECT fk_user as id_parent, rowid as id_son"; $sql = "SELECT fk_user as id_parent, rowid as id_son";
$sql.= " FROM ".MAIN_DB_PREFIX."user"; $sql.= " FROM ".MAIN_DB_PREFIX."user";
$sql.= " WHERE fk_user != 0"; $sql.= " WHERE fk_user <> 0";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity IN (".getEntity('user',1).")";
dol_syslog(get_class($this)."::load_parentof sql=".$sql); dol_syslog(get_class($this)."::load_parentof sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -2322,13 +2322,13 @@ class User extends CommonObject
// Define fullpath and fullname // Define fullpath and fullname
$this->users[$id_user]['fullpath'] = '_'.$id_user; $this->users[$id_user]['fullpath'] = '_'.$id_user;
$this->users[$id_user]['fullname'] = $this->users[$id_user]['label']; $this->users[$id_user]['fullname'] = $this->users[$id_user]['lastname'];
$i=0; $cursor_user=$id_user; $i=0; $cursor_user=$id_user;
while ((empty($protection) || $i < $protection) && ! empty($this->parentof[$cursor_user])) while ((empty($protection) || $i < $protection) && ! empty($this->parentof[$cursor_user])) // Loop on each parent, one after one
{ {
$this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath']; $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath'];
$this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['label'].' >> '.$this->users[$id_user]['fullname']; $this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'].' >> '.$this->users[$id_user]['fullname'];
$i++; $cursor_user=$this->parentof[$cursor_user]; $i++; $cursor_user=$this->parentof[$cursor_user];
} }