From: hickert Date: Thu, 27 Mar 2008 13:44:03 +0000 (+0000) Subject: Updated Target handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b4a2386a36b9d4d2b537c8d5208743cdf94835b2;p=gosa.git Updated Target handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10027 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc index e6eafceed..f1e2756cf 100644 --- a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc +++ b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc @@ -269,22 +269,7 @@ class DaemonEvent } if(isset($_POST['save_target_dialog'])){ $this->target_add_list_used =FALSE; - foreach($this->list_get_selected_items() as $id){ - if(in_array("gosaGroupOfNames",$this->target_divlist->_target_list[$id]['objectClass'])){ - foreach($this->target_divlist->_target_list[$id]['member'] as $mem_dn){ - if(isset($this->target_divlist->workstation_list[$mem_dn])){ - $this->a_targets[] = $this->target_divlist->workstation_list[$mem_dn]['macAddress'][0]; - } - if(isset($this->target_divlist->server_list[$mem_dn])){ - $this->a_targets[] = $this->target_divlist->server_list[$mem_dn]['macAddress'][0]; - } - } - }else{ - if(isset($this->target_divlist->_target_list[$id]['macAddress'][0])){ - $this->a_targets[] = $this->target_divlist->_target_list[$id]['macAddress'][0]; - } - } - } + $this->add_targets($this->target_divlist->get_selected_targets()); $this->target_divlist = NULL; } } diff --git a/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc b/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc index 476e0ab33..b908ddd68 100644 --- a/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc +++ b/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc @@ -167,6 +167,29 @@ class EventTargetAddList extends MultiSelectWindow } + function get_selected_targets() + { + $a_targets = array(); + foreach($this->list_get_selected_items() as $id){ + if(in_array("gosaGroupOfNames",$this->_target_list[$id]['objectClass'])){ + foreach($this->_target_list[$id]['member'] as $mem_dn){ + if(isset($this->workstation_list[$mem_dn])){ + $a_targets[] = $this->workstation_list[$mem_dn]['macAddress'][0]; + } + if(isset($this->server_list[$mem_dn])){ + $a_targets[] = $this->server_list[$mem_dn]['macAddress'][0]; + } + } + }else{ + if(isset($this->_target_list[$id]['macAddress'][0])){ + $a_targets[] = $this->_target_list[$id]['macAddress'][0]; + } + } + } + return($a_targets); + } + + function setEntries() { $_target_list = array(); @@ -244,6 +267,22 @@ class EventTargetAddList extends MultiSelectWindow $this->AddElement(array($field1,$field2,$field3)); } } + + + /*! \brief Returns a set of elements selected in a MultiSelectWindow + @return Array[integer]=integer + */ + protected function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>