From: Nik Okuntseff Date: Sun, 25 Nov 2018 22:06:55 +0000 (+0000) Subject: Introduced ttGroup class to store attributes of on behalf group. X-Git-Tag: timetracker_1.19-1~549 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ca6d2f927b985f4d80b31e5e2c6deb98e4fae6f6;p=timetracker.git Introduced ttGroup class to store attributes of on behalf group. --- diff --git a/WEB-INF/lib/ttGroup.class.php b/WEB-INF/lib/ttGroup.class.php new file mode 100644 index 00000000..2943438a --- /dev/null +++ b/WEB-INF/lib/ttGroup.class.php @@ -0,0 +1,131 @@ +query($sql); + if (is_a($res, 'PEAR_Error')) { + return; + } + + $val = $res->fetchRow(); + if ($val['id'] > 0) { + $this->id = $val['id']; + $this->parent_id = $val['parent_id']; + $this->org_id = $val['org_id']; + $this->name = $val['name']; + $this->lang = $val['lang']; + $this->decimal_mark = $val['decimal_mark']; + $this->date_format = $val['date_format']; + $this->time_format = $val['time_format']; + $this->week_start = $val['week_start']; + /* TODO: initialize other things here. + $this->tracking_mode = $val['tracking_mode']; + $this->project_required = $val['project_required']; + $this->task_required = $val['task_required']; + $this->record_type = $val['record_type']; + $this->bcc_email = $val['bcc_email']; + $this->allow_ip = $val['allow_ip']; + $this->password_complexity = $val['password_complexity']; + $this->group_name = $val['group_name']; + $this->currency = $val['currency']; + $this->plugins = $val['plugins']; + $this->lock_spec = $val['lock_spec']; + $this->workday_minutes = $val['workday_minutes']; + $this->custom_logo = $val['custom_logo']; + + $this->config = $val['config']; + $config = new ttConfigHelper($this->config); + // Set user config options. + $this->show_holidays = $config->getDefinedValue('show_holidays'); + $this->punch_mode = $config->getDefinedValue('punch_mode'); + $this->allow_overlap = $config->getDefinedValue('allow_overlap'); + $this->future_entries = $config->getDefinedValue('future_entries'); + $this->uncompleted_indicators = $config->getDefinedValue('uncompleted_indicators'); + if ($this->isPluginEnabled('wu')) { + $minutes_in_unit = $config->getIntValue('minutes_in_unit'); + if ($minutes_in_unit) $this->minutes_in_unit = $minutes_in_unit; + $first_unit_threshold = $config->getIntValue('1st_unit_threshold'); + if ($first_unit_threshold) $this->first_unit_threshold = $first_unit_threshold; + $this->unit_totals_only = $config->getDefinedValue('unit_totals_only'); + } + + // Set "on behalf" id and name (user). + if (isset($_SESSION['behalf_id'])) { + $this->behalf_id = $_SESSION['behalf_id']; + $this->behalf_name = $_SESSION['behalf_name']; + } + // Set "on behalf" id and name (group). + if (isset($_SESSION['behalf_group_id'])) { + $this->behalf_group_id = $_SESSION['behalf_group_id']; + $this->behalf_group_name = $_SESSION['behalf_group_name']; + } + */ + } + } +} diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 8c4595db..ccd1f961 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -28,6 +28,7 @@ import('ttConfigHelper'); import('ttGroupHelper'); +import('ttGroup'); class ttUser { var $login = null; // User login. @@ -74,6 +75,8 @@ class ttUser { var $first_unit_threshold = 0;// Threshold for 1st unit for Work units plugin. var $unit_totals_only = 0; // Totals only option for the Work units plugin. + var $behalfGroup = null; // A ttGroup instance with on behalf group attributes. + // Constructor. function __construct($login, $id = null) { if (!$login && !$id) { @@ -150,13 +153,15 @@ class ttUser { // Set "on behalf" id and name (user). if (isset($_SESSION['behalf_id'])) { - $this->behalf_id = $_SESSION['behalf_id']; - $this->behalf_name = $_SESSION['behalf_name']; + $this->behalf_id = $_SESSION['behalf_id']; + $this->behalf_name = $_SESSION['behalf_name']; } // Set "on behalf" id and name (group). if (isset($_SESSION['behalf_group_id'])) { - $this->behalf_group_id = $_SESSION['behalf_group_id']; - $this->behalf_group_name = $_SESSION['behalf_group_name']; + $this->behalf_group_id = $_SESSION['behalf_group_id']; + $this->behalf_group_name = $_SESSION['behalf_group_name']; + + $this->behalfGroup = new ttGroup($this->behalf_group_id, $this->org_id); } } } @@ -714,6 +719,9 @@ class ttUser { $this->behalf_group_id = $group_id; $this->behalf_group_name = $onBehalfGroupName; + unset($this->behalfGroup); + $this->behalfGroup = new ttGroup($this->behalf_group_id, $this->org_id); + // Adjust on behalf user. $this->adjustBehalfId(); return; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 47031b29..13992f25 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4516 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4517 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}