Code

Robustness for empty queues
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Jan 2008 08:15:42 +0000 (08:15 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Jan 2008 08:15:42 +0000 (08:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8645 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_gosaSupportDaemon.inc
gosa-core/plugins/addons/gotomasses/class_gotomasses.inc

index bd5766367ee305c232871cf84c555580121b76ba..98b568701a99f042a045e1ee26312fa40146d59d 100644 (file)
@@ -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); 
   }
 
index d3b15f2a7cca3fd50d2327a20c4c9f32c5f35667..75b40f62ffd80ffa996a8632f4a725c539977504 100644 (file)
@@ -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"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
+      if ($this->o_queue->get_error()){
+        msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
+      }
       return(array());
     }