From: hickert Date: Tue, 7 Aug 2007 07:43:00 +0000 (+0000) Subject: Added Copy & Paste to mimetypes, it wasn't portet correctly from trunk yet X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=adec05cf86a3e92b83978636a0d542d4fcbf806a;p=gosa.git Added Copy & Paste to mimetypes, it wasn't portet correctly from trunk yet git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6977 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/mimetypes/class_divListMimeTypes.inc b/plugins/admin/mimetypes/class_divListMimeTypes.inc index 61f7e0d8f..8686f4201 100755 --- a/plugins/admin/mimetypes/class_divListMimeTypes.inc +++ b/plugins/admin/mimetypes/class_divListMimeTypes.inc @@ -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 .= "  "; $add_sep = true; + $listhead.=$Copy_Paste; /* And at least add a department selection box */ $listhead .= _("Base")." ". @@ -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 .= " "; + $actions.= " "; + } + $actions.= ""; diff --git a/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/plugins/admin/mimetypes/class_mimetypeGeneric.inc index 90616a41c..e3e4147ae 100644 --- a/plugins/admin/mimetypes/class_mimetypeGeneric.inc +++ b/plugins/admin/mimetypes/class_mimetypeGeneric.inc @@ -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; diff --git a/plugins/admin/mimetypes/class_mimetypeManagement.inc b/plugins/admin/mimetypes/class_mimetypeManagement.inc index f4553fe70..793693dd1 100755 --- a/plugins/admin/mimetypes/class_mimetypeManagement.inc +++ b/plugins/admin/mimetypes/class_mimetypeManagement.inc @@ -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 */