From 24bb7e4924a7572d21a018aced1581828dae218a Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 4 Jun 2006 09:18:20 +0000 Subject: [PATCH] adding message copy buttons. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11178 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 1 + functions/mailbox_display.php | 30 ++++++++++++++++++++++++------ include/load_prefs.php | 5 +++++ include/options/display.php | 7 +++++++ src/read_body.php | 11 +++++++++-- templates/default/message_list.tpl | 9 +++++++-- 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24ac9bed..10f83cee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -71,6 +71,7 @@ Version 1.5.2 - CVS tree and folder selection boxes. - Added write support to address book LDAP backend. Patch by David Hardeman (#1495763). + - Added message copy options. Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index f17071d3..e296416b 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -904,7 +904,7 @@ function calcFetchColumns(&$aMailbox, &$aProps) { */ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { global $PHP_SELF; - global $boxes; + global $boxes, $show_copy_buttons; $highlight_list = (isset($aProps['config']['highlight_list'])) ? $aProps['config']['highlight_list'] : false; $fancy_index_highlite = (isset($aProps['config']['fancy_index_highlite'])) ? $aProps['config']['fancy_index_highlite'] : true; @@ -913,6 +913,11 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { $sMailbox = (isset($aProps['mailbox'])) ? $aProps['mailbox'] : false; $sTargetModule = (isset($aProps['module'])) ? $aProps['module'] : 'read_body'; $show_flag_buttons = (isset($aProps['config']['show_flag_buttons'])) ? $aProps['config']['show_flag_buttons'] : true; + + /* allows to control copy button in function call. If array key is not set, code follows user preferences */ + if (isset($aProps['config']['show_copy_buttons'])) + $show_copy_buttons = $aProps['config']['show_copy_buttons']; + $lastTargetMailbox = (isset($aProps['config']['lastTargetMailbox'])) ? $aProps['config']['lastTargetMailbox'] : ''; $aOrder = array_keys($aProps['columns']); $trash_folder = (isset($aProps['config']['trash_folder']) && $aProps['config']['trash_folder']) @@ -993,7 +998,6 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { /* future admin control over displayable buttons */ - $aAdminControl = array( 'markUnflagged' => 1, 'markFlagged' => 1, @@ -1004,8 +1008,10 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { 'undeleteButton'=> 1, 'bypass_trash' => 1, 'expungeButton' => 1, - 'moveButton' => 1 + 'moveButton' => 1, + 'copyButton' => 1 ); + /* user prefs control */ $aUserControl = array ( @@ -1018,7 +1024,8 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { 'undeleteButton'=> 1, 'bypass_trash' => 1, 'expungeButton' => 1, - 'moveButton' => 1 + 'moveButton' => 1, + 'copyButton' => $show_copy_buttons ); @@ -1033,6 +1040,8 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { $showMove = ($aMailbox['RIGHTS'] != 'READ-ONLY') ? true : false; $showExpunge = (!$aMailbox['AUTO_EXPUNGE'] && $aMailbox['RIGHTS'] != 'READ-ONLY' && in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) ? true : false; + + /* Button options that depend on IMAP server and selected folder */ $aImapControl = array ( 'markUnflagged' => in_array('\\flagged',$aMailbox['PERMANENTFLAGS'], true), 'markFlagged' => in_array('\\flagged',$aMailbox['PERMANENTFLAGS'], true), @@ -1043,8 +1052,10 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { 'undeleteButton'=> $showUndelete, 'bypass_trash' => $showByPassTrash, 'expungeButton' => $showExpunge, - 'moveButton' => $showMove + 'moveButton' => $showMove, + 'copyButton' => 1 ); + /* Button strings */ $aButtonStrings = array( 'markUnflagged' => _("Unflag"), 'markFlagged' => _("Flag"), @@ -1055,7 +1066,8 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { 'undeleteButton' => _("Undelete"), 'bypass_trash' => _("Bypass Trash"), 'expungeButton' => _("Expunge"), - 'moveButton' => _("Move") + 'moveButton' => _("Move"), + 'copyButton' => _("Copy") ); @@ -1081,6 +1093,7 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) { $aFormElements[$k] = array($aButtonStrings[$k],'checkbox'); break; case 'moveButton': + case 'copyButton': $aFormElements['targetMailbox'] = array(sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes),'select'); $aFormElements['mailbox'] = array($aMailbox['NAME'],'hidden'); @@ -1223,6 +1236,7 @@ function handleAsSent($mailbox) { function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = array()) { /* incoming formdata */ $sButton = (sqgetGlobalVar('moveButton', $sTmp, SQ_POST)) ? 'move' : $sButton; + $sButton = (sqgetGlobalVar('copyButton', $sTmp, SQ_POST)) ? 'copy' : $sButton; $sButton = (sqgetGlobalVar('expungeButton', $sTmp, SQ_POST)) ? 'expunge' : $sButton; $sButton = (sqgetGlobalVar('forward', $sTmp, SQ_POST)) ? 'forward' : $sButton; $sButton = (sqgetGlobalVar('delete', $sTmp, SQ_POST)) ? 'setDeleted' : $sButton; @@ -1271,6 +1285,10 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar sqsession_register($targetMailbox,'lastTargetMailbox'); $bExpunge = true; break; + case 'copy': + $aUpdatedMsgs = sqimap_msgs_list_copy($imapConnection,$aUid,$targetMailbox,true,$mailbox); + sqsession_register($targetMailbox,'lastTargetMailbox'); + break; case 'forward': $aMsgHeaders = array(); foreach ($aUid as $iUid) { diff --git a/include/load_prefs.php b/include/load_prefs.php index 47a0a502..012c8e3c 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -403,6 +403,11 @@ $chosen_fontsize = getPref($data_dir, $username, 'chosen_fontsize', $default_fon * @since 1.5.2 */ $translate_special_folders = getPref($data_dir, $username, 'translate_special_folders', SMPREF_OFF); +/** + * Controls display of message copy options + * @since 1.5.2 + */ +$show_copy_buttons = getPref($data_dir, $username, 'show_copy_buttons', SMPREF_OFF); /** Put in a safety net for authentication here, in case a naughty admin didn't run conf.pl when they upgraded */ diff --git a/include/options/display.php b/include/options/display.php index fb8daa90..98f1d044 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -282,6 +282,13 @@ function load_optpage_data_display() { 'refresh' => SMOPT_REFRESH_NONE ); + $optvals[SMOPT_GRP_MAILBOX][] = array( + 'name' => 'show_copy_buttons', + 'caption' => _("Enable Message Copy Buttons"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + $optvals[SMOPT_GRP_MAILBOX][] = array( 'name' => 'page_selector', 'caption' => _("Enable Page Selector"), diff --git a/src/read_body.php b/src/read_body.php index 410517bf..882e3f7d 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -488,7 +488,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed global $base_uri, $draft_folder, $where, $what, $color, $sort, $startMessage, $PHP_SELF, $save_as_draft, $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, - $username, $delete_prev_next_display, + $username, $delete_prev_next_display, $show_copy_buttons, $compose_new_win, $javascript_on, $compose_width, $compose_height; //FIXME cleanup argument list, use $aMailbox where possible @@ -708,7 +708,14 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed } $menu_row .= ' '; - $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n" . ''; + $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n"; + + // Add msg copy button + if ($show_copy_buttons) { + $menu_row .= getButton('submit', 'copyButton', _("Copy")); + } + + $menu_row .= ''; } $menu_row .= ''; diff --git a/templates/default/message_list.tpl b/templates/default/message_list.tpl index 2ea3c96f..f45ad87c 100644 --- a/templates/default/message_list.tpl +++ b/templates/default/message_list.tpl @@ -131,7 +131,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; foreach ($aFormElements as $key => $value) { switch ($value[1]) { case 'submit': - if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell + if ($key != 'moveButton' && $key != 'copyButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell ?>   + + + +