diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc
index 9ac6d7d1f5278980aed38507e8c2a31d995b85ec..7928972f7d3260bdbaa9749405be9e00a9cc511f 100644 (file)
class termgeneric extends plugin
{
- /* CLI vars */
- var $cli_summary= "Manage terminal base objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* Generic terminal attributes */
var $gotoMode= "locked";
var $gotoTerminalPath= "";
var $ghSoundAdapter= "-";
var $gotoLastUser= "-";
var $netConfigDNS;
+
/* Needed values and lists */
var $base= "";
var $cn= "";
+ var $description= "";
var $orig_dn= "";
var $inheritTimeServer = true;
var $attributes= array("gotoMode", "gotoTerminalPath",
"gotoSwapServer", "gotoSyslogServer", "gotoNtpServer",
"gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
- "ghCpuType", "ghMemSize","ghUsbSupport",
+ "ghCpuType", "ghMemSize","ghUsbSupport", "description",
"ghGfxAdapter", "ghSoundAdapter", "gotoLastUser");
var $objectclasses= array("top", "gotoTerminal", "GOhard");
- var $mapActions = array("reboot" => "",
- "instant_update" => "softupdate",
- "update" => "sceduledupdate",
- "reinstall" => "install",
- "rescan" => "",
- "memcheck" => "memcheck",
- "sysinfo" => "sysinfo");
+ var $validActions = array("reboot" => "", "rescan" => "", "wake" => "", "memcheck" => "", "sysinfo" => "");
var $fai_activated = FALSE;
var $view_logged = FALSE;
$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();
+ if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->validActions[$_POST['saction']])){
+ $action = $_POST['saction'];
+
+ /* Check if we have an DaemonEvent for this action */
+ if(class_available("DaemonEvent_".$action)){
+ $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+ if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
+ $evt = $events['TRIGGERED']["DaemonEvent_".$action];
+ $tmp = new $evt['CLASS_NAME']($this->config);
+ $tmp->add_targets(array($this->netConfigDNS->macAddress));
+ $tmp->set_type(TRIGGERED_EVENT);
+ $o_queue = new gosaSupportDaemon();
+ if(!$o_queue->append($tmp)){
+ msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+ $o_queue->get_error()),ERROR_DIALOG);
+ }
}
-
- $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));
+ }else{
+ msg_dialog::display(_("Event error"),
+ sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
}
- 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;
- }
}
/* Base select dialog */
}
$smarty->assign("cn", $this->cn);
+ $smarty->assign("description", $this->description);
$smarty->assign("staticAddress", "");
$smarty->assign("bases", $this->get_allowed_bases());
$smarty->assign("inheritTimeServer",$this->inheritTimeServer);
/* Check if terminal is online */
- $query= "fping -q -r 1 -t 500 ".$this->cn;
- exec ($query, $dummy, $retval);
-
- /* Offline */
- if ($retval == 0){
+ if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
$smarty->assign("actions", array( "halt" => _("Switch off"),
"reboot" => _("Reboot"),
"memcheck" => _("Memory test"),
new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+ }
/* Optionally execute a command after we're done */
$this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
$og->save ();
}
}
+
+ /* Clean queue form entries with this mac
+ */
+ if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
+ $q = new gosaSupportDaemon();
+ $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
+ }
}
}
}
}
- /* Append gosaAdministrativeUnitTag to objectClass if gosaUnitTag isset */
- if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
- $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
- }
-
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
if ($this->orig_dn == 'new'){
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->save();
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn));
-
- if ($activate){
- gosaSupportDaemon::send("gosa_set_activated_for_installation", $this->netConfigDNS->ipHostNumber);
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+ }
+
+ /* Send installation activation
+ */
+ if ($activate && class_available("DaemonEvent")){
+ $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+ $o_queue = new gosaSupportDaemon();
+ if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
+ $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
+ $tmp = new $evt['CLASS_NAME']($this->config);
+ $tmp->set_type(TRIGGERED_EVENT);
+ $tmp->add_targets(array($this->netConfigDNS->macAddress));
+ if(!$o_queue->append($tmp)){
+ msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+ $o_queue->get_error()),ERROR_DIALOG);
+ }
+ }
}
}
"gotoNtpServer" => _("Ntp server settings"),
"base" => _("Base"),
"cn" => _("Name"),
+ "description" => _("Description"),
"gotoRootPasswd" => _("Root password"),
"FAIstate" => _("Action flag"))
));