Code

Don not't reset server settings, if gosa.conf was modified
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index 23f6b3518794db2f1eadff308636226d1975e871..2f619e84ed0647dfc27a8ecd5e2fdef544dddd95 100644 (file)
@@ -31,10 +31,20 @@ class gosaSupportDaemon
   private $s_error      = "";
   private $b_error      = FALSE;
 
-  private $is_connected     = FALSE;
-
+  private $is_connected   = FALSE;
+  private $is_configured  = FALSE;
   protected $use_alternative_xml_parse_method = FALSE;
 
+  public function get_host()
+  {
+    return($this->s_host);
+  }
+
+  public function get_port()
+  {
+    return($this->i_port);
+  }
+
   /*! \brief  Creates a new gosaSupportDaemon object.
     @param string   Host    The Host where the daemon is running on.  
     @param integer  Port    The port which the daemon use.
@@ -60,7 +70,7 @@ class gosaSupportDaemon
         $this->i_port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->get_cfg_value("gosaSupportURI"));
         $this->s_encryption_key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->get_cfg_value("gosaSupportURI"));
       }
-
+      $this->is_configured = TRUE;
       $this->f_timeout = $timeout;
       if($connect){
         $this->connect();
@@ -69,6 +79,12 @@ class gosaSupportDaemon
   }
 
 
+  public function is_configured()
+  {
+    return($this->is_configured);
+  }
+
+
   /*! \brief  Establish daemon connection. 
     @return boolean Returns true if the connection was succesfully established. 
    */
@@ -106,17 +122,26 @@ class gosaSupportDaemon
     $data = array("module_name" => $mod);
     $res = $this->send_data("gosa_get_hosts_with_module",$this->s_host.":".$this->i_port,$data,TRUE);
     $hosts = array();
-    if(isset($res['XML'])){
+    if(isset($res['XML'][0])){
       foreach($res['XML'][0] as $name => $data){
         if(preg_match("/^ANSWER[0-9]*$/",$name)){
-          if(isset($data[0]['MAC'][0]['VALUE'])){
+          if(isset($data[0]['MAC'][0]['VALUE']) && $data[0]['MAC'][0]['VALUE'] != ""){
             $hosts[] = $data[0]['MAC'][0]['VALUE'];
-          }elseif(isset($data[0]['VALUE'])){
-            $hosts[] = $data[0]['VALUE'];
+          } elseif(isset($data[0]['IP'][0]['VALUE']) && $data[0]['IP'][0]['VALUE'] != "") {
+            $hosts[] = $data[0]['IP'][0]['VALUE'];
           }
         }
       }
     }
+
+    if(count($hosts) == 0){
+      @DEBUG(DEBUG_SI, __LINE__, "<b>".__CLASS__."::".__FUNCTION__."</b>" , 
+        __FILE__, "<font color='red'><i>Found: 0</i></font>", $info=$mod);
+    }else{
+      @DEBUG(DEBUG_SI, __LINE__, "<b>".__CLASS__."::".__FUNCTION__."</b>" , 
+        __FILE__, "<i>Found: ".count($hosts)."</i>", $info=$mod);
+    }
+
     return($hosts);
   }
 
@@ -196,7 +221,7 @@ class gosaSupportDaemon
         $ret .= $msg." ";
       }
     }
-    $ret = preg_replace("/ /","&nbsp;",$ret);
+    $ret = str_replace(" ","&nbsp;",$ret);
     return($ret);
   }
 
@@ -932,7 +957,7 @@ class gosaSupportDaemon
 
   /* Allows simply appending a new DaemonEvent 
    */
-  public function append($event)
+  public function append($event, $skip_add_mac = FALSE)
   {
     if(!($event instanceof DaemonEvent)){
       return(FALSE);
@@ -961,7 +986,9 @@ class gosaSupportDaemon
       /* Append an entry for each target 
        */
       foreach($targets as $target){
-        $data['macaddress'] = $target;
+        if(!$skip_add_mac){
+          $data['macaddress'] = $target;
+        }
         $this->send_data($action,$target,$data,$request_answer);
 
         if($this->is_error()){
@@ -1470,7 +1497,7 @@ class gosaSupportDaemon
    */
   public function krb5_get_policy($server,$name)
   {
-    $res = array();  
+    $ret = array();  
 
     /* Check if the given name is a valid request value 
      */
@@ -1838,7 +1865,7 @@ class gosaSupportDaemon
         There may be some Header lines like:
         -----BEGIN PGP PUBLIC KEY BLOCK-----   Version: GnuPG v1.4.6 (GNU/Linux)
      */
-    if(preg_match("/".normalizePreg("BEGIN PGP PUBLIC KEY BLOCK")."/",$key)){
+    if(preg_match("/BEGIN PGP PUBLIC KEY BLOCK/",$key)){
 
       /* Remove header */
       $key = preg_replace("/^.*\n\n/sim","",$key);