Refactoring: renamed getActiveUser() to getUser().
authorNik Okuntseff <support@anuko.com>
Tue, 27 Nov 2018 22:49:50 +0000 (22:49 +0000)
committerNik Okuntseff <support@anuko.com>
Tue, 27 Nov 2018 22:49:50 +0000 (22:49 +0000)
21 files changed:
WEB-INF/lib/form/Calendar.class.php
WEB-INF/lib/ttClientHelper.class.php
WEB-INF/lib/ttExpenseHelper.class.php
WEB-INF/lib/ttUser.class.php
WEB-INF/lib/ttWeekViewHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/users.tpl
expense_delete.php
expense_edit.php
expenses.php
mobile/expense_delete.php
mobile/expense_edit.php
mobile/expenses.php
mobile/time.php
mobile/time_delete.php
mobile/time_edit.php
mobile/timer.php
time.php
time_delete.php
time_edit.php
week.php

index 4c835f6..6c4a422 100644 (file)
@@ -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';
       
index 8f673f4..3ae662a 100644 (file)
@@ -289,7 +289,7 @@ class ttClientHelper {
   static function getClientsForUser()
   {
     global $user;
-    $user_id = $user->getActiveUser();
+    $user_id = $user->getUser();
 
     $result = array();
     $mdb2 = getConnection();
index e42a0ab..622e035 100644 (file)
@@ -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;
 
index 457d230..eae6b83 100644 (file)
@@ -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')) {
index f0bc13b..2cfb381 100644 (file)
@@ -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'))
index aba47ce..7022562 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.28.4531 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.28.4532 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index d539f8d..fb46c96 100644 (file)
@@ -73,7 +73,7 @@
           <td>{$u.name|escape}</td>
           <td>{$u.login|escape}</td>
           <td>{$u.role_name|escape}</td>
-      {if $u.rank < $user->rank || $u.group_id != $user->group_id}
+      {if $u.group_id != $user->group_id || $u.rank < $user->rank}
           <td><a href="user_edit.php?id={$u.id}">{$i18n.label.edit}</a></td>
           <td><a href="user_delete.php?id={$u.id}">{$i18n.label.delete}</a></td>
       {else}
index 49bb8ac..fcb039f 100644 (file)
@@ -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
index 0c7cee5..049bc4b 100644 (file)
@@ -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();
index 69d8ae7..aa0d977 100644 (file)
@@ -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);
index a6f0989..c0fa032 100644 (file)
@@ -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
index 61edca2..a039f42 100644 (file)
@@ -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();
index 97232f7..de1e677 100644 (file)
@@ -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);
index 25f832b..6aa9733 100644 (file)
@@ -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')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
     }
 
     // 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);
index 399895c..55bdffe 100644 (file)
@@ -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');
index 40f58e8..56d373f 100644 (file)
@@ -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')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
@@ -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,
index 8422338..ae5a96f 100644 (file)
@@ -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);
index 782c347..89f7389 100644 (file)
--- 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')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
     }
 
     // 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);
index 5d721ab..4e368df 100644 (file)
@@ -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');
index d0689ba..9911009 100644 (file)
@@ -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')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
@@ -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')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
@@ -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,
index c71a2cc..927e8a7 100644 (file)
--- 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);