Code

Added copy & paste to systems
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 12 Jun 2007 13:23:15 +0000 (13:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 12 Jun 2007 13:23:15 +0000 (13:23 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6572 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/class_groupManagement.inc
plugins/admin/systems/class_divListSystem.inc
plugins/admin/systems/class_systemManagement.inc

index 09a89297c14dc21fb0f6e298376f68bac215cb57..7fe75e3d2ae31928f26fee79a7565187c1584bbc 100644 (file)
@@ -655,8 +655,6 @@ class groupManagement extends plugin
   }
 
 
-
-
   /* Save data to object */
   function save_object()
   {
index f7b1ffac7af94d12f5d095a0cba0ba3f17112d96..99aaf9d0d8401f477531385d9d9db79a5c7cce97 100644 (file)
@@ -53,7 +53,7 @@ class divListSystem extends MultiSelectWindow
     $this->EnableSaveButton (false);
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 70;
+    $action_col_size = 110;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 38;
     }
@@ -161,7 +161,14 @@ class divListSystem extends MultiSelectWindow
 
     /* Must we add an additional seperator */
     $add_sep = false;
-    
+   
+    /* Get copy & paste icon */
+    $Copy_Paste ="";
+    if(preg_match("/(c.*w|w.*c)/",$all_module_acls) &&  $this->parent->CopyPasteHandler){
+      $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
+      $addsep = true;
+    }
+
     /* Add default header */
     $listhead = MultiSelectWindow::get_default_header();
 
@@ -171,6 +178,9 @@ class divListSystem extends MultiSelectWindow
       $add_sep = true;
     }
 
+    /* Assign copy & paste icons */
+    $listhead.=      $Copy_Paste;
+
     /* Handle create icons */ 
     if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"terminal/termgeneric"))){
       $add_sep = true;
@@ -222,6 +232,11 @@ class divListSystem extends MultiSelectWindow
     $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edittrash.png'
         title='"._("Remove selected systems")."' alt='"._("Remove systems")."' name='remove_multiple_systems'>&nbsp;";
 
+    $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/editcopy.png'
+      title='"._("Copy selected system")."' alt='"._("Copy systems")."' name='multiple_copy_systems'>&nbsp;";
+    $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/editcut.png'
+      title='"._("cut selected system")."' alt='"._("Cut systems")."' name='multiple_cut_systems'>&nbsp;";
+
     $listhead .="</div>";
 
     $this->SetListHeader($listhead);
@@ -250,7 +265,7 @@ class divListSystem extends MultiSelectWindow
     $empty    ="<img src='images/empty.png' style='width:16px ; height: 16px;' class='center' alt=''>";
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 70;
+    $action_col_size = 110;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 38;
     }
@@ -295,7 +310,14 @@ class divListSystem extends MultiSelectWindow
       /* Get specific generic acls */
       $acl      = $ui->get_permissions($val['dn'],$tabs[$type]['ACL']);
 
-      $action= "<input class='center' type='image' src='images/edit.png' 
+      $action ="";
+      if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $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;";
+      }
+      $action.= "<input class='center' type='image' src='images/edit.png' 
                     alt='"._("edit")."'     name='system_edit_%KEY%' title='"._("Edit system")."'>";
       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
         $action.= $this->GetSnapShotActions($val['dn']);
@@ -303,6 +325,7 @@ class divListSystem extends MultiSelectWindow
         $action.= $empty."&nbsp;".$empty."&nbsp;";
       }
 
+
       if(preg_match("/d/",$acl)){
         $action.= "<input class='center' type='image' src='images/edittrash.png' 
           alt='"._("delete")."'   name='system_del_%KEY%' title='"._("Delete system")."'>";
index 2327883611e9728053b8f06e9914fa9150887875..704bfee508b5baafbcb293390d95c7d26316d665 100644 (file)
@@ -38,6 +38,8 @@ class systems extends plugin
   var $terminals= array();
   var $ui       = NULL;
   var $DivListSystem;
+  var $start_pasting_copied_objects = FALSE;
+  var $CopyPasteHandler   = NULL;
 
   function systems ($config, $ui)
   {
@@ -47,8 +49,14 @@ class systems extends plugin
 
     /* Creat dialog object */
     $this->DivListSystem = new divListSystem($this->config,$this);
+
+    /* Copy & Paste enabled ?*/
+    if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
+    }
   }
 
+
   function execute()
   {
     /* Call parent execute */
@@ -90,9 +98,22 @@ class systems extends plugin
       }elseif(preg_match("/newsystem_.*/i",$key)){
         $s_action="newsystem";
         $s_entry  = preg_replace("/newsystem_/i","",$key);
+      }elseif(preg_match("/^multiple_copy_systems/",$key)){
+        $s_action = "copy_multiple";
+      }elseif(preg_match("/^multiple_cut_systems/",$key)){
+        $s_action = "cut_multiple";
+      }elseif(preg_match("/^editPaste.*/i",$key)){
+        $s_action="editPaste";
+      }elseif(preg_match("/^copy_.*/",$key)){
+        $s_action="copy";
+        $s_entry  = preg_replace("/^copy_/i","",$key);
+      }elseif(preg_match("/^cut_.*/",$key)){
+        $s_action="cut";
+        $s_entry  = preg_replace("/^cut_/i","",$key);
       }
     }
-
+    
+      
     /* Incoming handling  
      * If someone made a systemtype and ogroup selection 
      * Display the new requested entry type ... servtab  in case of server and so on.
@@ -124,6 +145,17 @@ class systems extends plugin
     }
 
 
+    /********************
+      Copy & Paste Handling  ...
+     ********************/
+
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+  
+
     /********************
       Create FAI CD ...   
      ********************/
@@ -1109,6 +1141,93 @@ class systems extends plugin
   }
 
 
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+
+    $tabs = array(
+        "terminal"    => array( "CLASS"     =>"TERMTABS",     "TABNAME" =>"termgeneric",     
+          "TABCLASS"  =>"termtabs",     "ACL"     =>"terminal"),
+        "workstation" => array( "CLASS"     =>"WORKTABS",     "TABNAME" =>"workgeneric",     
+          "TABCLASS"  =>"worktabs",     "ACL"     =>"workstation"),
+        "server"      => array( "CLASS"     =>"SERVTABS",     "TABNAME" =>"servgeneric",     
+          "TABCLASS"  =>"servtabs",     "ACL"     =>"server"),
+        "printer"     => array( "CLASS"     =>"PRINTTABS",    "TABNAME" =>"printgeneric",    
+          "TABCLASS"  =>"printtabs",    "ACL"     =>"printer"),
+        "phone"       => array( "CLASS"     =>"PHONETABS",    "TABNAME" =>"phonegeneric",    
+          "TABCLASS"  =>"phonetabs",    "ACL"     =>"phone"),
+        "component"   => array( "CLASS"     =>"COMPONENTTABS","TABNAME" =>"componentgeneric",
+          "TABCLASS"  =>"componenttabs","ACL"     =>"component"));
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $dn     = $this->terminals[$s_entry]['dn'];
+      $oc     = $this->terminals[$s_entry]['objectClass'];
+      $type   = $this->get_system_type($oc);
+
+      $tab_o  = $tabs[$type]['CLASS'];
+      $tab_c  = $tabs[$type]['TABCLASS'];
+      $acl    = $tabs[$type]['ACL'];
+
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl);
+    }
+
+    /* 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){
+        $dn = $this->terminals[$id]['dn'];
+        $oc = $this->terminals[$id]['objectClass']; 
+        $type = $this->get_system_type($oc);
+
+        $tab_o  = $tabs[$type]['CLASS'];
+        $tab_c  = $tabs[$type]['TABCLASS'];
+        $acl    = $tabs[$type]['ACL'];
+          
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl);
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl);
+        }
+      }
+    }
+
+    /* 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->DivListSystem->selectedBase);
+
+      /* 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 get_system_type($classes)
   {
     $type= "";