X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/d6a5ffec0f76b9ab5b1ee4f8e69ecdb2afd7c0ff..7f0309861f7e86e63d71775df7e491cdb25433e5:/WEB-INF/lib/ttUser.class.php diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 86174547..ad5c0410 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -27,6 +27,7 @@ // +----------------------------------------------------------------------+ import('ttConfigHelper'); +import('ttGroupHelper'); class ttUser { var $login = null; // User login. @@ -379,14 +380,14 @@ class ttUser { if ($selected_group_id != $this->group_id) { // We are in one of subgroups, and a parent exists. // Get parent group info. - $sql = "select parent_id from tt_groups where org_id = $this->org_id and id = $selected_group_id"; + $sql = "select parent_id from tt_groups where org_id = $this->org_id and id = $selected_group_id and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); $parent_id = $val['parent_id']; if ($parent_id) { // Get parent group name. - $sql = "select name from tt_groups where org_id = $this->org_id and id = $parent_id"; + $sql = "select name from tt_groups where org_id = $this->org_id and id = $parent_id and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -400,25 +401,29 @@ class ttUser { $groups[] = array('id'=>$selected_group_id,'name'=>$selected_group_name); // Add subgroups. - $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = $selected_group_id"; + $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = $selected_group_id and status = 1"; + //die($sql); $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { - $groups[] = array('id'=>$val['id'],'name'=>$val['name']); + $groups[] = $val; } } return $groups; } // getSubgroups obtains a list of immediate subgroups. - function getSubgroups() { + function getSubgroups($group_id = null) { $mdb2 = getConnection(); - $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = ".$this->getActiveGroup();; + if (!$group_id) $group_id = $this->getActiveGroup(); + + $sql = "select id, name, description from tt_groups where org_id = $this->org_id". + " and parent_id = $group_id and status is not null"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { - $groups[] = array('id'=>$val['id'],'name'=>$val['name']); + $groups[] = $val; } } return $groups; @@ -599,6 +604,14 @@ class ttUser { return true; } + // isGroupValid determines if a group is valid for user. + function isGroupValid($group_id) { + if ($group_id == $this->group_id) + return true; + else + return $this->isSubgroupValid($group_id); + } + // isSubgroupValid determines if a subgroup is valid for user. // A subgroup is valid if: // - user can manage_subgroups;