X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttUser.class.php;h=04273aa78b5c9a1b5bf6771ad5c7b253373c7d98;hb=7797eda9fb04c217a813db88e00bb9ee541eabbb;hp=8e907c8ab6c5188382cca0b9595029929ff94587;hpb=6cdff5151bba8cd6c8bd1bb90b1b2c18457ecb88;p=timetracker.git diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 8e907c8a..04273aa7 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -166,6 +166,11 @@ class ttUser { } } + // The getGroup returns group id on behalf of which the current user is operating. + function getGroup() { + return ($this->behalfGroup ? $this->behalfGroup->id : $this->group_id); + } + // getDecimalMark returns decimal mark for active group. function getDecimalMark() { return ($this->behalfGroup ? $this->behalfGroup->decimal_mark : $this->decimal_mark); @@ -181,11 +186,6 @@ class ttUser { return ($this->behalf_id ? $this->behalf_id : $this->id); } - // The getActiveGroup returns group id on behalf of which the current user is operating. - function getActiveGroup() { - return ($this->behalf_group_id ? $this->behalf_group_id : $this->group_id); - } - // can - determines whether user has a right to do something. function can($do_something) { return in_array($do_something, $this->rights); @@ -323,7 +323,7 @@ class ttUser { function getUsers($options) { $mdb2 = getConnection(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $org_id = $this->org_id; $skipClients = !isset($options['include_clients']); @@ -408,7 +408,7 @@ class ttUser { // Start with subgroups. $groups = array(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = $group_id and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -451,7 +451,7 @@ class ttUser { function getSubgroups($group_id = null) { $mdb2 = getConnection(); - if (!$group_id) $group_id = $this->getActiveGroup(); + if (!$group_id) $group_id = $this->getGroup(); $sql = "select id, name, description from tt_groups where org_id = $this->org_id". " and parent_id = $group_id and status is not null order by upper(name)"; @@ -470,7 +470,7 @@ class ttUser { if (!$this->can('manage_users')) return false; $mdb2 = getConnection(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $org_id = $this->org_id; $sql = "select u.id, u.name, u.login, u.role_id, u.client_id, u.status, u.rate, u.email from tt_users u". @@ -552,7 +552,7 @@ class ttUser { if ($group_id && !$this->isGroupValid($group_id)) return false; $mdb2 = getConnection(); - if (!$group_id) $group_id = $this->getActiveGroup(); + if (!$group_id) $group_id = $this->getGroup(); if (isset($fields['name'])) $name_part = ', name = '.$mdb2->quote($fields['name']); if (isset($fields['description'])) $description_part = ', description = '.$mdb2->quote($fields['description']); @@ -597,7 +597,7 @@ class ttUser { if (!$user_details) return false; $mdb2 = getConnection(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $org_id = $this->org_id; // Mark user to project binds as deleted.