From d60047b2a926685f18857fa77db5adde3cb7b09a Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 29 Feb 2008 10:02:01 +0000 Subject: [PATCH] Updated workstation class. -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 --- .../systems/goto/class_workstationGeneric.inc | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc index aa94042b3..30b45da1a 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc @@ -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")); -- 2.30.2