Code

Updated workstation class.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Feb 2008 10:02:01 +0000 (10:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Feb 2008 10:02:01 +0000 (10:02 +0000)
-Actions will be send to gosa-si with the DaemonEvent classes.

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

gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc

index aa94042b3b41d48d55073c7aa64aa7f4ffaa82b7..30b45da1aaf3bf69dd65442eb58cae72a061722f 100644 (file)
@@ -183,17 +183,52 @@ class workgeneric extends plugin
     }
 
     if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){
-       $method= "gosa";
-       $action= $_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";
-       }
-       gosaSupportDaemon::send("${method}_trigger_action_".$action, $this->netConfigDNS->macAddress, array("macAddress" => $this->netConfigDNS->macAddress));
+          $method= "job";
+        }
+
+        gosaSupportDaemon::send("${method}_trigger_action_".$action,
+            $this->netConfigDNS->macAddress,
+            array("macAddress" => $this->netConfigDNS->macAddress));
+      }
+
 
-        if ($action != "wake") {
+      if ($action != "wake") {
 
-          /* Set FAIstate */
-          if($this->fai_activated && $this->dn != "new"){
+        /* Set FAIstate */
+        if($this->fai_activated && $this->dn != "new"){
             $ldap = $this->config->get_ldap_link();
             $ldap->cd($this->config->current['BASE']);
             $ldap->cat($this->dn,array("objectClass"));