From d6ef9bf8412f391dd44844d4a43660c35f368465 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 13 Jun 2007 12:15:00 +0000 Subject: [PATCH] Added copy & paste to gofon Macros git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6576 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/gofon/macro/class_divListMacros.inc | 30 +++++- plugins/gofon/macro/class_gofonMacro.inc | 20 ++++ .../macro/class_gofonMacroManagement.inc | 96 +++++++++++++++++++ .../macro/class_gofonMacroParameters.inc | 7 ++ plugins/gofon/macro/paste_generic.tpl | 9 ++ 5 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 plugins/gofon/macro/paste_generic.tpl diff --git a/plugins/gofon/macro/class_divListMacros.inc b/plugins/gofon/macro/class_divListMacros.inc index 8fc64b956..0c16a67ec 100755 --- a/plugins/gofon/macro/class_divListMacros.inc +++ b/plugins/gofon/macro/class_divListMacros.inc @@ -42,7 +42,7 @@ class divListMacro extends MultiSelectWindow $this->EnableSaveButton (false); /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 60; + $action_col_size = 100; if($this->parent->snapshotEnabled()){ $action_col_size += 20; } @@ -126,9 +126,19 @@ class divListMacro extends MultiSelectWindow /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); + /* Get copy & paste icon */ + $Copy_Paste =""; + if(preg_match("/(c.*w|w.*c)/",$acls) && $this->parent->CopyPasteHandler){ + $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon(); + $addsep = true; + } + if(preg_match("/w/",$acls) && preg_match("/c/",$acls)){ $listhead .= $this->get_snapshot_header($this->selectedBase); } + + $listhead .= $Copy_Paste; + if(preg_match("/c/",$acls)){ $listhead .= "  "; @@ -142,6 +152,15 @@ class divListMacro extends MultiSelectWindow $listhead .= "  "; + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler)){ + $listhead .= "  "; + $listhead .= "  "; + $listhead .= ""; + } + $listhead .=""; $this->SetListHeader($listhead); } @@ -162,7 +181,7 @@ class divListMacro extends MultiSelectWindow $editlink = "%s"; /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 60; + $action_col_size = 100; if($this->parent->snapshotEnabled()){ $action_col_size += 20; } @@ -178,6 +197,13 @@ class divListMacro extends MultiSelectWindow continue; } + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$sacl)){ + $action.= " "; + $action.= " "; + } + $action.= ""; diff --git a/plugins/gofon/macro/class_gofonMacro.inc b/plugins/gofon/macro/class_gofonMacro.inc index 05f761b0d..7078cf998 100755 --- a/plugins/gofon/macro/class_gofonMacro.inc +++ b/plugins/gofon/macro/class_gofonMacro.inc @@ -544,6 +544,26 @@ class macro extends plugin } + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + function plInfo() { return (array( diff --git a/plugins/gofon/macro/class_gofonMacroManagement.inc b/plugins/gofon/macro/class_gofonMacroManagement.inc index f7a0e337f..d51135a01 100755 --- a/plugins/gofon/macro/class_gofonMacroManagement.inc +++ b/plugins/gofon/macro/class_gofonMacroManagement.inc @@ -31,6 +31,9 @@ class gofonMacro extends plugin var $ui = NULL; var $DivListMacro = NULL; + var $CopyPasteHandler = NULL; + var $start_pasting_copied_objects = FALSE; + function gofonMacro($config, $ui) { /* Save configuration for internal use */ @@ -38,6 +41,11 @@ class gofonMacro extends plugin $this->ui= $ui; $this->DivListMacro = new divListMacro($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() @@ -76,6 +84,18 @@ class gofonMacro extends plugin $s_action="new"; }elseif(preg_match("/^remove_multiple_macros/",$key)){ $s_action="del_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); + }elseif(preg_match("/^multiple_copy_objects/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_objects/",$key)){ + $s_action = "cut_multiple"; } } if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ @@ -85,6 +105,17 @@ class gofonMacro extends plugin $s_entry = preg_replace("/_.$/","",$s_entry); + /******************** + 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 a new Macro *****************/ @@ -370,6 +401,71 @@ class gofonMacro extends plugin } + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->macros[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"macrotabs","MACROTABS","gofonmacro"); + } + + /* 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->macros[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","macrotabs","MACROTABS","gofonmacro"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","macrotabs","MACROTABS","gofonmacro"); + } + } + } + + /* 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->DivListMacro->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(""); + } + + + /* Return departments, that will be included within snapshot detection */ function get_used_snapshot_bases() { diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc index b1ca0a8af..2960bbeb8 100755 --- a/plugins/gofon/macro/class_gofonMacroParameters.inc +++ b/plugins/gofon/macro/class_gofonMacroParameters.inc @@ -402,6 +402,13 @@ class macroParameter extends plugin show_ldap_error($ldap->get_error(), sprintf(_("Removing of goFonMacro/generic account with dn '%s' failed."),$this->dn)); } + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new macroParameter($this->config,$source['dn']); + $this->goFonMacroParameter = $source_o-> goFonMacroParameter; + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/gofon/macro/paste_generic.tpl b/plugins/gofon/macro/paste_generic.tpl new file mode 100644 index 000000000..0f5acf467 --- /dev/null +++ b/plugins/gofon/macro/paste_generic.tpl @@ -0,0 +1,9 @@ + + + + + +
+ {$must} + +
-- 2.30.2