posaune
[timetracker.git] / projects.php
index b8faa14..1b13789 100644 (file)
@@ -27,8 +27,7 @@
 // +----------------------------------------------------------------------+
 
 require_once('initialize.php');
-import('form.Form');
-import('ttTeamHelper');
+import('ttGroupHelper');
 
 // Access checks.
 if (!(ttAccessAllowed('view_own_projects') || ttAccessAllowed('manage_projects'))) {
@@ -39,48 +38,19 @@ if (MODE_PROJECTS != $user->getTrackingMode() && MODE_PROJECTS_AND_TASKS != $use
   header('Location: feature_disabled.php');
   exit();
 }
-if ($request->isPost() && !$user->isGroupValid($request->getParameter('group'))) {
-  header('Location: access_denied.php'); // Wrong group id in post.
-  exit();
-}
 // End of access checks.
 
-if ($request->isPost()) {
-  $group_id = $request->getParameter('group');
-  $user->setOnBehalfGroup($group_id);
-  // Projects feature may not be available in new group, check and redirect.
-  if (MODE_PROJECTS != $user->getTrackingMode() && MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) {
-    header('Location: feature_disabled.php');
-    exit();
-  }
-} else {
-  $group_id = $user->getGroup();
-}
-
-$form = new Form('projectsForm');
-if ($user->can('manage_subgroups')) {
-  $groups = $user->getGroupsForDropdown();
-  if (count($groups) > 1) {
-    $form->addInput(array('type'=>'combobox',
-      'onchange'=>'this.form.submit();',
-      'name'=>'group',
-      'style'=>'width: 250px;',
-      'value'=>$group_id,
-      'data'=>$groups,
-      'datakeys'=>array('id','name')));
-    $smarty->assign('group_dropdown', 1);
-  }
-}
+$showFiles = $user->isPluginEnabled('at');
 
 if($user->can('manage_projects')) {
-  $active_projects = ttTeamHelper::getActiveProjects($group_id);
-  $inactive_projects = ttTeamHelper::getInactiveProjects($group_id);
+  $active_projects = ttGroupHelper::getActiveProjects($showFiles);
+  $inactive_projects = ttGroupHelper::getInactiveProjects($showFiles);
 } else
-  $active_projects = $user->getAssignedProjects();
+  $active_projects = $user->getAssignedProjects($showFiles);
 
-$smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('active_projects', $active_projects);
 $smarty->assign('inactive_projects', $inactive_projects);
+$smarty->assign('show_files', $showFiles);
 $smarty->assign('title', $i18n->get('title.projects'));
 $smarty->assign('content_page_name', 'projects.tpl');
 $smarty->display('index.tpl');