X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=charts.php;h=c76eddfa549b296d4b1807ed6886cd72908805c5;hb=f8202dca930de9e3cc70cbc8084e10a0f346f389;hp=5bf9034899a6209b4cf8ad21340f1ec16ea5eab1;hpb=5ef582473f6b329be18ad83c61e053fdcd9c6ed5;p=timetracker.git diff --git a/charts.php b/charts.php index 5bf90348..c76eddfa 100644 --- a/charts.php +++ b/charts.php @@ -38,7 +38,7 @@ import('ttUserHelper'); import('ttTeamHelper'); // Access check. -if (!ttAccessCheck(right_view_charts)) { +if (!ttAccessCheck(right_view_charts) || !$user->isPluginEnabled('ch')) { header('Location: access_denied.php'); exit(); } @@ -67,13 +67,13 @@ if (!$cl_type) { $cl_type = $sc->getValue(SYSC_CHART_TYPE); } if (MODE_TIME == $user->tracking_mode) { - if (in_array('cl', explode(',', $user->plugins))) + if ($user->isPluginEnabled('cl')) $cl_type = CHART_CLIENTS; } else { if ($cl_type == CHART_CLIENTS) { - if (!in_array('cl', explode(',', $user->plugins))) + if (!$user->isPluginEnabled('cl')) $cl_type = CHART_PROJECTS; - } else if ($cl_type == CHART_TASKS) { + } elseif ($cl_type == CHART_TASKS) { if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) $cl_type = CHART_PROJECTS; } @@ -84,40 +84,40 @@ $_SESSION['chart_type'] = $cl_type; // Who do we draw charts for? $on_behalf_id = $request->getParameter('onBehalfUser', (isset($_SESSION['behalf_id'])? $_SESSION['behalf_id'] : $user->id)); -if ($request->getMethod( )== 'POST') { +if ($request->isPost()) { // If chart interval changed - save it. $cl_interval = $request->getParameter('interval'); if ($cl_interval) { - // Save in the session + // Save in the session $_SESSION['chart_interval'] = $cl_interval; // and permanently. - $sc = new ttSysConfig($user->id); + $sc = new ttSysConfig($user->id); $sc->setValue(SYSC_CHART_INTERVAL, $cl_interval); } - // If chart type changed - save it. + // If chart type changed - save it. $cl_type = $request->getParameter('type'); if ($cl_type) { // Save in the session $_SESSION['chart_type'] = $cl_type; // and permanently. $sc = new ttSysConfig($user->id); - $sc->setValue(SYSC_CHART_TYPE, $cl_type); + $sc->setValue(SYSC_CHART_TYPE, $cl_type); } // If user has changed - set behalf_id accordingly in the session. if ($request->getParameter('onBehalfUser')) { if($user->canManageTeam()) { unset($_SESSION['behalf_id']); unset($_SESSION['behalf_name']); - + if($on_behalf_id != $user->id) { $_SESSION['behalf_id'] = $on_behalf_id; - $_SESSION['behalf_name'] = ttUserHelper::getUserName($on_behalf_id); + $_SESSION['behalf_name'] = ttUserHelper::getUserName($on_behalf_id); } header('Location: charts.php'); exit(); } } -} +} // isPost // Elements of chartForm. $chart_form = new Form('chartForm'); @@ -139,10 +139,10 @@ if ($user->canManageTeam()) { // Chart interval options. $intervals = array(); -$intervals[INTERVAL_THIS_DAY] = $i18n->getKey('dropdown.this_day'); -$intervals[INTERVAL_THIS_WEEK] = $i18n->getKey('dropdown.this_week'); -$intervals[INTERVAL_THIS_MONTH] = $i18n->getKey('dropdown.this_month'); -$intervals[INTERVAL_THIS_YEAR] = $i18n->getKey('dropdown.this_year'); +$intervals[INTERVAL_THIS_DAY] = $i18n->getKey('dropdown.selected_day'); +$intervals[INTERVAL_THIS_WEEK] = $i18n->getKey('dropdown.selected_week'); +$intervals[INTERVAL_THIS_MONTH] = $i18n->getKey('dropdown.selected_month'); +$intervals[INTERVAL_THIS_YEAR] = $i18n->getKey('dropdown.selected_year'); $intervals[INTERVAL_ALL_TIME] = $i18n->getKey('dropdown.all_time'); // Chart interval dropdown. @@ -154,17 +154,16 @@ $chart_form->addInput(array('type' => 'combobox', )); // Chart type options. -$chart_selector = (MODE_PROJECTS_AND_TASKS == $user->tracking_mode - || in_array('cl', explode(',', $user->plugins))); +$chart_selector = (MODE_PROJECTS_AND_TASKS == $user->tracking_mode || $user->isPluginEnabled('cl')); if ($chart_selector) { $types = array(); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $types[CHART_PROJECTS] = $i18n->getKey('dropdown.projects'); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $types[CHART_TASKS] = $i18n->getKey('dropdown.tasks'); - if (in_array('cl', explode(',', $user->plugins))) + if ($user->isPluginEnabled('cl')) $types[CHART_CLIENTS] = $i18n->getKey('dropdown.clients'); - + // Add chart type dropdown. $chart_form->addInput(array('type' => 'combobox', 'onchange' => 'if(this.form) this.form.submit();', @@ -179,7 +178,7 @@ $chart_form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date) // Get data for our chart. $totals = ttChartHelper::getTotals($on_behalf_id, $cl_type, $cl_date, $cl_interval); -$smarty->assign('totals', $totals); +$smarty->assign('totals', $totals); // Prepare chart for drawing. /* @@ -188,7 +187,7 @@ $smarty->assign('totals', $totals); * auto-calculated percentage markers around it. We print labels (to the side of the picture) ourselves, * using the same colors libchart is using. For labels printout, the $totals array (which is used for picture points) * is also passed to charts.tpl Smarty template. - * + * * To make all of the above possible with only one database call to obtain $totals we have to print the chart image * to a file here (see code below). Once the image is available as a .png file, the charts.tpl can render it. *