From: cajus Date: Thu, 31 Jan 2008 16:24:58 +0000 (+0000) Subject: Updated to handle actions X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=940abfac1e10642726cd12e225feeecb905d2382;p=gosa.git Updated to handle actions git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8707 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc index 9ac6d7d1f..a94547aee 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc @@ -48,10 +48,8 @@ class termgeneric extends plugin var $objectclasses= array("top", "gotoTerminal", "GOhard"); var $mapActions = array("reboot" => "", - "instant_update" => "softupdate", - "update" => "sceduledupdate", - "reinstall" => "install", "rescan" => "", + "wake" => "", "memcheck" => "memcheck", "sysinfo" => "sysinfo"); @@ -168,77 +166,8 @@ class termgeneric extends plugin $this->is_account= !$this->is_account; } - if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ - - /* 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")); - $res = $ldap->fetch(); - - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } - - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - - if($attrs['FAIstate'] == ""){ -#FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); - } - - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn)); - } - - switch($_POST['saction']){ - case 'wake': - $cmd= $this->config->search("termgeneric", "WAKECMD",array('tabs')); - - if ($cmd == ""){ - print_red(_("No WAKECMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - } - break; - - case 'reboot': - $cmd= $this->config->search("termgeneric", "REBOOTCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No REBOOTCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->cn, $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - } - break; - - case 'halt': - $cmd= $this->config->search("termgeneric", "HALTCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No HALTCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->cn, $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - } - break; - } + if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->mapActions[$_POST['saction']])){ + gosaSupportDaemon::send("gosa_trigger_action_".$_POST['saction'], $this->netConfigDNS->ipHostNumber, array("macAddress" => $this->netConfigDNS->macAddress)); } /* Base select dialog */ diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc index 8b31f4329..b151d3a83 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc @@ -58,6 +58,7 @@ class workgeneric extends plugin "update" => "scheduledupdate", "reinstall" => "install", "rescan" => "", + "wake" => "", "memcheck" => "memcheck", "sysinfo" => "sysinfo"); @@ -180,15 +181,10 @@ class workgeneric extends plugin } } - if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate"))){ - $cmd= $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No ACTIONCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } elseif ($_POST['saction'] != "wake") { + if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){ + gosaSupportDaemon::send("gosa_trigger_action_".$_POST['saction'], $this->netConfigDNS->ipHostNumber, array("macAddress" => $this->netConfigDNS->macAddress)); + + if ($_POST['saction'] != "wake") { /* Set FAIstate */ if($this->fai_activated && $this->dn != "new"){ @@ -212,7 +208,7 @@ class workgeneric extends plugin } if($attrs['FAIstate'] == ""){ -#FIXME we should check if FAIobject is not used anymore + #FIXME we should check if FAIobject is not used anymore $attrs['FAIstate'] = array(); } @@ -223,7 +219,6 @@ class workgeneric extends plugin } $this->didAction= TRUE; } - } } /* Do we represent a valid terminal? */