Code

msgPool
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index 7d2ec9751b459b45e5de4706dfba9c20fd9af7a4..a6e1c410f0de0ed3de5f8c19a146e1f98412f291 100644 (file)
@@ -184,6 +184,9 @@ $xml_msg.= "
       }
     }
     
+    /* Remove session ID. No one is interested in this... */
+    unset($ret['SESSION_ID']);
+
     return($ret);
   }
 
@@ -235,6 +238,53 @@ $xml_msg.= "
   }
 
 
+  /*! \brief  Returns an entry containing all requested ids.
+    @param  Array   The IDs of the entries we want to return.
+    @return Array   Of the requested entries. 
+   */
+  public function get_entries_by_mac($macs)
+  {
+    if(!is_array($macs)){
+      trigger_error("Requires an array as parameter.");
+      return;
+    }
+    $this->reset_error();
+
+    $ret = array();
+
+    $xml_msg = "<xml>
+      <header>gosa_query_jobdb</header>
+      <target>GOSA</target>
+      <source>GOSA</source>
+      <where>
+      <clause>
+      <connector>or</connector>";
+    foreach($macs as $mac){
+      $xml_msg .= "<phrase>
+        <operator>eq</operator>
+        <macaddress>".$mac."</macaddress>
+        </phrase>";
+    }
+    $xml_msg .= "</clause>
+      </where>
+      </xml>";
+
+    if($this->connect()){
+      $this->o_sock->write($xml_msg);
+      $str = trim($this->o_sock->read());
+      $entries = $this->xml_to_array($str); 
+      if(isset($entries['XML'])){
+        foreach($entries['XML'] as $name => $entry){
+          if(preg_match("/^ANSWER[0-9]*$/",$name)){
+            $ret[$name] = $entry;
+          }
+        }
+      }
+    }
+    return($ret);
+  }
+
+
   /*! \brief  Returns an entry containing all requested ids.
     @param  Array   The IDs of the entries we want to return.
     @return Array   Of the requested entries. 
@@ -461,7 +511,7 @@ $xml_msg.= "
 
     if(!isset($params['XML'])){
       if (!array_key_exists('XML', $params)){
-        $this->set_error(_("Could not parse XML."));
+        $this->set_error(_("Cannot not parse XML!"));
       }
       $params = array("COUNT" => 0);
     }
@@ -606,7 +656,6 @@ $xml_msg.= "
       $request_answer = FALSE;
       if($event->get_type() == SCHEDULED_EVENT){
         $action = $event->get_schedule_action();
-        $request_answer = TRUE;
       }elseif($event->get_type() == TRIGGERED_EVENT){
         $action = $event->get_trigger_action();
       }else{
@@ -718,20 +767,7 @@ $xml_msg.= "
     /* First of all we have to check which jobs are startet 
      *  for $mac 
      */
-    $xml_msg ="
-      <xml>
-       <header>gosa_query_jobdb</header>
-       <target>GOSA</target>
-       <source>GOSA</source>
-       <where>
-        <clause>
-         <phrase>
-          <macaddress>".$mac."</macaddress>
-         </phrase>
-        </clause>
-       </where>
-      </xml>
-    ";  
+    $xml_msg ="<xml><header>gosa_query_jobdb</header><target>GOSA</target><source>GOSA</source><where><clause><phrase><macaddress>".$mac."</macaddress></phrase></clause></where></xml>";  
     
     new log("debug","DaemonEvent ", "gosaSupportDaemon::clean_queue_from_mac()", array($mac => $mac)," start cleaning.");
  
@@ -755,7 +791,7 @@ $xml_msg.= "
                 $tmp->add_targets(array($mac));
                 $tmp->set_type(TRIGGERED_EVENT);
                 if(!$this->append($tmp)){
-                  msg_dialog::display(_("Error"), sprintf(_("Cannot send abort event for entry: %s"),$entry['ID']) , ERROR_DIALOG);
+                  msg_dialog::display(_("Error"), sprintf(_("Cannot send abort event for entry %s!"),$entry['ID']) , ERROR_DIALOG);
                   new log("debug","DaemonEvent ", "gosaSupportDaemon::clean_queue_from_mac()", array($mac => $mac),
                       "FAILED, could not send 'DaemonEvent_faireboot' for entry ID (".$entry['ID'].") - ".$this->get_error());
                 }else{
@@ -775,7 +811,7 @@ $xml_msg.= "
                *  Failed or waiting events, can be removed without any trouble.
                */ 
               if(!$this->remove_entries(array($entry['ID']))){
-                msg_dialog::display(_("Error"), sprintf(_("Cannot remove entry: %s"),$entry['ID']) , ERROR_DIALOG);
+                msg_dialog::display(_("Error"), sprintf(_("Cannot remove entry %s!"),$entry['ID']) , ERROR_DIALOG);
               }
               ;break;
           }