Code

Added copy & paste for fai
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Dec 2007 12:56:39 +0000 (12:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Dec 2007 12:56:39 +0000 (12:56 +0000)
- Not implemented completely

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8045 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_divListFai.inc
plugins/admin/fai/class_faiManagement.inc

index b42bac3480f8d6a84b06e8333d8a078a4c988ed5..f398438fb0cc20063764e466b67c6ab79967ac4a 100644 (file)
@@ -336,8 +336,17 @@ class divListFai extends MultiSelectWindow
          }
        }
 
-       $edi = $editlink;
-       $acti = $action;
+
+       /* Add copy & cut icons */
+       $ui = get_userinfo();
+       $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module);
+       if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){
+         $action .= "<input class='center' type='image'
+           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+         $action.= "<input class='center' type='image'
+           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+       }
+
 
        /* Cutted objects should be displayed in light grey */
        $display = $value['cn'].$desc;
@@ -349,6 +358,8 @@ class divListFai extends MultiSelectWindow
            }
          }
        }
+       $edi = $editlink;
+       $acti = $action;
 
        /* Create each field */
        $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
index b7bfc4c54c951f4839199dfcfa40c89b31e92ba8..b9c0271102053a8529276e2c4dc86e042074cbec 100644 (file)
@@ -62,6 +62,11 @@ class faiManagement extends plugin
     
     /* Creat dialog object */
     $this->DivListFai = new divListFai($this->config,$this);
+
+    /* Copy & Paste handler */
+    if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
+      $this->CopyPasteHandler= new CopyPasteHandler($this->config);
+    }
        }
 
        function execute()
@@ -96,12 +101,16 @@ class faiManagement extends plugin
                     "/edit_continue/"=>"select_class_name_finished",
                     "/^multiple_copy_fai/" => "copy_multiple", 
                     "/^multiple_cut_fai/" => "cut_multiple", 
+                    "/^copy/" => "copy",
+                    "/^cut/" => "cut",
                     "/^remove_multiple_fai_objects/" => "del_multiple");
 
                foreach($_POST as $name => $value){
       foreach($posts as $reg => $act ){
         if(preg_match($reg,$name)){
           $s_action = $act;
+          $s_entry = ltrim(preg_replace($reg,"",$name),"_");
+          $s_entry = preg_replace("/_.*$/","",$s_entry);
         }
       }
                        if(preg_match("/^entry_edit_.*/",$name)){
@@ -168,6 +177,16 @@ class faiManagement extends plugin
       $s_action = "del_multiple";
     }
 
+    /********************
+      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 confirme dialog 
@@ -1040,6 +1059,84 @@ class faiManagement extends plugin
   }
 
 
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+    /* Check if Copy & Paste is disabled */
+    if(!is_object($this->CopyPasteHandler)){
+      return("");
+    }
+
+    $base = $this->DivListFai->selectedBranch;
+    if($base == "main"){
+      $base = $this->DivListFai->selectedBase;
+    }
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $entry    = $this->objects[$s_entry];
+      $a_setup  = $this->get_type($entry);
+      $dn = $entry['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+    }
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+
+        /* Cleanup object queue */
+        $entry    = $this->objects[$id];
+        $a_setup  = $this->get_type($entry);
+        $dn = $entry['dn'];
+
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
+        }
+      }
+    }
+
+    /* Start pasting entries */
+    if($s_action == "editPaste"){
+      $this->start_pasting_copied_objects = TRUE;
+    }
+
+    /* 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",$base);
+
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      save_release_changes_now();
+
+      /* Return dialog data */
+      if(!empty($data)){
+        return($data);
+      }
+    }
+
+    /* Automatically disable status for pasting */
+    if(!$this->CopyPasteHandler->entries_queued()){
+      $this->start_pasting_copied_objects = FALSE;
+    }
+    return("");
+  }
+
+
   /* Return plugin informations for acl handling */ 
   static function plInfo()
   {