Code

Updated server class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Feb 2008 10:00:39 +0000 (10:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Feb 2008 10:00:39 +0000 (10:00 +0000)
-Action will be send to gosa-si with the event classes now.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9203 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/systems/admin/systems/class_servGeneric.inc

index a111d7cc9d30d3dc1ff5a5f18b86214ae1a7b041..bd48ff0b8b67bd4d4bb6b5bde4953552e90f8660 100644 (file)
@@ -104,14 +104,49 @@ class servgeneric extends plugin
       return($display);
     }
 
-    /* Check for action */
+
+
     if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){
+
+      /* Check given action */
+      $mapEvent = array("wake"           => "wakeup",
+                        "instant_update" => "update");
+      $action = $_POST['saction'];
+      if(isset($mapEvent[$action])){
+        $action = $mapEvent[$action];
+      }
+
+      /* Check if we have an DaemonEvent for this action */
+      if(class_available("DaemonEvent_".$action)){
+        $events = DaemonEvent::get_event_types();
+        if(isset($events['BY_CLASS']["DaemonEvent_".$action])){
+          $evt = $events['BY_CLASS']["DaemonEvent_".$action];
+          $tmp = new $evt['CLASS_NAME']($this->config);
+          $tmp->add_targets(array($this->netConfigDNS->macAddress));
+          $tmp->set_type(TRIGGERED_EVENT);
+          $o_queue = new gosaSupportDaemon();
+          if(!$o_queue->append($tmp)){
+            msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+                  $o_queue->get_error()),ERROR_DIALOG);
+          }
+        }
+      }else{
+
+        msg_dialog::display(_("Missing Daemon Event"),
+                    sprintf(_("The requested action does not exists '%s' Sending event manually."),"DaemonEvent_".$action),ERROR_DIALOG);
+
+        /* No event found, send action manually.
+         */
         $method= "gosa";
         $action= $_POST['saction'];
-       if ($action == "reinstall" || $action == "update" || $action == "instant_update"){
-                $method= "job";
+        if ($action == "reinstall" || $action == "update" || $action == "instant_update"){
+          $method= "job";
         }
-        gosaSupportDaemon::send("${method}_trigger_action_".$action, $this->netConfigDNS->macAddress, array("macAddress" => $this->netConfigDNS->macAddress));
+
+        gosaSupportDaemon::send("${method}_trigger_action_".$action,
+            $this->netConfigDNS->macAddress,
+            array("macAddress" => $this->netConfigDNS->macAddress));
+      }
 
       $this->didAction= TRUE;