Code

Updated statistics plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Nov 2010 15:51:10 +0000 (15:51 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Nov 2010 15:51:10 +0000 (15:51 +0000)
-It requires a registration now

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20185 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/statistics/class_statistics.inc
gosa-core/plugins/generic/statistics/statistics.tpl

index 852c7ec6f925a0fcf077f8438b6fd5973e5f52b8..6947b85f64659031cde3d5c73c5ad1a3bc216bb4 100644 (file)
@@ -30,30 +30,37 @@ class statistics extends plugin
     {
         plugin::plugin($config, NULL);
 
-        $this->graphs[] = new categoryActionsOverTime($config); 
-        $this->graphs[] = new memoryUsageChart($config); 
-        $this->graphs[] = new cpuLoadChart($config); 
-        $this->graphs[] = new renderTimeChart($config); 
-        $this->graphs[] = new durationTimeChart($config); 
-        $this->graphs[] = new objectCountChart($config); 
-        $this->graphs[] = new actionSelectChart($config); 
-        $this->graphs[] = new passwordChangeChart($config); 
-        $this->staticChart1 = new pieChart1($config); 
-        $this->staticChart2 = new pieChart2($config); 
-
-        // Init start and stop times for graph 1
-        $this->graph1DatePicker1 = date('d.m.Y', time() - 28 * 24 * 60 *60);
-        $this->graph1DatePicker2 = date('d.m.Y', time());
-
-        // First try to retrieve values via RPC
-        $this->rpcConfigured = FALSE;
-        if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
-            $this->rpcConfigured = TRUE;
-            $this->rpcHandle = $this->config->getRpcHandle(
-                    "http://10.3.64.59:4000",
-                    "65717fe6-9e3e-11df-b010-5452005f1250",
-                    "WyukwauWoid2",
-                    TRUE);
+        // Detect registration status first
+        $this->registered = 
+            GOsaRegistration::isRegistered($config) && 
+            GOsaRegistration::getRegistrationType($config) == "registered";
+
+        if($registered){
+            $this->graphs[] = new categoryActionsOverTime($config); 
+            $this->graphs[] = new memoryUsageChart($config); 
+            $this->graphs[] = new cpuLoadChart($config); 
+            $this->graphs[] = new renderTimeChart($config); 
+            $this->graphs[] = new durationTimeChart($config); 
+            $this->graphs[] = new objectCountChart($config); 
+            $this->graphs[] = new actionSelectChart($config); 
+            $this->graphs[] = new passwordChangeChart($config); 
+            $this->staticChart1 = new pieChart1($config); 
+            $this->staticChart2 = new pieChart2($config); 
+
+            // Init start and stop times for graph 1
+            $this->graph1DatePicker1 = date('d.m.Y', time() - 28 * 24 * 60 *60);
+            $this->graph1DatePicker2 = date('d.m.Y', time());
+
+            // First try to retrieve values via RPC
+            $this->rpcConfigured = FALSE;
+            if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
+                $this->rpcConfigured = TRUE;
+                $this->rpcHandle = $this->config->getRpcHandle(
+                        "http://10.3.64.59:4000",
+                        "65717fe6-9e3e-11df-b010-5452005f1250",
+                        "WyukwauWoid2",
+                        TRUE);
+            }
         }
     }
 
@@ -130,6 +137,18 @@ class statistics extends plugin
     function execute()
     {
         $smarty = get_smarty();
+       
+        // Check registration status, we need at least 'registered'. 
+        $smarty->assign("registered", $this->registered);
+        if(!$this->registered){
+    
+            $plist = session::get('plist');
+            $id = array_search('dashBoard', $plist->pluginList);
+            $smarty->assign('dashBoardId', $id);
+            return($smarty->fetch(get_template_path('statistics.tpl', TRUE)));
+        }
+
         $smarty->assign('graph1DatePicker1', $this->graph1DatePicker1);
         $smarty->assign('graph1DatePicker2', $this->graph1DatePicker2);
 
@@ -401,6 +420,9 @@ class statistics extends plugin
 
     function save_object()
     {
+        // Nothing to do for not registered accounts.
+        if(!$this->registered) return;
+
         plugin::save_object();
         if(isset($_POST['graph1DatePicker1'])) $this->graph1DatePicker1 = get_post('graph1DatePicker1');
         if(isset($_POST['graph1DatePicker2'])) $this->graph1DatePicker2 = get_post('graph1DatePicker2');
index 670bc8f5a5f0fdc29955a2540b9223af35efa857..166863164243b49a3effdcb7fbd16f5cd84dfc59 100644 (file)
@@ -1,7 +1,12 @@
 
 <h3>{t}Usage statistics{/t}</h3>
+{if !$registered}
 
-{if !$rpcConfigured}
+    {t}This feature is disabled. To enable it you have to register GOsa, you can initiate a registration using the dash-board plugin.{/t}
+
+    <button type='button' onClick="openPlugin({$dashBoardId});">{t}Dash board{/t}</button>
+
+{else if !$rpcConfigured}
 
     {t}This feature is disabled. To enable it you can use the GOsa properties plugin, just activate the remote procedure call (RPC) configuration flags.{/t}