From: Nik Okuntseff Date: Tue, 27 Nov 2018 22:49:50 +0000 (+0000) Subject: Refactoring: renamed getActiveUser() to getUser(). X-Git-Tag: timetracker_1.19-1~534 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=fa6508ac21c30d6bfef008387fabd29a843d7b66;p=timetracker.git Refactoring: renamed getActiveUser() to getUser(). --- diff --git a/WEB-INF/lib/form/Calendar.class.php b/WEB-INF/lib/form/Calendar.class.php index 4c835f62..6c4a4223 100644 --- a/WEB-INF/lib/form/Calendar.class.php +++ b/WEB-INF/lib/form/Calendar.class.php @@ -260,7 +260,7 @@ class Calendar extends FormElement { function _getActiveDates($start, $end) { global $user; - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); $table = ($this->highlight == 'expenses') ? 'tt_expense_items' : 'tt_log'; diff --git a/WEB-INF/lib/ttClientHelper.class.php b/WEB-INF/lib/ttClientHelper.class.php index 8f673f43..3ae662a1 100644 --- a/WEB-INF/lib/ttClientHelper.class.php +++ b/WEB-INF/lib/ttClientHelper.class.php @@ -289,7 +289,7 @@ class ttClientHelper { static function getClientsForUser() { global $user; - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); $result = array(); $mdb2 = getConnection(); diff --git a/WEB-INF/lib/ttExpenseHelper.class.php b/WEB-INF/lib/ttExpenseHelper.class.php index e42a0ab5..622e035c 100644 --- a/WEB-INF/lib/ttExpenseHelper.class.php +++ b/WEB-INF/lib/ttExpenseHelper.class.php @@ -34,7 +34,7 @@ class ttExpenseHelper { global $user; $mdb2 = getConnection(); - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); $group_id = $user->getGroup(); $org_id = $user->org_id; diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 457d2302..eae6b83f 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -166,8 +166,13 @@ class ttUser { } } + // The getUser returns user id on behalf of whom the current user is operating. + function getUser() { + return ($this->behalf_id ? $this->behalf_id : $this->id); + } + // The getGroup returns group id on behalf of which the current user is operating. - function getGroup() { + function getGroup() { return ($this->behalfGroup ? $this->behalfGroup->id : $this->group_id); } @@ -196,11 +201,6 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->config : $this->config); } - // The getActiveUser returns user id on behalf of whom the current user is operating. - function getActiveUser() { - return ($this->behalf_id ? $this->behalf_id : $this->id); - } - // can - determines whether user has a right to do something. function can($do_something) { return in_array($do_something, $this->rights); @@ -226,7 +226,7 @@ class ttUser { $group_id = $this->behalf_group_id ? $this->behalf_group_id : $this->group_id; // 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 - inner join tt_user_project_binds upb on (upb.user_id = ".$this->getActiveUser()." and upb.project_id = p.id and upb.status = 1) + inner join tt_user_project_binds upb on (upb.user_id = ".$this->getUser()." and upb.project_id = p.id and upb.status = 1) where p.group_id = $group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index f0bc13bd..2cfb3813 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -236,7 +236,7 @@ class ttWeekViewHelper { unset($objDate); // Obtain past week(s) records. - $records = ttWeekViewHelper::getRecordsForInterval($user->getActiveUser(), $pastWeekStartDate, $pastWeekEndDate); + $records = ttWeekViewHelper::getRecordsForInterval($user->getUser(), $pastWeekStartDate, $pastWeekEndDate); // Handle potential situation of no records by re-trying for up to 4 more previous weeks (after a long vacation, etc.). if (!$records) { for ($i = 0; $i < 4; $i++) { @@ -247,7 +247,7 @@ class ttWeekViewHelper { $pastWeekEndDate = $objDate->toString(DB_DATEFORMAT); unset($objDate); - $records = ttWeekViewHelper::getRecordsForInterval($user->getActiveUser(), $pastWeekStartDate, $pastWeekEndDate); + $records = ttWeekViewHelper::getRecordsForInterval($user->getUser(), $pastWeekStartDate, $pastWeekEndDate); // Break out of the loop if we found something. if ($records) break; } @@ -492,7 +492,7 @@ class ttWeekViewHelper { // Prepare an array of fields for regular insert function. $fields4insert = array(); - $fields4insert['user_id'] = $user->getActiveUser(); + $fields4insert['user_id'] = $user->getUser(); $fields4insert['group_id'] = $user->getGroup(); $fields4insert['org_id'] = $user->org_id; $fields4insert['date'] = $entry_date; @@ -532,7 +532,7 @@ class ttWeekViewHelper { $mdb2 = getConnection(); $duration = $fields['duration']; $tt_log_id = $fields['tt_log_id']; - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); $sql = "update tt_log set duration = '$duration' where id = $tt_log_id and user_id = $user_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) @@ -598,7 +598,7 @@ class ttWeekViewHelper { $mdb2 = getConnection(); $tt_log_id = $fields['tt_log_id']; $comment = $fields['comment']; - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); $sql = "update tt_log set comment = ".$mdb2->quote($fields['comment'])." where id = $tt_log_id and user_id = $user_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index aba47ce4..70225624 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - {if $u.rank < $user->rank || $u.group_id != $user->group_id} + {if $u.group_id != $user->group_id || $u.rank < $user->rank} {else} diff --git a/expense_delete.php b/expense_delete.php index 49bb8ac1..fcb039f0 100644 --- a/expense_delete.php +++ b/expense_delete.php @@ -42,7 +42,7 @@ if (!$user->isPluginEnabled('ex')) { } $cl_id = (int)$request->getParameter('id'); // Get the expense item we are deleting. -$expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser()); +$expense_item = ttExpenseHelper::getItem($cl_id, $user->getUser()); if (!$expense_item || $expense_item['invoice_id']) { // Prohibit deleting not ours or invoiced items. header('Location: access_denied.php'); @@ -59,7 +59,7 @@ if ($request->isPost()) { if ($err->no()) { // Mark the record as deleted. - if (ttExpenseHelper::markDeleted($cl_id, $user->getActiveUser())) { + if (ttExpenseHelper::markDeleted($cl_id, $user->getUser())) { header('Location: expenses.php'); exit(); } else diff --git a/expense_edit.php b/expense_edit.php index 0c7cee5c..049bc4be 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -43,7 +43,7 @@ if (!$user->isPluginEnabled('ex')) { } $cl_id = (int)$request->getParameter('id'); // Get the expense item we are editing. -$expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser()); +$expense_item = ttExpenseHelper::getItem($cl_id, $user->getUser()); if (!$expense_item || $expense_item['invoice_id']) { // Prohibit editing not ours or invoiced items. header('Location: access_denied.php'); @@ -189,7 +189,7 @@ if ($request->isPost()) { // Now, an update. if ($err->no()) { - if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getUser(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'paid'=>$cl_paid))) { header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT)); exit(); diff --git a/expenses.php b/expenses.php index 69d8ae72..aa0d9776 100644 --- a/expenses.php +++ b/expenses.php @@ -210,8 +210,8 @@ if ($request->isPost()) { } } -$smarty->assign('day_total', ttExpenseHelper::getTotalForDay($user->getActiveUser(), $cl_date)); -$smarty->assign('expense_items', ttExpenseHelper::getItems($user->getActiveUser(), $cl_date)); +$smarty->assign('day_total', ttExpenseHelper::getTotalForDay($user->getUser(), $cl_date)); +$smarty->assign('expense_items', ttExpenseHelper::getItems($user->getUser(), $cl_date)); $smarty->assign('predefined_expenses', $predefined_expenses); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); diff --git a/mobile/expense_delete.php b/mobile/expense_delete.php index a6f0989e..c0fa032e 100644 --- a/mobile/expense_delete.php +++ b/mobile/expense_delete.php @@ -42,7 +42,7 @@ if (!$user->isPluginEnabled('ex')) { } $cl_id = (int)$request->getParameter('id'); // Get the expense item we are deleting. -$expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser()); +$expense_item = ttExpenseHelper::getItem($cl_id, $user->getUser()); if (!$expense_item || $expense_item['invoice_id']) { // Prohibit deleting not ours or invoiced items. header('Location: access_denied.php'); @@ -59,7 +59,7 @@ if ($request->isPost()) { if ($err->no()) { // Mark the record as deleted. - if (ttExpenseHelper::markDeleted($cl_id, $user->getActiveUser())) { + if (ttExpenseHelper::markDeleted($cl_id, $user->getUser())) { header('Location: expenses.php'); exit(); } else diff --git a/mobile/expense_edit.php b/mobile/expense_edit.php index 61edca26..a039f42f 100644 --- a/mobile/expense_edit.php +++ b/mobile/expense_edit.php @@ -43,7 +43,7 @@ if (!$user->isPluginEnabled('ex')) { } $cl_id = (int)$request->getParameter('id'); // Get the expense item we are editing. -$expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser()); +$expense_item = ttExpenseHelper::getItem($cl_id, $user->getUser()); if (!$expense_item || $expense_item['invoice_id']) { // Prohibit editing not ours or invoiced items. header('Location: access_denied.php'); @@ -184,7 +184,7 @@ if ($request->isPost()) { // Now, an update. if ($err->no()) { - if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getUser(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost))) { header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT)); exit(); diff --git a/mobile/expenses.php b/mobile/expenses.php index 97232f70..de1e6778 100644 --- a/mobile/expenses.php +++ b/mobile/expenses.php @@ -216,8 +216,8 @@ if ($request->isPost()) { $smarty->assign('next_date', $next_date); $smarty->assign('prev_date', $prev_date); -$smarty->assign('day_total', ttExpenseHelper::getTotalForDay($user->getActiveUser(), $cl_date)); -$smarty->assign('expense_items', ttExpenseHelper::getItems($user->getActiveUser(), $cl_date)); +$smarty->assign('day_total', ttExpenseHelper::getTotalForDay($user->getUser(), $cl_date)); +$smarty->assign('expense_items', ttExpenseHelper::getItems($user->getUser(), $cl_date)); $smarty->assign('predefined_expenses', $predefined_expenses); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); diff --git a/mobile/time.php b/mobile/time.php index 25f832bc..6aa97330 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -238,20 +238,20 @@ if ($request->isPost()) { // Prohibit creating another uncompleted record. if ($err->no()) { - if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getActiveUser())) && (($cl_finish == '') && ($cl_duration == ''))) + if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getUser())) && (($cl_finish == '') && ($cl_duration == ''))) $err->add($i18n->get('error.uncompleted_exists')." ".$i18n->get('error.goto_uncompleted').""); } // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish)) + if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish)) $err->add($i18n->get('error.overlap')); } if ($err->no()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, - 'user_id' => $user->getActiveUser(), + 'user_id' => $user->getUser(), 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'client' => $cl_client, @@ -283,8 +283,8 @@ if ($request->isPost()) { $smarty->assign('next_date', $next_date); $smarty->assign('prev_date', $prev_date); -$smarty->assign('time_records', ttTimeHelper::getRecords($user->getActiveUser(), $cl_date)); -$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getActiveUser(), $cl_date)); +$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date)); +$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date)); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); diff --git a/mobile/time_delete.php b/mobile/time_delete.php index 399895c7..55bdffe6 100644 --- a/mobile/time_delete.php +++ b/mobile/time_delete.php @@ -38,7 +38,7 @@ if (!ttAccessAllowed('track_own_time')) { exit(); } $cl_id = (int)$request->getParameter('id'); -$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser()); +$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser()); if (!$time_rec || $time_rec['invoice_id']) { // Prohibit deleting not ours or invoiced records. header('Location: access_denied.php'); @@ -64,7 +64,7 @@ if ($request->isPost()) { if ($err->no()) { // Delete the record. - $result = ttTimeHelper::delete($cl_id, $user->getActiveUser()); + $result = ttTimeHelper::delete($cl_id, $user->getUser()); if ($result) { header('Location: time.php'); diff --git a/mobile/time_edit.php b/mobile/time_edit.php index 40f58e8d..56d373ff 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -40,7 +40,7 @@ if (!ttAccessAllowed('track_own_time')) { exit(); } $cl_id = (int)$request->getParameter('id'); -$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser()); +$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser()); if (!$time_rec || $time_rec['invoice_id']) { // Prohibit editing not ours or invoiced records. header('Location: access_denied.php'); @@ -279,7 +279,7 @@ if ($request->isPost()) { // 3) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists. $uncompleted = ($cl_finish == '' && $cl_duration == ''); if ($uncompleted) { - $not_completed_rec = ttTimeHelper::getUncompleted($user->getActiveUser()); + $not_completed_rec = ttTimeHelper::getUncompleted($user->getUser()); if ($not_completed_rec && ($time_rec['id'] <> $not_completed_rec['id'])) { // We have another not completed record. $err->add($i18n->get('error.uncompleted_exists')." ".$i18n->get('error.goto_uncompleted').""); @@ -289,7 +289,7 @@ if ($request->isPost()) { // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getActiveUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id)) + if (ttTimeHelper::overlaps($user->getUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id)) $err->add($i18n->get('error.overlap')); } @@ -298,7 +298,7 @@ if ($request->isPost()) { $res = ttTimeHelper::update(array( 'id'=>$cl_id, 'date'=>$new_date->toString(DB_DATEFORMAT), - 'user_id'=>$user->getActiveUser(), + 'user_id'=>$user->getUser(), 'client'=>$cl_client, 'project'=>$cl_project, 'task'=>$cl_task, diff --git a/mobile/timer.php b/mobile/timer.php index 8422338b..ae5a96f5 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -80,7 +80,7 @@ $cl_task = $request->getParameter('task', @$_SESSION['task']); $_SESSION['task'] = $cl_task; // Obtain uncompleted record. Assumtion is that only 1 uncompleted record is allowed. -$uncompleted = ttTimeHelper::getUncompleted($user->getActiveUser()); +$uncompleted = ttTimeHelper::getUncompleted($user->getUser()); $enable_controls = ($uncompleted == null); // Elements of timeRecordForm. @@ -217,14 +217,14 @@ if ($request->isPost()) { // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish)) + if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish)) $err->add($i18n->get('error.overlap')); } if ($err->no()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, - 'user_id' => $user->getActiveUser(), + 'user_id' => $user->getUser(), 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'client' => $cl_client, @@ -254,15 +254,15 @@ if ($request->isPost()) { } if ($request->getParameter('btn_stop')) { // Stop button clicked. We need to finish an uncompleted record in progress. - $record = ttTimeHelper::getRecord($uncompleted['id'], $user->getActiveUser()); + $record = ttTimeHelper::getRecord($uncompleted['id'], $user->getUser()); // Can we complete this record? if (ttTimeHelper::isValidInterval($record['start'], $cl_finish) // finish time is greater than start time - && !ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap + && !ttTimeHelper::overlaps($user->getUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap $res = ttTimeHelper::update(array( 'id'=>$record['id'], 'date'=>$cl_date, - 'user_id'=>$user->getActiveUser(), + 'user_id'=>$user->getUser(), 'client'=>$record['client_id'], 'project'=>$record['project_id'], 'task'=>$record['task_id'], @@ -283,15 +283,15 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user->getActiveUser(), $cl_date); +$week_total = ttTimeHelper::getTimeForWeek($user->getUser(), $cl_date); $smarty->assign('week_total', $week_total); $smarty->assign('uncompleted', $uncompleted); -$smarty->assign('time_records', ttTimeHelper::getRecords($user->getActiveUser(), $cl_date)); -$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getActiveUser(), $cl_date)); +$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date)); +$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date)); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); diff --git a/time.php b/time.php index 782c3472..89f7389f 100644 --- a/time.php +++ b/time.php @@ -74,7 +74,7 @@ if ($request->isPost() && $userChanged) { $user_id = $request->getParameter('user'); $user->setOnBehalfUser($user_id); } else { - $user_id = $user->getActiveUser(); + $user_id = $user->getUser(); } // Initialize and store date in session. @@ -97,7 +97,7 @@ if ($user->isPluginEnabled('mq')){ require_once('plugins/MonthlyQuota.class.php'); $quota = new MonthlyQuota(); $month_quota_minutes = $quota->get($selected_date->mYear, $selected_date->mMonth); - $month_total = ttTimeHelper::getTimeForMonth($user->getActiveUser(), $selected_date); + $month_total = ttTimeHelper::getTimeForMonth($user->getUser(), $selected_date); $minutes_left = $month_quota_minutes - ttTimeHelper::toMinutes($month_total); $smarty->assign('month_total', $month_total); @@ -323,13 +323,13 @@ if ($request->isPost()) { // Prohibit creating another uncompleted record. if ($err->no()) { - if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getActiveUser())) && (($cl_finish == '') && ($cl_duration == ''))) + if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getUser())) && (($cl_finish == '') && ($cl_duration == ''))) $err->add($i18n->get('error.uncompleted_exists')." ".$i18n->get('error.goto_uncompleted').""); } // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish)) + if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish)) $err->add($i18n->get('error.overlap')); } @@ -337,7 +337,7 @@ if ($request->isPost()) { if ($err->no()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, - 'user_id' => $user->getActiveUser(), + 'user_id' => $user->getUser(), 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'client' => $cl_client, @@ -366,18 +366,18 @@ if ($request->isPost()) { } elseif ($request->getParameter('btn_stop')) { // Stop button pressed to finish an uncompleted record. $record_id = $request->getParameter('record_id'); - $record = ttTimeHelper::getRecord($record_id, $user->getActiveUser()); + $record = ttTimeHelper::getRecord($record_id, $user->getUser()); $browser_date = $request->getParameter('browser_date'); $browser_time = $request->getParameter('browser_time'); // Can we complete this record? if ($record['date'] == $browser_date // closing today's record && ttTimeHelper::isValidInterval($record['start'], $browser_time) // finish time is greater than start time - && !ttTimeHelper::overlaps($user->getActiveUser(), $browser_date, $record['start'], $browser_time)) { // no overlap + && !ttTimeHelper::overlaps($user->getUser(), $browser_date, $record['start'], $browser_time)) { // no overlap $res = ttTimeHelper::update(array( 'id'=>$record['id'], 'date'=>$record['date'], - 'user_id'=>$user->getActiveUser(), + 'user_id'=>$user->getUser(), 'client'=>$record['client_id'], 'project'=>$record['project_id'], 'task'=>$record['task_id'], @@ -395,12 +395,12 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user->getActiveUser(), $selected_date); +$week_total = ttTimeHelper::getTimeForWeek($user->getUser(), $selected_date); $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total); -$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getActiveUser(), $cl_date)); -$smarty->assign('time_records', ttTimeHelper::getRecords($user->getActiveUser(), $cl_date)); +$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date)); +$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date)); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); diff --git a/time_delete.php b/time_delete.php index 5d721ab1..4e368df2 100644 --- a/time_delete.php +++ b/time_delete.php @@ -38,7 +38,7 @@ if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) { exit(); } $cl_id = (int)$request->getParameter('id'); -$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser()); +$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser()); if (!$time_rec || $time_rec['invoice_id']) { // Prohibit deleting not ours or invoiced records. header('Location: access_denied.php'); @@ -64,7 +64,7 @@ if ($request->isPost()) { if ($err->no()) { // Delete the record. - $result = ttTimeHelper::delete($cl_id, $user->getActiveUser()); + $result = ttTimeHelper::delete($cl_id, $user->getUser()); if ($result) { header('Location: time.php'); diff --git a/time_edit.php b/time_edit.php index d0689ba7..99110096 100644 --- a/time_edit.php +++ b/time_edit.php @@ -40,7 +40,7 @@ if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) { exit(); } $cl_id = (int)$request->getParameter('id'); -$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser()); +$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser()); if (!$time_rec || $time_rec['invoice_id']) { // Prohibit editing not ours or invoiced records. header('Location: access_denied.php'); @@ -285,7 +285,7 @@ if ($request->isPost()) { // 3) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists. $uncompleted = ($cl_finish == '' && $cl_duration == ''); if ($uncompleted) { - $not_completed_rec = ttTimeHelper::getUncompleted($user->getActiveUser()); + $not_completed_rec = ttTimeHelper::getUncompleted($user->getUser()); if ($not_completed_rec && ($time_rec['id'] <> $not_completed_rec['id'])) { // We have another not completed record. $err->add($i18n->get('error.uncompleted_exists')." ".$i18n->get('error.goto_uncompleted').""); @@ -295,7 +295,7 @@ if ($request->isPost()) { // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getActiveUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id)) + if (ttTimeHelper::overlaps($user->getUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id)) $err->add($i18n->get('error.overlap')); } @@ -304,7 +304,7 @@ if ($request->isPost()) { $res = ttTimeHelper::update(array( 'id'=>$cl_id, 'date'=>$new_date->toString(DB_DATEFORMAT), - 'user_id'=>$user->getActiveUser(), + 'user_id'=>$user->getUser(), 'client'=>$cl_client, 'project'=>$cl_project, 'task'=>$cl_task, @@ -345,7 +345,7 @@ if ($request->isPost()) { // 2) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists. $uncompleted = ($cl_finish == '' && $cl_duration == ''); if ($uncompleted) { - $not_completed_rec = ttTimeHelper::getUncompleted($user->getActiveUser()); + $not_completed_rec = ttTimeHelper::getUncompleted($user->getUser()); if ($not_completed_rec) { // We have another not completed record. $err->add($i18n->get('error.uncompleted_exists')." ".$i18n->get('error.goto_uncompleted').""); @@ -355,7 +355,7 @@ if ($request->isPost()) { // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getActiveUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish)) + if (ttTimeHelper::overlaps($user->getUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish)) $err->add($i18n->get('error.overlap')); } @@ -364,7 +364,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date'=>$new_date->toString(DB_DATEFORMAT), - 'user_id'=>$user->getActiveUser(), + 'user_id'=>$user->getUser(), 'group_id'=>$user->getGroup(), 'org_id' => $user->org_id, 'client'=>$cl_client, diff --git a/week.php b/week.php index c71a2ccd..927e8a77 100644 --- a/week.php +++ b/week.php @@ -92,7 +92,7 @@ if ($user->isPluginEnabled('mq')){ require_once('plugins/MonthlyQuota.class.php'); $quota = new MonthlyQuota(); $month_quota = $quota->get($selected_date->mYear, $selected_date->mMonth); - $month_total = ttTimeHelper::getTimeForMonth($user->getActiveUser(), $selected_date); + $month_total = ttTimeHelper::getTimeForMonth($user->getUser(), $selected_date); $minutes_left = round(60*$month_quota) - ttTimeHelper::toMinutes($month_total); $smarty->assign('month_total', $month_total); @@ -128,7 +128,7 @@ $_SESSION['note'] = $cl_note; $dayHeaders = ttWeekViewHelper::getDayHeadersForWeek($startDate->toString(DB_DATEFORMAT)); $lockedDays = ttWeekViewHelper::getLockedDaysForWeek($startDate->toString(DB_DATEFORMAT)); // Get already existing records. -$records = ttWeekViewHelper::getRecordsForInterval($user->getActiveUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT)); +$records = ttWeekViewHelper::getRecordsForInterval($user->getUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT)); // Build data array for the table. Format is described in ttWeekViewHelper::getDataForWeekView function. if ($records) $dataArray = ttWeekViewHelper::getDataForWeekView($records, $dayHeaders); @@ -433,7 +433,7 @@ if ($request->isPost()) { $result = ttWeekViewHelper::insertDurationFromWeekView($fields, $custom_fields, $err); } elseif ($postedDuration == null || 0 == ttTimeHelper::toMinutes($postedDuration)) { // Delete an already existing record here. - $result = ttTimeHelper::delete($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $user->getActiveUser()); + $result = ttTimeHelper::delete($dataArray[$rowNumber][$dayHeader]['tt_log_id'], $user->getUser()); } else { $fields = array(); $fields['tt_log_id'] = $dataArray[$rowNumber][$dayHeader]['tt_log_id']; @@ -494,7 +494,7 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user->getActiveUser(), $selected_date); +$week_total = ttTimeHelper::getTimeForWeek($user->getUser(), $selected_date); $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total);
 Anuko Time Tracker 1.18.28.4531 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4532 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/users.tpl b/WEB-INF/templates/users.tpl index d539f8d5..fb46c96d 100644 --- a/WEB-INF/templates/users.tpl +++ b/WEB-INF/templates/users.tpl @@ -73,7 +73,7 @@ {$u.name|escape} {$u.login|escape} {$u.role_name|escape}{$i18n.label.edit} {$i18n.label.delete}