isPluginEnabled('ts')) { header('Location: feature_disabled.php'); exit(); } if ($user->isClient()) { header('Location: access_denied.php'); // No timesheets for clients. exit(); } if ($request->isPost()) { $userChanged = $request->getParameter('user_changed'); // Reused in multiple places below. if ($userChanged && !($user->can('view_timesheets') && $user->isUserValid($request->getParameter('user')))) { header('Location: access_denied.php'); // Group changed, but no rght or wrong user id. TODO: research relevance of this... exit(); } } // End of access checks. // Determine user for which we display this page. if ($request->isPost() && $userChanged) { $user_id = $request->getParameter('user'); $user->setOnBehalfUser($user_id); } else { $user_id = $user->getUser(); } $group_id = $user->getGroup(); // Elements of timesheetsForm. $form = new Form('timesheetsForm'); if ($user->can('view_timesheets') || $user->can('view_all_timesheets')) { $rank = $user->getMaxRankForGroup($group_id); if ($user->can('view_own_timesheets')) $options = array('status'=>ACTIVE,'max_rank'=>$rank,'include_self'=>true,'self_first'=>true); else $options = array('status'=>ACTIVE,'max_rank'=>$rank); $user_list = $user->getUsers($options); if (count($user_list) >= 1) { $form->addInput(array('type'=>'combobox', 'onchange'=>'document.timesheetsForm.user_changed.value=1;document.timesheetsForm.submit();', 'name'=>'user', 'style'=>'width: 250px;', 'value'=>$user_id, 'data'=>$user_list, 'datakeys'=>array('id','name'))); $form->addInput(array('type'=>'hidden','name'=>'user_changed')); $smarty->assign('user_dropdown', 1); } } $active_timesheets = ttTimesheetHelper::getActiveTimesheets($user_id); $inactive_timesheets = ttTimesheetHelper::getInactiveTimesheets($user_id); $showClient = $user->isPluginEnabled('cl'); $canEdit = $user->can('manage_own_timesheets') || $user->can('manage_timesheets') || $user->can('manage_all_timesheets'); $smarty->assign('active_timesheets', $active_timesheets); $smarty->assign('inactive_timesheets', $inactive_timesheets); $smarty->assign('show_client', $showClient); $smarty->assign('can_edit', $canEdit); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('title', $i18n->get('title.timesheets')); $smarty->assign('content_page_name', 'timesheets.tpl'); $smarty->display('index.tpl');