X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=week.php;h=c71a2ccd0d8d342fbf58b8a3fc0151abdb0af359;hb=9eb2c5f542ed33fc1aba2e7392a5a29181cbfd1a;hp=29c15e4798bc8d3dd8e128a8b85ce5d2aa90c77f;hpb=d8d15e03655dcacf8365baf6d2b36d80dad84890;p=timetracker.git diff --git a/week.php b/week.php index 29c15e47..c71a2ccd 100644 --- a/week.php +++ b/week.php @@ -38,11 +38,24 @@ import('ttClientHelper'); import('ttTimeHelper'); import('DateAndTime'); -// Access check. -if (!ttAccessAllowed('track_own_time') || !$user->isPluginEnabled('wv')) { +// Access checks. +if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) { header('Location: access_denied.php'); exit(); } +if (!$user->isPluginEnabled('wv')) { + header('Location: feature_disabled.php'); + exit(); +} +if ($user->behalf_id && (!$user->can('track_time') || !$user->checkBehalfId())) { + header('Location: access_denied.php'); // Trying on behalf, but no right or wrong user. + exit(); +} +if (!$user->behalf_id && !$user->can('track_own_time') && !$user->adjustBehalfId()) { + header('Location: access_denied.php'); // Trying as self, but no right for self, and noone to work on behalf. + exit(); +} +// End of access checks. // Initialize and store date in session. $cl_date = $request->getParameter('date', @$_SESSION['date']); @@ -70,7 +83,7 @@ $endDate->setTimestamp(mktime(0,0,0,$t_arr[4]+1,$t_arr[3]-$t_arr[6]+6+$startWeek // 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); } @@ -199,8 +212,12 @@ class WeekViewCellRenderer extends DefaultCellRenderer { $form = new Form('weekTimeForm'); if ($user->can('track_time')) { - $user_list = ttTeamHelper::getActiveUsers(array('putSelfFirst'=>true)); - if (count($user_list) > 1) { + if ($user->can('track_own_time')) + $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1,'include_self'=>true,'self_first'=>true); + else + $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1); + $user_list = $user->getUsers($options); + if (count($user_list) >= 1) { $form->addInput(array('type'=>'combobox', 'onchange'=>'this.form.submit();', 'name'=>'onBehalfUser', @@ -227,7 +244,7 @@ $form->addInputElement($table); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -235,7 +252,7 @@ if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { 'value'=>$cl_client, 'data'=>$active_clients, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); + 'empty'=>array(''=>$i18n->get('dropdown.select')))); // Note: in other modes the client list is filtered to relevant clients only. See below. } @@ -249,11 +266,11 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_project, 'data'=>$project_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); + 'empty'=>array(''=>$i18n->get('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -276,19 +293,19 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'value'=>$cl_client, 'data'=>$client_list, 'datakeys'=>array('id', 'name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); + 'empty'=>array(''=>$i18n->get('dropdown.select')))); } } 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;', 'value'=>$cl_task, 'data'=>$task_list, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); + 'empty'=>array(''=>$i18n->get('dropdown.select')))); } if (!defined('NOTE_INPUT_HEIGHT')) define('NOTE_INPUT_HEIGHT', 40); @@ -299,7 +316,7 @@ $form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date)); // if ($user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'get_date()')); // User current date, which gets filled in on btn_submit click. -$form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.submit'))); +$form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->get('button.submit'))); // If we have custom fields - add controls for them. if ($custom_fields && $custom_fields->fields[0]) { @@ -311,7 +328,7 @@ if ($custom_fields && $custom_fields->fields[0]) { 'style'=>'width: 250px;', 'value'=>$cl_cf_1, 'data'=>$custom_fields->options, - 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); + 'empty'=>array(''=>$i18n->get('dropdown.select')))); } } @@ -330,15 +347,15 @@ if ($request->isPost()) { } if ($newEntryPosted) { if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) - $err->add($i18n->getKey('error.client')); + $err->add($i18n->get('error.client')); if ($custom_fields) { - if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); + if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->get('error.field'), $custom_fields->fields[0]['label']); } if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - if (!$cl_project) $err->add($i18n->getKey('error.project')); + if (!$cl_project) $err->add($i18n->get('error.project')); } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode && $user->task_required) { - if (!$cl_task) $err->add($i18n->getKey('error.task')); + if (!$cl_task) $err->add($i18n->get('error.task')); } } // Finished validating user input for row 0. @@ -369,7 +386,7 @@ if ($request->isPost()) { // If posted value is not null, check and normalize it. if ($postedDuration) { if (false === ttTimeHelper::postedDurationToMinutes($postedDuration)) { - $err->add($i18n->getKey('error.field'), $i18n->getKey('label.duration')); + $err->add($i18n->get('error.field'), $i18n->get('label.duration')); $result = false; break; // Break out. Stop any further processing. } else { $minutes = ttTimeHelper::postedDurationToMinutes($postedDuration); @@ -433,7 +450,7 @@ if ($request->isPost()) { $existingComment = $dataArray[$rowNumber][$dayHeader]['note']; // If posted value is not null, check it. if ($postedComment && !ttValidString($postedComment, true)) { - $err->add($i18n->getKey('error.field'), $i18n->getKey('label.note')); + $err->add($i18n->get('error.field'), $i18n->get('label.note')); $result = false; break; // Break out. Stop any further processing. } // Do not process if value has not changed. @@ -490,6 +507,6 @@ $smarty->assign('onload', 'onLoad="fillDropdowns()"'); $smarty->assign('timestring', $startDate->toString($user->date_format).' - '.$endDate->toString($user->date_format)); $smarty->assign('time_records', $records); -$smarty->assign('title', $i18n->getKey('title.time')); +$smarty->assign('title', $i18n->get('title.time')); $smarty->assign('content_page_name', 'week.tpl'); $smarty->display('index.tpl');