Code

Added Copy & Paste to mimetypes, it wasn't portet correctly from trunk yet
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Aug 2007 07:43:00 +0000 (07:43 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Aug 2007 07:43:00 +0000 (07:43 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6977 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/mimetypes/class_divListMimeTypes.inc
plugins/admin/mimetypes/class_mimetypeGeneric.inc
plugins/admin/mimetypes/class_mimetypeManagement.inc

index 61f7e0d8f3275d0ce45d7d76b4839470550f2aa3..8686f42015108731546c71238f03897a1a605032 100755 (executable)
@@ -94,10 +94,18 @@ class divListMimeTypes extends MultiSelectWindow
       }
     }
 
+    /* Get copy & paste icon */
+    if($this->parent->CopyPasteHandler){
+      $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
+    }else{
+      $Copy_Paste ="";
+    }
+
     $listhead = MultiSelectWindow::get_default_header();
     $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_mime.png' alt='"._("new").
       "' title='"._("Create new mime type")."' name='mime_new'>&nbsp;";
     $add_sep = true;
+    $listhead.=$Copy_Paste;
 
     /* And at least add a department selection box */
     $listhead .=  _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
@@ -143,6 +151,18 @@ class divListMimeTypes extends MultiSelectWindow
       /* Create action icons */
       $actions = "";
 
+      $dn= $val['dn'];
+      $acl= get_permissions ($dn, $this->ui->subtreeACL);
+      $acl= get_module_permission($acl, "mimetype", $dn);
+
+      /* Append copy&paste icons if allowed */
+      if($acl == "#all#" && $this->parent->CopyPasteHandler){
+        $actions .= "<input class='center' type='image'
+          src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+        $actions.= "<input class='center' type='image'
+          src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+      }
+
       $actions.= "<input class='center' type='image'
         src='images/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
 
index 90616a41c4e08ba3cab4b23399dc14d1bb4418d5..e3e4147ae31b6b3766f705993df55a61d99f6d39 100644 (file)
@@ -672,7 +672,7 @@ class mimetype extends plugin
   {
     plugin::PrepareForCopyPaste($source);
 
-    $source_o = new mimetype($this->config,$source['dn'],$this->parent);
+    $source_o = new mimetype($this->config,$source->dn,$this->parent);
 
     foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){
       $use_attr     = "use_".$name;
index f4553fe7057d838ff7cdc5c359e6e4b25e972612..793693dd155aba7e15bf7c69a9239e2583040344 100755 (executable)
@@ -152,10 +152,27 @@ class mimetypeManagement 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);
+    /* Get 'dn' from posted 'uid' */
+    if(in_array_ics($s_action,array("editPaste","cut","copy")) || ($this->CopyPasteHandler && $this->CopyPasteHandler->stillOpen())){
+
+      if(isset($this->mimetypes[trim($s_entry)]['dn'])){
+        $dn= $this->mimetypes[trim($s_entry)]['dn'];
+      }else{
+        $dn = $this->DivListMimeTypes->selectedBase;
+      }
+
+      $acl= get_permissions ($dn, $this->ui->subtreeACL);
+      $acl= get_module_permission($acl, "mimetype", $dn);
+
+      if($acl != "#all#"){
+        print_red (_("You are not allowed to execute this method!"));
+      }else{
+        /* Display the copy & paste dialog, if it is currently open */
+        $ret = $this->copyPasteHandling($s_action,$s_entry);
+        if($ret){
+          return($ret);
+        }
+      }
     }
 
 
@@ -171,10 +188,10 @@ class mimetypeManagement extends plugin
          react on this. */
       $this->dn= "new";
 
-      /* Create new usertab object */
+      /* Create new mimetab object */
       $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn);
 
-      /* Set up the users ACL's for this 'dn' */
+      /* Set up the mimetypes ACL's for this 'dn' */
       $acl= get_permissions ($this->DivListMimeTypes->selectedBase, $this->ui->subtreeACL);
       $this->mimetabs->set_acl($acl);
     }   
@@ -198,7 +215,7 @@ class mimetypeManagement extends plugin
      ****************/
 
     /* Finish mime edit is triggered by the tabulator dialog, so
-       the user wants to save edited data. Check and save at this point. */
+       the mimetypes wants to save edited data. Check and save at this point. */
     if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->mimetabs->config))){
 
       /* Check tabs, will feed message array */
@@ -233,7 +250,7 @@ class mimetypeManagement extends plugin
       Edit entry  
      ****************/
 
-    /* User wants to edit data? */
+    /* mimetypes wants to edit data? */
     if (($s_action=="edit") && (!isset($this->mimetabs->config))){
 
       /* Get 'dn' from posted 'mimelist', must be unique */
@@ -253,7 +270,7 @@ class mimetypeManagement extends plugin
       /* Register mimetabs to trigger edit dialog */
       $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn);
 
-      /* Set up the users ACL's for this 'dn' */
+      /* Set up the mimetypes ACL's for this 'dn' */
       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
       $this->mimetabs->set_acl($acl);
 
@@ -301,7 +318,7 @@ class mimetypeManagement extends plugin
       Delete mime type 
      ****************/
 
-    /* Remove user was requested */
+    /* Remove mimetypes was requested */
     if ($s_action == "del"){
 
       /* Get 'dn' from posted 'uid' */
@@ -328,7 +345,7 @@ class mimetypeManagement extends plugin
         return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
       } else {
 
-        /* Obviously the user isn't allowed to delete. Show message and
+        /* Obviously the mimetypes isn't allowed to delete. Show message and
            clean session. */
         print_red (_("You are not allowed to delete this mime type!"));
       }
@@ -477,6 +494,81 @@ class mimetypeManagement extends plugin
   }
 
 
+ /* Perform copy & paste requests
+      If copy&paste is in progress this returns a dialog to fix required attributes
+   */
+  function copyPasteHandling($s_action,$s_entry)
+  {
+    /* Only perform copy/paste if it is enabled */
+    if($this->CopyPasteHandler){
+
+      /* Prepare current object to be pasted */
+      if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
+
+        $this->CopyPasteHandler->save_object();
+        $this->CopyPasteHandler->SetVar("base", $this->DivListMimeTypes->selectedBase);
+
+        /* Execute copy & paste dialog and display returned data, normaly a dialog which allows
+            us to solve all attribute mismatches for this object.
+            If nothing is returned, copy & paste was succesfully or aborted */
+        if(($ret= $this->CopyPasteHandler->execute())){
+          return ($ret);
+        }
+
+        /* Use the last dn to search for it's ID in the newly generated list. */
+        $dn= $this->CopyPasteHandler->lastdn;
+
+        /* Get new mimetypes list */
+        $this->reload();
+        foreach($this->mimetypes as $id => $entry){
+          if($entry['dn'] == $dn){
+            $s_entry= $id;
+            break;
+          }
+        }
+
+        /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
+        if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
+          $this->CPPasswordChange = $s_entry;
+        }
+      }
+      /* Copy selected object
+          Create a new empty object and the current selected object.
+          Send both to copy&paste class*/
+      if($s_action == "copy"){
+        $this->CopyPasteHandler->Clear();
+        $dn= $this->mimetypes[trim($s_entry)]['dn'];
+        $acl= get_permissions ($dn, $this->ui->subtreeACL);
+        $obj    = new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn);
+        $objNew = new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], "new");
+        $obj->    set_acl($acl);
+        $objNew-> set_acl($acl);
+        $this->CopyPasteHandler->Copy($obj,$objNew);
+      }
+
+      /* Cut selected object.
+          Open mimetabs object and send it to the copy & paste handler */
+      if($s_action == "cut"){
+        $this->CopyPasteHandler->Clear();
+        $dn= $this->mimetypes[trim($s_entry)]['dn'];
+        $acl= get_permissions ($dn, $this->ui->subtreeACL);
+        $obj= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn);
+        $obj->set_acl($acl);
+        $this->CopyPasteHandler->Cut($obj);
+      }
+    }
+  }
+
+
+
+
+
+
+
+
+
+
+
   function copyPasteHandling_from_queue($s_action,$s_entry)
   {
     /* Check if Copy & Paste is disabled */