Code

Udpated Application copy & paste
[gosa.git] / plugins / admin / applications / class_applicationManagement.inc
index a340977ca8e09cb7542f9346828f1f9444a856b1..14c88b6e16d490106e7d22eb97f8c429c8adccb2 100644 (file)
@@ -32,6 +32,7 @@ class applicationManagement extends plugin
   var $DivListApplication       = NULL;
   var $applications             = array();
   var $enableReleaseManagement  = false;
+  var $start_pasting_copied_objects = FALSE;
 
   function IsReleaseManagementActivated()
   {
@@ -136,6 +137,10 @@ class applicationManagement extends plugin
         $s_action="del_multiple";
       }elseif(preg_match("/^editPaste.*/i",$key)){
         $s_action="editPaste";
+      }elseif(preg_match("/^multiple_copy_groups/",$key)){
+        $s_action = "copy_multiple";
+      }elseif(preg_match("/^multiple_cut_groups/",$key)){
+        $s_action = "cut_multiple";
       }
     }
 
@@ -151,12 +156,10 @@ class applicationManagement extends plugin
       Copy & Paste handling  
      ****************/
 
-    /* Only perform copy / paste if it is enabled 
-     */
-    if($this->CopyPasteHandler){
-      if($str = $this->copyPasteHandling($s_action,$s_entry)){
-       return($str);
-      };
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
     }
 
 
@@ -518,49 +521,67 @@ class applicationManagement extends plugin
   }
 
 
 function copyPasteHandling($s_action,$s_entry)
function copyPasteHandling_from_queue($s_action,$s_entry)
   {
-    /* Paste copied/cutted object in here
-     */
-    if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
-      $this->CopyPasteHandler->save_object();
-      $this->CopyPasteHandler->SetVar("base", $this->DivListApplication->selectedBase);
-
-      if($str = $this->CopyPasteHandler->execute()) {
-        return($str);
-      }
-    }
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
 
-    /* Copy current object to CopyHandler
-     */
-    if($s_action == "copy"){
-      $this->CopyPasteHandler->Clear();
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
       $dn = $this->applications[$s_entry]['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"apptabs","APPSTABS","application");
+    }
+
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
 
-      /* Check Acls */
-      $acl_all= $this->ui->has_complete_category_acls($dn,"application");  
-      if(preg_match("/(c.*w|w.*c)/",$acl_all)){
-        $obj    = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,  "application");
-        $objNew = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], "new","application");
-        $this->CopyPasteHandler->Copy($obj,$objNew);
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->applications[$id]['dn'];
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","apptabs","APPSTABS","application");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","apptabs","APPSTABS","application");
+        }
       }
     }
 
-    /* Copy current object to CopyHandler
-     */
-    if($s_action == "cut"){
-      $this->CopyPasteHandler->Clear();
-      $dn = $this->applications[$s_entry]['dn'];
+    /* 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",$this->DivListApplication->selectedBase);
 
-      /* Check Acls */
-      $acl_all= $this->ui->has_complete_category_acls($dn,"application");  
-      if(preg_match("/(c.*w|w.*c)/",$acl_all)){
-        $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn, "application");
-        $this->CopyPasteHandler->Cut($obj);
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      /* 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("");
   }
 
+
   function list_get_selected_items()
   {
     $ids = array();