X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttUser.class.php;h=c00bd9f42cd62ec8563aff8426ff76d174b387f3;hb=1ca0df080b44b700872bec9216d8405b1f90bc11;hp=5e359cd213c1dd954f22f35b2f09f06e4fc06925;hpb=9af5722a81d1999243ac3a3d51d3cf3c3256d86a;p=timetracker.git diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 5e359cd2..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']; @@ -179,6 +181,16 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->decimal_mark : $this->decimal_mark); } + // getDateFormat returns date format for active group. + function getDateFormat() { + return ($this->behalfGroup ? $this->behalfGroup->date_format : $this->date_format); + } + + // getTimeFormat returns time format for active group. + function getTimeFormat() { + return ($this->behalfGroup ? $this->behalfGroup->time_format : $this->time_format); + } + // getTrackingMode returns tracking mode for active group. function getTrackingMode() { return ($this->behalfGroup ? $this->behalfGroup->tracking_mode : $this->tracking_mode); @@ -189,11 +201,26 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->record_type : $this->record_type); } + // getCurrency returns currency string for active group. + function getCurrency() { + return ($this->behalfGroup ? $this->behalfGroup->currency : $this->currency); + } + // getPlugins returns plugins string for active group. function getPlugins() { return ($this->behalfGroup ? $this->behalfGroup->plugins : $this->plugins); } + // getLockSpec returns lock specification for active group. + function getLockSpec() { + 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); @@ -230,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". @@ -314,7 +341,7 @@ class ttUser { if (!$this->isPluginEnabled('lk')) return false; // Locking feature is disabled. - if (!$this->lock_spec) + if (!$this->getLockSpec()) return false; // There is no lock specification. if (!$this->behalf_id && $this->can('override_own_date_lock')) @@ -327,7 +354,7 @@ class ttUser { require_once(LIBRARY_DIR.'/tdcron/class.tdcron.entry.php'); // Calculate the last occurrence of a lock. - $last = tdCron::getLastOccurrence($this->lock_spec, time()); + $last = tdCron::getLastOccurrence($this->getLockSpec(), time()); $lockdate = new DateAndTime(DB_DATEFORMAT, strftime('%Y-%m-%d', $last)); if ($date->before($lockdate)) return true; @@ -574,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']); @@ -767,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; @@ -790,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. @@ -813,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; + } }