adding message copy buttons.
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 4 Jun 2006 09:18:20 +0000 (09:18 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 4 Jun 2006 09:18:20 +0000 (09:18 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11178 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
functions/mailbox_display.php
include/load_prefs.php
include/options/display.php
src/read_body.php
templates/default/message_list.tpl

index 24ac9bed2b131bf2241b5695df1427734f9cbd3a..10f83cee9cfbe61c440ec8efe61df418647c210c 100644 (file)
--- 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)
 --------------------------------------
index f17071d347bdee5c56311df01c3b4b3681331a45..e296416bbf49ccd1799d8636fe9dc0e1fb934b2c 100644 (file)
@@ -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) {
index 47a0a502f01e8150d8083d2b6a437cc39677ce91..012c8e3c49d9e3264e6cace5788b85a276ea43f2 100644 (file)
@@ -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 */
 
index fb8daa90a5b3f92da4e1d9b6f0bae267448d72e9..98f1d04465ed61931814032a6286ed1ad4c58574 100644 (file)
@@ -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"),
index 410517bf5ea12aba8e0d42fe68d01171be27af0a..882e3f7dc5bc70eab3c56d745705ff5e8e794dcf 100644 (file)
@@ -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 .= '</select> ';
 
-        $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n" . '</form>';
+        $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n";
+
+        // Add msg copy button
+        if ($show_copy_buttons) {
+            $menu_row .= getButton('submit', 'copyButton', _("Copy"));
+        }
+
+        $menu_row .= '</form>';
     }
     $menu_row .= '</td></tr>';
 
index 2ea3c96f0d2ae597c5128c2f833a01d00ae877ce..f45ad87c46ccc0dbb7c3ae0cf297216f83d0e0ed 100644 (file)
@@ -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
 ?>
                   <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />&nbsp;
 <?php
@@ -174,13 +174,18 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
               </td>
 <?php
         } // if (isset($aFormElements['delete']))
-        if (isset($aFormElements['moveButton'])) {
+        if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
 ?>
               <td class="message_control_move">
                     <select name="targetMailbox">
                        <?php echo $aFormElements['targetMailbox'][0];?>
                     </select>
+<?php         if (isset($aFormElements['moveButton'])) { ?>
                   <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
+<?php         }
+              if (isset($aFormElements['copyButton'])) { ?>
+                  <input type="submit" name="copyButton" value="<?php echo $aFormElements['copyButton'][0]; ?>" class="message_control_button" />
+<?php         } ?>
               </td>
 
 <?php