X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fsystems%2Fadmin%2Fsystems%2Fclass_systemManagement.inc;h=e5d66afcc17849ebad7e1ac8affb9f53a8291da9;hb=a063e95e6a1e33c48ca144f34a8e734189440f4f;hp=afa8b44ec74959d5cb70f514c9a3fe9ac234e4ac;hpb=1913b70f010190de1249bbecb26294ef5f376fea;p=gosa.git diff --git a/gosa-plugins/systems/admin/systems/class_systemManagement.inc b/gosa-plugins/systems/admin/systems/class_systemManagement.inc index afa8b44ec..e5d66afcc 100644 --- a/gosa-plugins/systems/admin/systems/class_systemManagement.inc +++ b/gosa-plugins/systems/admin/systems/class_systemManagement.inc @@ -1,21 +1,23 @@ dns = array(); $ids = $this->list_get_selected_items(); @@ -515,23 +517,19 @@ class systems extends plugin $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); } } } @@ -540,21 +538,18 @@ class systems extends plugin /* Insert scheduled events into queue */ if($this->systab instanceof DaemonEvent){ $this->systab->save_object(); - if(isset($_POST['save_event_dialog']) || $save_events_directly){ - $header = $this->systab->get_schedule_action(); - $targets = $this->systab->get_targets(); - $data = $this->systab->save(); - $data['timestamp'] = $this->systab->get_timestamp(); + + /* 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($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; @@ -640,7 +635,11 @@ class systems extends plugin 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 (); @@ -777,7 +776,11 @@ class systems extends plugin 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 (); @@ -874,6 +877,40 @@ class systems extends plugin } $this->systab->save(); + + /* Get macAddress to be able to an installation event + */ + if($this->systab instanceof ArpNewDeviceTabs || session::is_set('SelectedSystemType')){ + $events = DaemonEvent::get_event_types(SYSTEM_EVENT); + + /* Get mac of currently edited entry */ + $mac = ""; + if($this->systab instanceof ArpNewDeviceTabs){ + $mac = $this->systab->by_object['ArpNewDevice']->netConfigDNS->macAddress; + }else{ + foreach(array("workgeneric","termgeneric","servgeneric") as $type){ + if(isset($this->systab->by_object[$type]->netConfigDNS->macAddress)){ + $mac = $this->systab->by_object[$type]->netConfigDNS->macAddress; + break; + } + } + } + + /* Add installation event + */ + if(!empty($mac) && isset($events['BY_CLASS']['DaemonEvent_install'])){ + $evt = $events['BY_CLASS']['DaemonEvent_install']; + $tmp = new $evt['CLASS_NAME']($this->config); + $tmp->add_targets(array($mac)); + $tmp->set_type(TRIGGERED_EVENT); + $o_queue = new gosaSupportDaemon(); + $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); + } + } + } if(session::is_set('SelectedSystemType')){ session::un_set('SelectedSystemType'); @@ -1341,13 +1378,10 @@ class systems extends plugin /* 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)){