Code

Updated Target handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Mar 2008 13:44:03 +0000 (13:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Mar 2008 13:44:03 +0000 (13:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10027 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc
gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc

index e6eafceeda9eef4dfe7cf1490d7896161f9cbd06..f1e2756cf62e4f3288cb9bba08f0dc11c294de88 100644 (file)
@@ -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;
       }
     }
index 476e0ab33dbadb30241a443d21de103d106f95ec..b908ddd68c5a8260e4d9bf4d1604330c262d0045 100644 (file)
@@ -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:
 ?>