A bit more progress on renaming.
[timetracker.git] / reports.php
index 59f3c0f..0028e99 100644 (file)
@@ -37,7 +37,7 @@ import('ttFavReportHelper');
 import('ttClientHelper');
 
 // Access check.
-if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) {
+if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports') || ttAccessAllowed('view_all_reports'))) {
   header('Location: access_denied.php');
   exit();
 }
@@ -45,7 +45,7 @@ if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) {
 // Use custom fields plugin if it is enabled.
 if ($user->isPluginEnabled('cf')) {
   require_once('plugins/CustomFields.class.php');
-  $custom_fields = new CustomFields($user->team_id);
+  $custom_fields = new CustomFields($user->group_id);
   $smarty->assign('custom_fields', $custom_fields);
 }
 
@@ -104,7 +104,7 @@ $form->addInput(array('type'=>'combobox',
   'datakeys'=>array('id','name'),
   'empty'=>array(''=>$i18n->get('dropdown.all'))));
 if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
-  $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+  $task_list = ttTeamHelper::getActiveTasks($user->group_id);
   $form->addInput(array('type'=>'combobox',
     'name'=>'task',
     'style'=>'width: 250px;',
@@ -141,15 +141,16 @@ if ($user->canManageTeam() && $user->isPluginEnabled('ps')) {
 }
 
 $user_list = array();
-if ($user->can('view_reports') || $user->isClient()) {
+if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) {
   // Prepare user and assigned projects arrays.
-  if ($user->can('view_reports')) {
-    // $users = ttTeamHelper::getUsers(); // Active and inactive users for managers.
+  if ($user->can('view_reports') || $user->can('view_all_reports')) {
+    $max_rank = $user->rank-1;
+    if ($user->can('view_all_reports')) $max_rank = 512;
     if ($user->can('view_own_reports'))
-      $options = array('max_rank'=>$user->rank-1,'include_self'=>true);
+      $options = array('max_rank'=>$max_rank,'include_self'=>true);
     else
-      $options = array('max_rank'=>$user->rank-1);
-    $users = $user->getUsers($options); // Active and inactive users for managers.
+      $options = array('max_rank'=>$max_rank);
+    $users = $user->getUsers($options); // Active and inactive users.
   }
   elseif ($user->isClient())
     $users = ttTeamHelper::getUsersForClient(); // Active and inactive users for clients.