diff --git a/include/class.staff.php b/include/class.staff.php index 2f5726d012d3e6f59e7b23faee48a54023766960..0563d50174c89ad46168215b93d08528d5be0036 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -37,13 +37,11 @@ class Staff { if(!$var && !($var=$this->getId())) return false; - $sql='SELECT staff.*, grp.*, tz.offset as tz_offset ' - .' ,TIME_TO_SEC(TIMEDIFF(NOW(),IFNULL(staff.passwdreset,staff.created))) as passwd_change_sec ' + $sql='SELECT staff.*, staff.created as added, grp.* ' .' FROM '.STAFF_TABLE.' staff ' - .' LEFT JOIN '.GROUP_TABLE.' grp ON(grp.group_id=staff.group_id) ' - .' LEFT JOIN '.TIMEZONE_TABLE.' tz ON(tz.id=staff.timezone_id) '; + .' LEFT JOIN '.GROUP_TABLE.' grp ON(grp.group_id=staff.group_id) '; - $sql.=sprintf('WHERE %s=%s',is_numeric($var)?'staff_id':'username',db_input($var)); + $sql.=sprintf(' WHERE %s=%s',is_numeric($var)?'staff_id':'username',db_input($var)); if(!($res=db_query($sql)) || !db_num_rows($res)) return NULL; @@ -51,11 +49,20 @@ class Staff { $this->ht=db_fetch_array($res); $this->id = $this->ht['staff_id']; - $this->teams =$this->ht['teams']=$this->getTeams(); - - $this->teams=array(); + $this->teams = $this->ht['teams']= array(); $this->stats=array(); + //WE have to patch info here to support upgrading from old versions. + if(($time=strtotime($this->ht['passwdreset']?$this->ht['passwdreset']:$this->ht['added']))) + $this->ht['passwd_change'] = time()-$time; //XXX: check timezone issues. + + /* TODO: Add timezone class + if($this->ht['timezone_id']) + $this->ht['tz_offset'] = Timezone::getOffsetById($this->ht['timezone_id']); + elseif($this->ht['timezone_offset']) + $this->ht['tz_offset'] = $this->ht['timezone_offset']; + */ + return ($this->id); } @@ -96,7 +103,7 @@ class Staff { function isPasswdResetDue() { global $cfg; return ($cfg && $cfg->getPasswdResetPeriod() - && $this->ht['passwd_change_sec']>($cfg->getPasswdResetPeriod()*30*24*60*60)); + && $this->ht['passwd_change']>($cfg->getPasswdResetPeriod()*30*24*60*60)); } function isPasswdChangeDue() { @@ -169,7 +176,7 @@ class Staff { function getDepts() { //Departments the user is allowed to access...based on the group they belong to + user's dept. - return array_filter(array_unique(array_merge(explode(',', $this->ht['dept_access']), array($this->dept_id)))); //Neptune help us + return array_filter(array_unique(array_merge(explode(',', $this->ht['dept_access']), array($this->getDeptId())))); //Neptune help us } function getDepartments() {