posaune
[timetracker.git] / projects.php
index cc79e4a..1b13789 100644 (file)
 // +----------------------------------------------------------------------+
 
 require_once('initialize.php');
-import('form.Form');
-import('ttTeamHelper');
+import('ttGroupHelper');
 
-// Access check.
-if (!ttAccessCheck(right_data_entry)) {
+// Access checks.
+if (!(ttAccessAllowed('view_own_projects') || ttAccessAllowed('manage_projects'))) {
   header('Location: access_denied.php');
   exit();
 }
+if (MODE_PROJECTS != $user->getTrackingMode() && MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) {
+  header('Location: feature_disabled.php');
+  exit();
+}
+// End of access checks.
+
+$showFiles = $user->isPluginEnabled('at');
 
-if($user->canManageTeam()) {
-  $active_projects = ttTeamHelper::getActiveProjects($user->team_id);
-  $inactive_projects = ttTeamHelper::getInactiveProjects($user->team_id);
+if($user->can('manage_projects')) {
+  $active_projects = ttGroupHelper::getActiveProjects($showFiles);
+  $inactive_projects = ttGroupHelper::getInactiveProjects($showFiles);
 } else
-  $active_projects = $user->getAssignedProjects();
+  $active_projects = $user->getAssignedProjects($showFiles);
 
 $smarty->assign('active_projects', $active_projects);
 $smarty->assign('inactive_projects', $inactive_projects);
-$smarty->assign('title', $i18n->getKey('title.projects'));
+$smarty->assign('show_files', $showFiles);
+$smarty->assign('title', $i18n->get('title.projects'));
 $smarty->assign('content_page_name', 'projects.tpl');
 $smarty->display('index.tpl');