]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttChartHelper.class.php
Adjusted charts.php for subgroups.
[timetracker.git] / WEB-INF / lib / ttChartHelper.class.php
index 75a38d072908439dc0661a59b8f8f4825dfda754..7a4d25843258ccf0c2cf2371a8e1ce35b7647340 100644 (file)
@@ -132,4 +132,39 @@ class ttChartHelper {
 
     return $result;
   }
+
+  // adjustType - adjust chart type to something that is available for a group.
+  static function adjustType($requested_type) {
+    global $user;
+    $tracking_mode = $user->getTrackingMode();
+    $client_option = $user->isPluginEnabled('cl');
+
+    // We have 3 possible options for chart tyep: projects, tasks, or clients.
+    // Deal with each one individually.
+
+    if ($requested_type == CHART_PROJECTS) {
+      if ($tracking_mode == MODE_PROJECTS || $tracking_mode == MODE_PROJECTS_AND_TASKS)
+        return CHART_PROJECTS;
+      else if ($client_option)
+        return CHART_CLIENTS;
+    }
+
+    if ($requested_type == CHART_TASKS) {
+      if ($tracking_mode == MODE_PROJECTS_AND_TASKS)
+        return CHART_TASKS;
+      if ($tracking_mode == MODE_PROJECTS)
+        return CHART_PROJECTS;
+      else if ($client_option)
+        return CHART_CLIENTS;
+    }
+
+    if ($requested_type == CHART_CLIENTS) {
+      if ($client_option)
+        return CHART_CLIENTS;
+      else if ($tracking_mode == MODE_PROJECTS || ($tracking_mode == MODE_PROJECTS_AND_TASKS))
+        return CHART_PROJECTS;
+    }
+
+    return  CHART_PROJECTS;
+  }
 }