From e4bde156099ef542d9804511b578a27da0f16b56 Mon Sep 17 00:00:00 2001 From: cajus Date: Wed, 30 Jan 2008 08:15:42 +0000 Subject: [PATCH] Robustness for empty queues git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8645 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_gosaSupportDaemon.inc | 32 ++++++++++--------- .../addons/gotomasses/class_gotomasses.inc | 4 ++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc index bd5766367..98b568701 100644 --- a/gosa-core/include/class_gosaSupportDaemon.inc +++ b/gosa-core/include/class_gosaSupportDaemon.inc @@ -41,9 +41,9 @@ Function overview: class gosaSupportDaemon { - static private $s_host = ""; - static private $i_port = 0; - static private $s_encryption_key = ""; + private $s_host = ""; + private $i_port = 0; + private $s_encryption_key = ""; private $o_sock = NULL; private $f_timeout = 2; @@ -68,14 +68,10 @@ class gosaSupportDaemon # load from config, store statically if (isset($config->current['GOSA_SI'])){ - if (gosaSupportDaemon::$s_host == ""){ - $host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->current['GOSA_SI']); - $port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->current['GOSA_SI']); - $key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->current['GOSA_SI']); - - gosaSupportDaemon::$s_host = $host; - gosaSupportDaemon::$i_port = $port; - gosaSupportDaemon::$s_encryption_key = $key; + if ($this->s_host == ""){ + $this->s_host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->current['GOSA_SI']); + $this->i_port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->current['GOSA_SI']); + $this->s_encryption_key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->current['GOSA_SI']); } $this->f_timeout = $timeout; @@ -91,9 +87,9 @@ class gosaSupportDaemon */ public function connect() { - $this->o_sock = new Socket_Client(gosaSupportDaemon::$s_host,gosaSupportDaemon::$i_port,TRUE,$this->f_timeout); + $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout); if($this->o_sock->connected()){ - $this->o_sock->setEncryptionKey(gosaSupportDaemon::$s_encryption_key); + $this->o_sock->setEncryptionKey($this->s_encryption_key); $this->is_connected = TRUE; }else{ $this->error = $this->o_sock->get_error(); @@ -174,9 +170,11 @@ class gosaSupportDaemon $ret = $entries; } } + return($ret); } + /*! \brief Checks if the given ids are used queue ids. @param Array The ids we want to check.. @return Array An array containing all ids as index and TRUE/FALSE as value. @@ -452,10 +450,14 @@ class gosaSupportDaemon } } } + if(!isset($params['XML'])){ - $this->set_error(_("Could not parse XML.")); - $params = array(); + if (!array_key_exists('XML', $params)){ + $this->set_error(_("Could not parse XML.")); + } + $params = array("COUNT" => 0); } + return($params); } diff --git a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc index d3b15f2a7..75b40f62f 100644 --- a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc +++ b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc @@ -361,7 +361,9 @@ class gotomasses extends plugin $stop = $this->range; $entries = $this->o_queue->get_queued_entries($start,$stop,$sort); if(!is_array($entries) || !isset($entries['XML']) || !is_array($entries['XML'])){ - msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "

".$this->o_queue->get_error()), ERROR_DIALOG); + if ($this->o_queue->get_error()){ + msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "

".$this->o_queue->get_error()), ERROR_DIALOG); + } return(array()); } -- 2.30.2