diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc
index a28ed75b7143a9f1e2cfab8db4d832f859bdf5e0..d9e946a14cbf8b60c4fe7c1fcf8a35114b8371e4 100644 (file)
var $l= "";
var $description= "";
var $orig_dn= "";
var $l= "";
var $description= "";
var $orig_dn= "";
+ var $didAction= FALSE;
/* attribute list for save action */
var $attributes= array("cn", "description","gotoMode");
/* attribute list for save action */
var $attributes= array("cn", "description","gotoMode");
var $netConfigDNS;
var $modes = array();
var $netConfigDNS;
var $modes = array();
- function servgeneric ($config, $dn= NULL)
+ var $mapActions = array("reboot" => "",
+ "instant_update" => "softupdate",
+ "update" => "sceduledupdate",
+ "reinstall" => "install",
+ "rescan" => "",
+ "memcheck" => "memcheck",
+ "sysinfo" => "sysinfo");
+
+ function servgeneric ($config, $dn= NULL, $parent= NULL)
{
{
- plugin::plugin ($config, $dn);
+ plugin::plugin ($config, $dn, $parent);
$this->modes["active"]= _("Activated");
$this->modes["locked"]= _("Locked");
$this->modes["active"]= _("Activated");
$this->modes["locked"]= _("Locked");
- $this->modes["memcheck"]= _("Memory test");
- $this->modes["sysinfo"]= _("System analysis");
/* Set base */
if ($this->dn == "new"){
/* Set base */
if ($this->dn == "new"){
function execute()
{
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
/* Do we represent a valid server? */
if (!$this->is_account && $this->parent == NULL){
/* Do we represent a valid server? */
if (!$this->is_account && $this->parent == NULL){
/* Check for action */
if (isset($_POST['action'])){
/* Check for action */
if (isset($_POST['action'])){
- switch($_POST['action']){
- case 'wake':
- $cmd= search_config($this->config->data['TABS'], "servgeneric", "WAKECMD");
- 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));
- }
+ $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD");
+ 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']];
}
}
- break;
-
- case 'reboot':
- $cmd= search_config($this->config->data['TABS'], "servgeneric", "REBOOTCMD");
- 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));
- }
+
+ for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
+ $attrs['objectClass'][] = $res['objectClass'][$i];
}
}
- break;
-
- case 'halt':
- $cmd= search_config($this->config->data['TABS'], "servgeneric", "HALTCMD");
- 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));
- }
+
+ if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+ $attrs['objectClass'][] = "FAIobject";
}
}
- break;
+
+ 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());
+ }
}
}
}
}
"instant_update" => _("Instant update"),
"update" => _("Scheduled update"),
"reinstall" => _("Reinstall"),
"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"),
} 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 */
}
/* Show main page */
$mode= "modify";
}
$mode= "modify";
}
+ show_ldap_error($ldap->get_error(), _("Saving server failed"));
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->save($this->dn);
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->save($this->dn);
- show_ldap_error($ldap->get_error(), _("Saving server failed"));
/* Optionally execute a command after we're done */
/* Optionally execute a command after we're done */
- $this->handle_post_events($mode);
+ if(!$this->didAction){
+ $this->handle_post_events($mode);
+ }
}
}
}
}