From 09bf1c75a2471eba087cc7c77a9a96bfd9bb8b9f Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 4 Nov 2010 15:51:10 +0000 Subject: [PATCH] Updated statistics plugin -It requires a registration now git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20185 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../generic/statistics/class_statistics.inc | 70 ++++++++++++------- .../plugins/generic/statistics/statistics.tpl | 7 +- 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/gosa-core/plugins/generic/statistics/class_statistics.inc b/gosa-core/plugins/generic/statistics/class_statistics.inc index 852c7ec6f..6947b85f6 100644 --- a/gosa-core/plugins/generic/statistics/class_statistics.inc +++ b/gosa-core/plugins/generic/statistics/class_statistics.inc @@ -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'); diff --git a/gosa-core/plugins/generic/statistics/statistics.tpl b/gosa-core/plugins/generic/statistics/statistics.tpl index 670bc8f5a..166863164 100644 --- a/gosa-core/plugins/generic/statistics/statistics.tpl +++ b/gosa-core/plugins/generic/statistics/statistics.tpl @@ -1,7 +1,12 @@

{t}Usage statistics{/t}

+{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} + + + +{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} -- 2.30.2