diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 266ebac9100dfe1f2caed53fcca138b29a63702e..0bc620c41bfde62660eab15b293def68907d0a2a 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -259,7 +259,6 @@ if ($result) { $num = $db->num_rows($result); $i = 0; - $var=false; while ($i < $num) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 594c7e090d6a582954c24d0b18189b4e1982a14a..ac03847583df1065dd4be98aa9c3d130c40e0565 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -104,16 +104,17 @@ class User extends CommonObject public $lang; public $rights; // Array of permissions user->rights->permx - public $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */ - private $_tab_loaded=array(); // Array of cache of already loaded permissions - public $nb_rights; // Number of rights granted to the user - + public $all_permissions_are_loaded; // All permission are loaded + public $nb_rights; // Number of rights granted to the user + private $_tab_loaded=array(); // Cache array of already loaded permissions + public $conf; // To store personal config - var $oldcopy; // To contains a clone of this when we need to save old properties of object - + public $default_values; // To store default values for user + public $users; // To store all tree of users hierarchy public $parentof; // To store an array of all parents for all ids. - + private $cache_childids; + public $accountancy_code; // Accountancy code in prevision of the complete accountancy module public $thm; // Average cost of employee - Used for valuation of time spent @@ -127,7 +128,6 @@ class User extends CommonObject public $dateemployment; // Define date of employment by company - private $cache_childids; /** @@ -339,6 +339,7 @@ class User extends CommonObject // To get back the global configuration unique to the user if ($loadpersonalconf) { + // Load user->conf for user $sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param"; $sql.= " WHERE fk_user = ".$this->id; $sql.= " AND entity = ".$conf->entity; @@ -362,6 +363,24 @@ class User extends CommonObject $this->error=$this->db->error(); return -2; } + + // Load user->default_values for user. TODO Save this in memcached ? + $sql = "SELECT rowid, entity, type, page, param, value"; + $sql.= " FROM ".MAIN_DB_PREFIX."default_values"; + $sql.= " WHERE entity IN (".$this->entity.",".$conf->entity.")"; + $sql.= " AND user_id IN (0, ".$this->id.")"; + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj = $this->db->fetch_object($resql)) + { + if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) + { + $user->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; + } + } + $this->db->free($resql); + } } return 1;