X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=charts.php;h=d6707038f93f8762550e37b0e9388b34ed85d09f;hb=a575a9147976a06263d8a7eae006d6ba3372446e;hp=69997d87f9536c2cd9bb14a7144a45555a416dd3;hpb=a0dd058ab6007cfc6a72713215a7f4abb96f1b45;p=timetracker.git diff --git a/charts.php b/charts.php index 69997d87..d6707038 100644 --- a/charts.php +++ b/charts.php @@ -37,11 +37,23 @@ import('PieChartEx'); import('ttUserHelper'); import('ttTeamHelper'); -// Access check. -if (!ttAccessAllowed('view_own_charts') || !$user->isPluginEnabled('ch')) { +// Access checks. +if (!(ttAccessAllowed('view_own_charts') || ttAccessAllowed('view_charts'))) { header('Location: access_denied.php'); exit(); } +if (!$user->isPluginEnabled('ch')) { + header('Location: feature_disabled.php'); + exit(); +} +if ($user->behalf_id && (!$user->can('view_charts') || !$user->checkBehalfId())) { + header('Location: access_denied.php'); // Trying on behalf, but no right or wrong user. + exit(); +} +if (!$user->behalf_id && !$user->can('view_own_charts') && !$user->adjustBehalfId()) { + header('Location: access_denied.php'); // Trying as self, but no right for self, and noone to view on behalf. + exit(); +} // Initialize and store date in session. $cl_date = $request->getParameter('date', @$_SESSION['date']); @@ -105,7 +117,7 @@ if ($request->isPost()) { } // If user has changed - set behalf_id accordingly in the session. if ($request->getParameter('onBehalfUser')) { - if($user->canManageTeam()) { + if($user->can('view_charts')) { unset($_SESSION['behalf_id']); unset($_SESSION['behalf_name']); @@ -123,9 +135,13 @@ if ($request->isPost()) { $chart_form = new Form('chartForm'); // User dropdown. Changes the user "on behalf" of whom we are working. -if ($user->canManageTeam()) { - $user_list = ttTeamHelper::getActiveUsers(array('putSelfFirst'=>true)); - if (count($user_list) > 1) { +if ($user->can('view_charts')) { + if ($user->can('view_own_charts')) + $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) { $chart_form->addInput(array('type'=>'combobox', 'onchange'=>'this.form.submit();', 'name'=>'onBehalfUser',