X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttUser.class.php;h=e50d9a3ea2fe3a15ea413315c48b86a03a94fa30;hb=f05a2db179417c20c7d841f0363bca4988c8a2ca;hp=25cc83f7a7426c63aba7d1bfc5b0d1e50ea9b5a0;hpb=460983ff96c7f6b57d7d7d567c767730fb1ba36e;p=timetracker.git diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 25cc83f7..e50d9a3e 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -419,7 +419,7 @@ class ttUser { 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"; + " and parent_id = $group_id and status is not null order by upper(name)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -672,4 +672,37 @@ class ttUser { } return $user_part; } + + // setOnBehalfGroup sets on behalf group for the user in both the object and the session. + function setOnBehalfGroup($group_id) { + + // Unset things first. + $this->behalf_group_id = null; + $this->behalf_group_name = null; + unset($_SESSION['behalf_group_id']); + unset($_SESSION['behalf_group_name']); + + // Do not do anything if we don't have rights. + if (!$this->can('manage_subgroups')) return; + + // No need to set if the group is our home group. + if ($group_id == $this->group_id) return; + + // No need to set if the subgroup is not valid. + if (!$this->isSubgroupValid($group_id)) return; + + // We are good to set on behalf group. + $onBehalfGroupName = ttGroupHelper::getGroupName($group_id); + $_SESSION['behalf_group_id'] = $group_id; + $_SESSION['behalf_group_name'] = $onBehalfGroupName; + $this->behalf_group_id = $group_id; + $this->behalf_group_name = $onBehalfGroupName; + + // Question remains whether or not we need to adjust on behalf user. + // Adjusting for now. Test it and redesign if necessary. + unset($_SESSION['behalf_id']); + unset($_SESSION['behalf_name']); + $this->adjustBehalfId(); + return; + } }