X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servGeneric.inc;h=38bcccb65473bf55e68656c26b026aa0bf8edef6;hb=e646d1b091e3d40c67039125dae867faa6fdd402;hp=ad47160ae20dd94661829b64007c72ecead3fe0e;hpb=63b9e701de6039ce487df1e9ef00399e02721a7c;p=gosa.git diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index ad47160ae..38bcccb65 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -17,6 +17,7 @@ class servgeneric extends plugin var $l= ""; var $description= ""; var $orig_dn= ""; + var $didAction= FALSE; /* attribute list for save action */ var $attributes= array("cn", "description","gotoMode"); @@ -27,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"){ @@ -51,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){ @@ -63,42 +70,46 @@ 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"; + } + + if($attrs['FAIstate'] == ""){ + #FIXME we should check if FAIobject is used anymore + $attrs['FAIstate'] = array(); } - break; + + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic (FAIstate) with dn '%s' failed."),$this->dn)); + } } } @@ -107,7 +118,7 @@ class servgeneric extends plugin foreach($_POST as $name => $value){ if(preg_match("/^chooseBase/",$name) && $once){ $once = false; - $this->dialog = new baseSelectDialog($this->config); + $this->dialog = new baseSelectDialog($this->config,$this); $this->dialog->setCurrentBase($this->base); } } @@ -136,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); @@ -149,11 +162,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 */ @@ -168,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(), sprintf(_("Removing of system server/generic with dn '%s' failed."),$this->dn)); /* Delete references to object groups */ $ldap->cd ($this->config->current['BASE']); @@ -178,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)); } @@ -276,18 +293,41 @@ 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(), sprintf(_("Saving of system server/generic with dn '%s' failed."),$this->dn)); $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); + } } + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Server generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("server" => array("description" => _("Server"), + "objectClass" => "gotoWorkstation")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "description" => _("Description"), + "gotoMode" => _("Goto mode"), + "base" => _("Base"), + "FAIstate" => _("Action flag")) + )); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: