Code

Updated event handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Feb 2008 14:52:17 +0000 (14:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Feb 2008 14:52:17 +0000 (14:52 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9216 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc
gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc
gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc
gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc

index dce8cdfb4b8e2130a3fb949d15fd5f914c5edd77..cb7b2eafe04ccc98075c6130a22412ef96229010 100644 (file)
@@ -169,12 +169,48 @@ class termgeneric extends plugin
     }
 
     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";
+          $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));
+      }
     }
 
     /* Base select dialog */
@@ -511,8 +547,21 @@ class termgeneric extends plugin
     $this->netConfigDNS->save();
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn));
 
+    /* Send installation activation
+     */
     if ($activate){
-      gosaSupportDaemon::send("gosa_set_activated_for_installation", $this->netConfigDNS->ipHostNumber);
+      $events = DaemonEvent::get_event_types();
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['BY_CLASS']['DaemonEvent_installation_activation'])){
+        $evt = $events['BY_CLASS']['DaemonEvent_installation_activation'];
+        $tmp = new $evt['CLASS_NAME']($this->config);
+        $tmp->set_type(TRIGGERED_EVENT);
+        $tmp->add_targets(array($this->netConfigDNS->macAddress));
+        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);
+        }
+      }
     }
   }
 
index da458705eded97378e373ca65f539fc8f9bcce7c..388d35840bb19786b23d904761a0721be47ae499 100644 (file)
@@ -448,8 +448,22 @@ class termstartup extends plugin
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/startup with dn '%s' failed."),$this->dn));
     $this->handle_post_events("modify");
 
+    /* Send ldap configuration update
+     */
     if ($ldap_changed){
-        gosaSupportDaemon::send("gosa_reload_ldap_config", $this->parent->by_object['termgeneric']->netConfigDNS->macAddress);
+      $events = DaemonEvent::get_event_types();
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['BY_CLASS']['DaemonEvent_reload_ldap_config'])){
+        $evt = $events['BY_CLASS']['DaemonEvent_reload_ldap_config'];
+        $tmp = new $evt['CLASS_NAME']($this->config);
+        $tmp->set_type(TRIGGERED_EVENT);
+        $tmp->add_targets(array($this->netConfigDNS->macAddress));
+        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);
+        }
+      }
     }
   }
 
index 09915e9e071ce14dd864d2273b98073827e3421a..0d8175d71e9c9e9c550ae9791180a2e52d2c159f 100644 (file)
@@ -599,7 +599,21 @@ class workgeneric extends plugin
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn));
 
     if ($activate){
-      gosaSupportDaemon::send("gosa_set_activated_for_installation", $this->netConfigDNS->macAddress);
+
+      /* Send installation activation
+       */
+      $events = DaemonEvent::get_event_types();
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['BY_CLASS']['DaemonEvent_installation_activation'])){
+        $evt = $events['BY_CLASS']['DaemonEvent_installation_activation'];
+        $tmp = new $evt['CLASS_NAME']($this->config);
+        $tmp->set_type(TRIGGERED_EVENT);
+        $tmp->add_targets(array($this->netConfigDNS->macAddress));
+        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);
+        }
+      }
     }
   }
 
index 06a1223ba218220ceb7cf4559dfd9dd5408aed73..9571b208bed97e52380b986e4cbac60ec4237ddd 100644 (file)
@@ -903,9 +903,19 @@ class workstartup extends plugin
 
     /* Check if LDAP server has changed */
     if ($ldap_changed){
-      gosaSupportDaemon::send("gosa_reload_ldap_config", $this->parent->by_object['workgeneric']->netConfigDNS->macAddress);
+      $events = DaemonEvent::get_event_types();
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['BY_CLASS']['DaemonEvent_reload_ldap_config'])){
+        $evt = $events['BY_CLASS']['DaemonEvent_reload_ldap_config'];
+        $tmp = new $evt['CLASS_NAME']($this->config);
+        $tmp->set_type(TRIGGERED_EVENT);
+        $tmp->add_targets(array($this->netConfigDNS->macAddress));
+        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);
+        }
+      }
     }
-
   }