diff --git a/gosa-plugins/systems/admin/systems/class_systemManagement.inc b/gosa-plugins/systems/admin/systems/class_systemManagement.inc
index 98128010c461bdb376a1375d874c7c3760d8c2f9..b1f33c1b94cc54845aaa48774812e569175d0b45 100644 (file)
<?php
/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class systems extends plugin
/********************
SCHEDULE action in GOsa Daemon
********************/
- $save_events_directly = FALSE;
+
if(preg_match("/^schedule_event_/",$s_action) || preg_match("/^trigger_event_/",$s_action)){
$this->dns = array();
$ids = $this->list_get_selected_items();
$mac[]= $attrs['macAddress'][0];
}
}
- $events = DaemonEvent::get_event_types();
- if(preg_match("/^trigger_event_/",$s_action)){
- $type = preg_replace("/^trigger_event_/","",$s_action);
- }else{
- $type = preg_replace("/^schedule_event_/","",$s_action);
- }
+ $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
+ $type = preg_replace("/^[a-z]*_event_/","",$s_action);
+
+ /* Prepare event to be added
+ */
if(count($mac) && isset($events['BY_CLASS'][$type])){
$event = $events['BY_CLASS'][$type];
$this->systab = new $event['CLASS_NAME']($this->config);
$this->systab->add_targets($mac);
-
- /* Insert event directly with current timestamp
- * to force direct execution.
- */
- if(preg_match("/^trigger_event_/",$s_action)){
- $this->systab->set_timestamp(time());
- $save_events_directly = TRUE;
+ if(preg_match("/trigger_event/",$s_action)){
+ $this->systab->set_type(TRIGGERED_EVENT);
+ }else{
+ $this->systab->set_type(SCHEDULED_EVENT);
}
}
}
/* Insert scheduled events into queue */
if($this->systab instanceof DaemonEvent){
$this->systab->save_object();
- if(isset($_POST['save_event_dialog']) || $save_events_directly){
- /* Directly means not scheduled */
- if($save_events_directly){
- $header = $this->systab->get_trigger_action();
- }else{
- $header = $this->systab->get_schedule_action();
- }
- $targets = $this->systab->get_targets();
- $data = $this->systab->save();
+ /* Save event
+ */
+ if(isset($_POST['save_event_dialog']) || $this->systab->get_type() == TRIGGERED_EVENT){
$o_queue = new gosaSupportDaemon();
- foreach($targets as $target){
- $data['macaddress'] = $target;
- $o_queue->send_data($header,$target,$data,TRUE);
- if($o_queue->is_error()){
- msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
- $o_queue->get_error()),ERROR_DIALOG);
- }
+ $o_queue->append($this->systab);
+ if($o_queue->is_error()){
+ msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+ $o_queue->get_error()),ERROR_DIALOG);
+ }else{
+ $this->systab = FALSE;
}
- $this->systab = FALSE;
}
if(isset($_POST['abort_event_dialog'])){
$this->systab = FALSE;
if(preg_match("/d/",$tabacl)){
/* Delete request is permitted, perform LDAP action */
- if($tabtype=="phonetabs"){
+ if(in_array($type,array("ArpNewDevice","NewDevice")) && class_available("termgeneric")){
+ $this->systab= new termgeneric($this->config, $dn);
+ $this->systab->set_acl_base($dn);
+ $this->systab->remove_from_parent();
+ }elseif($tabtype=="phonetabs"){
$this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
$this->systab->set_acl_base($dn);
$this->systab->by_object['phoneGeneric']->remove_from_parent ();
if(preg_match("/d/",$tabacl)){
/* Delete request is permitted, perform LDAP action */
- if($tabtype=="phonetabs"){
+ if(in_array($type,array("ArpNewDevice","NewDevice")) && class_available("termgeneric")){
+ $this->systab= new termgeneric($this->config, $this->dn);
+ $this->systab->set_acl_base($this->dn);
+ $this->systab->remove_from_parent();
+ }elseif($tabtype=="phonetabs"){
$this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type);
$this->systab->set_acl_base($this->dn);
$this->systab->by_object['phoneGeneric']->remove_from_parent ();
/* Get macAddress to be able to an installation event
*/
if($this->systab instanceof ArpNewDeviceTabs || session::is_set('SelectedSystemType')){
- $events = DaemonEvent::get_event_types();
+ $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
/* Get mac of currently edited entry */
$mac = "";
/* Add installation event
*/
- if(!empty($mac) && isset($events['BY_CLASS']['DaemonEvent_install'])){
- $evt = $events['BY_CLASS']['DaemonEvent_install'];
+ if(!empty($mac) && isset($events['BY_CLASS']['DaemonEvent_reinstall'])){
+ $evt = $events['BY_CLASS']['DaemonEvent_reinstall'];
$tmp = new $evt['CLASS_NAME']($this->config);
$tmp->add_targets(array($mac));
- $header = $tmp->get_trigger_action();
- $data = $tmp->save();
- $data['macaddress'] = $mac;
+ $tmp->set_type(SCHEDULED_EVENT);
$o_queue = new gosaSupportDaemon();
- $o_queue->send_data($header,$mac,$data,TRUE);
+ $o_queue->append($tmp);
if($o_queue->is_error()){
msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
$o_queue->get_error()),ERROR_DIALOG);
} else {
/* Ok. There seem to be errors regarding to the tab data,
show message and continue as usual. */
- show_errors($message);
+ msgDialog::displayChecks($message);
}
}
$dialog = FALSE;
$hide_apply = $this->dn == "new";
+ $hide_apply = ($this->dn == "new") || (preg_match("/".normalizePreg(get_ou("incomingou"))."/",$this->dn));
if(is_object($this->systab) && !isset($this->systab->by_object)){
$dialog = TRUE;
$hide_apply = TRUE;
/* Return C&P dialog */
if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
-
- /* Load entry from queue and set base */
- $this->CopyPasteHandler->load_entry_from_queue();
- $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
/* Get dialog */
$data = $this->CopyPasteHandler->execute();
+ $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
/* Return dialog data */
if(!empty($data)){