Code

Added FAI edit selection
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 3 Dec 2008 09:05:08 +0000 (09:05 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 3 Dec 2008 09:05:08 +0000 (09:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13134 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc
gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/faiGroupHandle.tpl

index 7b4454cfac833186f19294297b62e4da96674ae5..2ae27825ec5129907fe21c3c697c95a046e57f9d 100644 (file)
@@ -12,12 +12,21 @@ class faiGroupHandle{
   {
     if(in_array($Action,array("edit","remove"))){
       $this->mode = $Action;
+    }else{
+      trigger_error("Wrong action type '".$Action."'.");
+      exit();
     }
 
     /* Preset required values */
     foreach($FAI_group as $type => $data){
       $FAI_group[$type]['selected'] = FALSE;
     }
+    
+    /* Select first entry in edit mode */
+    if($this->mode == "edit"){
+      reset($FAI_group);
+      $FAI_group[key($FAI_group)]['selected'] = TRUE;
+    }
     $this->FAI_group = $FAI_group;
   }
 
@@ -33,20 +42,28 @@ class faiGroupHandle{
   function save_object()
   {
     if(isset($_POST['faiGroupHandle'])){
-      foreach($this->FAI_group as $key => $group){
-        if(isset($_POST[$this->mode."_".$key])){
-          $this->FAI_group[$key]['selected'] = TRUE;
-        }else{
-          $this->FAI_group[$key]['selected'] = FALSE;
+      if($this->mode == "remove"){
+        foreach($this->FAI_group as $key => $group){
+          if(isset($_POST[$this->mode."_".$key])){
+            $this->FAI_group[$key]['selected'] = TRUE;
+          }else{
+            $this->FAI_group[$key]['selected'] = FALSE;
+          }
+        } 
+      }else{
+        if(isset($_POST['edit_selected']) && isset($this->FAI_group[get_post('edit_selected')])){
+          foreach($this->FAI_group as $key => $obj){
+            $this->FAI_group[$key]['selected'] = FALSE;
+          }
+          $this->FAI_group[get_post('edit_selected')]['selected'] = TRUE;
         }
-      } 
+      }
       if(isset($_POST['faiGroupHandle_apply']) || isset($_POST['faiGroupHandle_cancel'])){
         $this->open = FALSE;
       }
       if(isset($_POST['faiGroupHandle_cancel'])){
         $this->canceled = TRUE;
       }
-    
     }
   }
 
index 3266af679a579eb894bea5977aafdd48ba019705..bf3308523ba4e8f6e0fe957280755f4f8d9bbcd4 100644 (file)
@@ -295,6 +295,11 @@ class faiManagement extends plugin
         $this->dialog = new faiGroupHandle($group,"remove");
 
       }
+    }elseif($s_action == "group_edit"){
+      if(isset($this->objects[$s_entry])){
+        $group = $this->objects[$s_entry];
+        $this->dialog = new faiGroupHandle($group,"edit");
+      }
     }
     if($this->dialog instanceOf faiGroupHandle){
       $this->dialog->save_object();
@@ -490,9 +495,17 @@ class faiManagement extends plugin
       Edit entry 
      ****************/
 
-               if(($s_action == "edit") && (!isset($this->dialog->config))){
-      if(isset($this->objects[$i_entryID][$s_entryType])){
-        $entry    = $this->objects[$i_entryID][$s_entryType];
+               if(($s_action == "edit") || $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){
+
+      $entry = array();
+      if($this->dialog instanceOf faiGroupHandle){
+        $entries = $this->dialog->get_selected();
+        $entry = array_pop($entries);
+      }elseif(isset($this->objects[$i_entryID][$s_entryType])){
+        $entry = $this->objects[$i_entryID][$s_entryType];
+      }
+
+      if(count($entry)){
         $a_setup  = $this->get_type($entry);
         $this->dn = $entry['dn'];
 
index 4bc7c874518c32bc9d8091461aece7b7e27ec514..3ebd9587847e2ab08cde89615eff1a85390e0a44 100644 (file)
@@ -9,6 +9,9 @@
                        {if $mode == "remove"}
                                <input type='checkbox' name='{$mode}_{$key}'
                                {if $item.selected} checked {/if}>
+                       {elseif $mode == "edit"}
+                   <input type='radio' name='{$mode}_selected' value='{$key}'
+                    {if $item.selected} checked {/if}>
                        {/if}
                </td>
                <td>