From aa79bcfe94876fda8819004efa44bba80660fb4e Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 2 Jun 2006 04:46:37 +0000 Subject: [PATCH] Added ability to save FAIstate while in execute git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3613 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_servGeneric.inc | 49 +++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index 1a4cc14f2..77377092c 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -28,14 +28,20 @@ class servgeneric extends plugin var $netConfigDNS; var $modes = array(); + var $mapActions = array("reboot" => "", + "instant_update" => "softupdate", + "update" => "sceduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); + function servgeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); $this->modes["active"]= _("Activated"); $this->modes["locked"]= _("Locked"); - $this->modes["memcheck"]= _("Memory test"); - $this->modes["sysinfo"]= _("System analysis"); /* Set base */ if ($this->dn == "new"){ @@ -65,14 +71,45 @@ class servgeneric extends plugin /* Check for action */ if (isset($_POST['action'])){ $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD"); + $cmd= "/bin/echo"; 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)); } else { $this->didAction= TRUE; + + /* Set FAIstate */ + $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 ++){ + if(($attrs['FAIstate'] == "") && ($res['objectClass'][$i] == "FAIobject")) continue; + $attrs['objectClass'][] = $res['objectClass'][$i]; + } + + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + + if($attrs['FAIstate'] == ""){ + $attrs['FAIstate'] = array(); + } + + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error()); } } } @@ -126,11 +163,15 @@ class servgeneric extends plugin "instant_update" => _("Instant update"), "update" => _("Scheduled update"), "reinstall" => _("Reinstall"), - "rescan" => _("Rescan hardware"))); + "rescan" => _("Rescan hardware"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); } else { $smarty->assign("actions", array("wake" => _("Wake up"), "reinstall" => _("Reinstall"), - "update" => _("Scheduled update"))); + "update" => _("Scheduled update"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); } /* Show main page */ -- 2.30.2