X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servGeneric.inc;h=9c0f48cd1f442c63d0434f2fffc556b7810f816f;hb=78fd52f682986d25fb95c171757d58384f7f58f8;hp=9252d16a969a181f0935a791947f6c4aee1069a5;hpb=2304649c2c57b79131339b8bd6fa6359a87de877;p=gosa.git diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index 9252d16a9..9c0f48cd1 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -17,17 +17,32 @@ class servgeneric extends plugin var $l= ""; var $description= ""; var $orig_dn= ""; + var $didAction= FALSE; /* attribute list for save action */ - var $attributes= array("cn", "description"); - var $objectclasses= array("top", "goServer"); + var $attributes= array("cn", "description","gotoMode"); + var $objectclasses= array("top", "GOhard", "goServer"); + + var $gotoMode= "locked"; 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"); + /* Set base */ if ($this->dn == "new"){ $ui= get_userinfo(); @@ -43,8 +58,8 @@ class servgeneric extends plugin 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){ @@ -55,42 +70,71 @@ class servgeneric extends plugin /* 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()); + } + } + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + $this->base = $this->dialog->isSelected(); + $this->dialog= false; + }else{ + return($this->dialog->execute()); } } @@ -103,6 +147,8 @@ class servgeneric extends plugin $smarty->assign($attr."ACL", chkacl($this->acl, $attr)); $smarty->assign("$attr", $this->$attr); } + $smarty->assign("baseACL", chkacl($this->acl, "base")); + $smarty->assign("staticAddress", ""); $smarty->assign("base_select", $this->base); @@ -112,14 +158,24 @@ class servgeneric extends plugin /* Offline */ if ($retval == 0){ - $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"))); + $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), + "instant_update" => _("Instant update"), + "update" => _("Scheduled update"), + "reinstall" => _("Reinstall"), + "rescan" => _("Rescan hardware"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); } else { - $smarty->assign("actions", array("wake" => _("Wake up"))); + $smarty->assign("actions", array("wake" => _("Wake up"), + "reinstall" => _("Reinstall"), + "update" => _("Scheduled update"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); } - /* Show main page */ $smarty->assign("netconfig", $this->netConfigDNS->execute()); + $smarty->assign("modes", $this->modes); return($smarty->fetch (get_template_path('server.tpl', TRUE))); } @@ -129,7 +185,7 @@ class servgeneric extends plugin $this->netConfigDNS->remove_from_parent(); $ldap= $this->config->get_ldap_link(); $ldap->rmdir($this->dn); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Removing server failed")); /* Delete references to object groups */ $ldap->cd ($this->config->current['BASE']); @@ -139,7 +195,7 @@ class servgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->handle_post_events("remove"); + $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress)); } @@ -158,7 +214,9 @@ class servgeneric extends plugin /* Check supplied data */ function check() { - $message= $this->netConfigDNS->check(); + /* Call common method to give check the hook */ + $message= plugin::check(); + $message= array_merge($message, $this->netConfigDNS->check()); $this->dn= "cn=".$this->cn.",ou=servers,ou=systems,".$this->base; /* must: cn */ @@ -235,16 +293,18 @@ class servgeneric extends plugin $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + $ldap->modify ($this->attrs); $mode= "modify"; } + show_ldap_error($ldap->get_error(), _("Saving server failed")); $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); - show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ - $this->handle_post_events($mode); + if(!$this->didAction){ + $this->handle_post_events($mode); + } } }