X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttUser.class.php;h=c00bd9f42cd62ec8563aff8426ff76d174b387f3;hb=54bb71ed8e6b7f79e3b26bc1c8a70a95793950c8;hp=05081c5ab80921acaa4680dd2cf97ce3911dfd84;hpb=03e3d32869aa0791e1d841be69cf5c0c84a5450f;p=timetracker.git diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 05081c5a..c00bd9f4 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -29,6 +29,8 @@ import('ttConfigHelper'); import('ttGroupHelper'); import('ttGroup'); +import('form.Form'); +import('form.ActionForm'); class ttUser { var $login = null; // User login. @@ -111,9 +113,9 @@ class ttUser { $this->role_id = $val['role_id']; $this->role_name = $val['role_name']; $this->rights = explode(',', $val['rights']); - $this->is_client = !in_array('track_own_time', $this->rights); $this->rank = $val['rank']; $this->client_id = $val['client_id']; + $this->is_client = $this->client_id && !in_array('track_own_time', $this->rights); $this->email = $val['email']; $this->lang = $val['lang']; $this->decimal_mark = $val['decimal_mark']; @@ -214,6 +216,11 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->lock_spec : $this->lock_spec); } + // getWorkdayMinutes returns workday_minutes for active group. + function getWorkdayMinutes() { + return ($this->behalfGroup ? $this->behalfGroup->workday_minutes : $this->workday_minutes); + } + // getConfig returns config string for active group. function getConfig() { return ($this->behalfGroup ? $this->behalfGroup->config : $this->config); @@ -250,9 +257,9 @@ class ttUser { $result = array(); $mdb2 = getConnection(); + $user_id = $this->getUser(); $group_id = $this->getGroup(); $org_id = $this->org_id; - $user_id = $this->getUser(); // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name, p.description, p.tasks, upb.rate from tt_projects p". @@ -594,15 +601,10 @@ class ttUser { // updateGroup updates group information with new data. function updateGroup($fields) { - if (!($this->can('manage_basic_settings') || - $this->can('manage_advanced_settings') || - $this->can('manage_features'))) return false; - // TODO: update the above for subgroup updates. + $mdb2 = getConnection(); $group_id = $fields['group_id']; if ($group_id && !$this->isGroupValid($group_id)) return false; - - $mdb2 = getConnection(); if (!$group_id) $group_id = $this->getGroup(); if (isset($fields['name'])) $name_part = ', name = '.$mdb2->quote($fields['name']); @@ -787,6 +789,13 @@ class ttUser { unset($_SESSION['behalf_id']); unset($_SESSION['behalf_name']); + // Destroy report bean if it was set in session. + $form = new Form('dummyForm'); + $bean = new ActionForm('reportBean', $form, $request); + if ($bean->isSaved()) { + $bean->destroyBean(); + } + // Do not do anything if we don't have rights. if (!$this->can('manage_subgroups')) return; @@ -810,7 +819,7 @@ class ttUser { return; } - // setOnBehalfUser sets on behalf user both the object and the session. + // setOnBehalfUser sets on behalf user both the object and the session. function setOnBehalfUser($user_id) { // Unset things first. @@ -833,4 +842,17 @@ class ttUser { $this->behalf_name = $onBehalfUserName; return; } + + // The exists() function determines if an active user exists in context of a page. + // If we are working as self, true. + // If we are working in a subgroup with active users, true. + // If we are working in a subgroup without active users, false. + function exists() { + if (!$this->behalfGroup) + return true; // Working as self. + else if ($this->behalfGroup->active_users) + return true; // Subgroup has users. + + return false; + } }