Code

Added copy & paste to fai
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 3 Dec 2008 12:38:25 +0000 (12:38 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 3 Dec 2008 12:38:25 +0000 (12:38 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13143 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 5ac631747760f9d1027f2bdda4d1adbe6be0e89a..f331b9aff9f189dcf6a37fc5372578157dfbf7f4 100644 (file)
@@ -277,10 +277,7 @@ class divListFai extends MultiSelectWindow
           src='images/lists/edit.png'>";
         $actions.= "<img class='center' src='images/empty.png' alt=' '>";
       }else{
-
-        $actions.= '<input class="center" src="images/lists/cut.png" alt="Ausschneiden" name="cut_10" 
-          title="Diesen Eintrag ausschneiden" type="image">&nbsp;
-        <input class="center" src="images/lists/copy.png" alt="Kopieren" name="copy_10" 
+        $actions.= '<input class="center" src="images/lists/copy.png" alt="Kopieren" name="group_copy_'.$key.'" 
           title="Diesen Eintrag kopieren" type="image">&nbsp;';
 
         $actions.= "<input type='image' name='group_edit_".$key."' class='center'
index 999b692332725ff4d8518c80bd4ef2e6fcea89de..0049555ed00f209335c61918162e82523d3f36d0 100644 (file)
@@ -10,7 +10,7 @@ class faiGroupHandle{
 
   public function __construct($FAI_group, $Action)
   {
-    if(in_array($Action,array("edit","remove"))){
+    if(in_array($Action,array("edit","remove","copy","cut"))){
       $this->mode = $Action;
     }else{
       trigger_error("Wrong action type '".$Action."'.");
@@ -21,7 +21,7 @@ class faiGroupHandle{
     foreach($FAI_group as $type => $data){
       $FAI_group[$type]['selected'] = FALSE;
       $FAI_group[$type]['freezed'] = isset($data['FAIstate']) && preg_match("/freeze/",$data['FAIstate']);
-      if($this->mode == "edit" && !$FAI_group[$type]['freezed']){
+      if(($this->mode == "cut" || $this->mode == "edit") && !$FAI_group[$type]['freezed']){
         $FAI_group[$type]['selected'] = TRUE;
       }
     }
@@ -40,7 +40,7 @@ class faiGroupHandle{
   function save_object()
   {
     if(isset($_POST['faiGroupHandle'])){
-      if($this->mode == "remove"){
+      if(in_array($this->mode,array("copy","cut","remove"))){
         foreach($this->FAI_group as $key => $group){
           if(isset($_POST[$this->mode."_".$key])){
             $this->FAI_group[$key]['selected'] = TRUE;
index c88f435d26e1ec2993516f8c3a0975d045d06d9b..d209b1d6d447842194cbf9502bdbf3662c93c2c5 100644 (file)
@@ -140,6 +140,8 @@ class faiManagement extends plugin
 
                     "/^edit_continue$/"               => "select_class_name_finished",
 
+                    "/^group_copy/"                   => "group_copy",
+                    "/^group_cut/"                    => "group_cut",
                     "/^group_edit/"                   => "group_edit",
                     "/^group_remove/"                 => "group_remove");
                foreach($_POST as $name => $value){
@@ -201,16 +203,6 @@ class faiManagement extends plugin
       $this->no_save = $no_save;
     }
 
-    /********************
-      Copy & Paste
-     ********************/
-
-    /* Display the copy & paste dialog, if it is currently open */
-    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
-    if($ret){
-      return($ret);
-    }
-
 
     /*******************
       Opsi extension 
@@ -272,6 +264,16 @@ class faiManagement extends plugin
         $group = $this->objects[$s_entry];
         $this->dialog = new faiGroupHandle($group,"edit");
       }
+    }elseif($s_action == "group_cut"){
+      if(isset($this->objects[$s_entry])){
+        $group = $this->objects[$s_entry];
+        $this->dialog = new faiGroupHandle($group,"cut");
+      }
+    }elseif($s_action == "group_copy"){
+      if(isset($this->objects[$s_entry])){
+        $group = $this->objects[$s_entry];
+        $this->dialog = new faiGroupHandle($group,"copy");
+      }
     }
     if($this->dialog instanceOf faiGroupHandle){
       $this->dialog->save_object();
@@ -286,6 +288,16 @@ class faiManagement extends plugin
       }
     }
 
+    /********************
+      Copy & Paste
+     ********************/
+
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+
 
     /********************
       Delete MULTIPLE entries confirmed
@@ -399,7 +411,6 @@ class faiManagement extends plugin
       $this->dns = array();
     }
 
-
     /****************
       Edit entry 
      ****************/
@@ -1297,16 +1308,21 @@ class faiManagement extends plugin
     $ui = get_userinfo();
 
     /* Add a single entry to queue */
-    if($s_action == "copy"){
+    if($this->dialog instanceOf faiGroupHandle && !$this->dialog->is_open()){
 
-      /* Cleanup object queue */
-      $this->CopyPasteHandler->cleanup_queue();
-      $entry    = $this->objects[$s_entry];
-      $a_setup  = $this->get_type($entry);
-      $dn = $entry['dn'];
+      if(in_array($this->dialog->get_mode(),array("copy"))){      
 
-      if($ui->is_copyable($dn,"fai",$a_setup[1])){
-        $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+        /* Cleanup object queue */
+        $this->CopyPasteHandler->cleanup_queue();
+        $group = $this->dialog->get_selected();
+        foreach($group as $entry){
+          $a_setup  = $this->get_type($entry);
+          $dn = $entry['dn'];
+          if($ui->is_copyable($dn,"fai",$a_setup[1])){
+            $this->CopyPasteHandler->add_to_queue($dn,$this->dialog->get_mode(),$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+          }
+        }
+        $this->dialog = FALSE;
       }
     }
 
@@ -1318,14 +1334,14 @@ class faiManagement extends plugin
 
       /* Add new entries to CP queue */
       foreach($this->list_get_selected_items() as $id){
+        $group    = $this->objects[$id];
+        foreach($group as $entry){
+          $a_setup  = $this->get_type($entry);
+          $dn = $entry['dn'];
 
-        /* Cleanup object queue */
-        $entry    = $this->objects[$id];
-        $a_setup  = $this->get_type($entry);
-        $dn = $entry['dn'];
-
-        if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
-          $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+          if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
+            $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+          }
         }
       }
     }
index cddbd0fa4a22333563ebc175746907163bf08832..84c25f1586e1e82d6c3864c1a5ecb97c4edd6dbf 100644 (file)
        </tr>
 {/foreach}
 </table>
+
+{elseif $mode == "copy"}
+
+<h2>{t}Copy entries{/t}</h2>
+<br>
+{t}Select the entry you want to copy.{/t}
+<br>
+<br>
+<table>
+{foreach from=$FAI_group item=item key=key}
+       <tr>
+               <td>
+                       <input type='checkbox' name='{$mode}_{$key}'
+                       {if $item.selected} checked {/if}>
+               </td>
+               <td>
+                       <img src='{$types.$key.IMG}' alt='{$types.$key.KZL}' title='{$types.$key.NAME}'
+                               class='center'>
+               </td>
+               <td style='width:150px;'>{$types.$key.NAME}</td>
+               <td>{$item.description}
+               </td>
+       </tr>
+{/foreach}
+</table>
+
+{elseif $mode == "cut"}
+
+<h2>{t}Cut entries{/t}</h2>
+<br>
+{t}Select the entry you want to cut.{/t}
+<br>
+<br>
+<table>
+{foreach from=$FAI_group item=item key=key}
+       <tr>
+               <td>
+                       {if $item.freezed}
+                               <img src="images/lists/locked.png" class='center'>
+                       {else}
+                               <input type='checkbox' name='{$mode}_{$key}'
+                       {if $item.selected} checked {/if}>
+                       {/if}
+               </td>
+               <td>
+                       <img src='{$types.$key.IMG}' alt='{$types.$key.KZL}' title='{$types.$key.NAME}'
+                               class='center'>
+               </td>
+               <td style='width:150px;'>{$types.$key.NAME}</td>
+               <td>{$item.description}
+               </td>
+       </tr>
+{/foreach}
+</table>
 {/if}
 <br>
 <br>