Implement ability to move to next message after moving the one you are viewing, per...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 8 May 2020 00:59:52 +0000 (00:59 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 8 May 2020 00:59:52 +0000 (00:59 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14856 7612ce4b-ef26-0410-bec9-ea0150e637f0

include/load_prefs.php
include/options/display.php
src/read_body.php

index 2eb50b7945419759101b797303e7124758dda2ae..633531349697b5b4663bcc2dc06295da8bdf0077 100644 (file)
@@ -354,6 +354,7 @@ $truncate_subject = getPref($data_dir, $username, 'truncate_subject', 50);
 $show_recipient_instead = getPref($data_dir, $username, 'show_recipient_instead', SMPREF_OFF);
 
 $delete_prev_next_display = getPref($data_dir, $username, 'delete_prev_next_display', SMPREF_ON);
+$return_to_message_list_after_move = getPref($data_dir, $username, 'return_to_message_list_after_move', SMPREF_ON);
 
 /**
  * Access keys
index 1effe44a4a2de21c03f2d8481cc2f81c24e96c69..33496d569ece8e6221097a3712f0c0b3036c5b24 100644 (file)
@@ -408,6 +408,13 @@ FIXME!
         'refresh' => SMOPT_REFRESH_ALL
     );
 
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
+        'name'    => 'return_to_message_list_after_move',
+        'caption' => _("Return To Message List After Move"),
+        'type'    => SMOPT_TYPE_BOOLEAN,
+        'refresh' => SMOPT_REFRESH_NONE
+    );
+
 
 
     /*** Load the Address Book Options into the array ***/
index 1a0e54577d9e0b5aa118356a9d83d5f4916c4309..dbc58c3593863b4fef9c32b35288111b31613a29 100644 (file)
@@ -37,7 +37,7 @@ require_once(SM_PATH . 'functions/compose.php');
  * and sorted msgs array and return the index of the next message
  *
  * @param int $passed_id The current message UID
- * @return the index of the next valid message from the array
+ * @return the index of the next valid message from the array or -1 if there is no next message
  */
 function findNextMessage($uidset,$passed_id='backwards') {
     if (!is_array($uidset)) {
@@ -59,7 +59,7 @@ function findNextMessage($uidset,$passed_id='backwards') {
  * and sorted msgs array and return the index of the previous message
  *
  * @param int $passed_id The current message UID
- * @return the index of the next valid message from the array
+ * @return the index of the previous valid message from the array or -1 if there is no previous message
  */
 
 function findPreviousMessage($uidset, $passed_id) {
@@ -479,7 +479,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,
            $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
            $delete_prev_next_display, $show_copy_buttons,
            $compose_new_win, $compose_width, $compose_height,
-           $oTemplate;
+           $oTemplate, $return_to_message_list_after_move;
 
     //FIXME cleanup argument list, use $aMailbox where possible
     $mailbox = $aMailbox['NAME'];
@@ -640,16 +640,22 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,
 
     $oTemplate->assign('mailboxes', sqimap_mailbox_option_array($imapConnection));
     if (in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true)) {
-        $delete_url = $base_uri . "src/$where";
         $oTemplate->assign('can_be_deleted', true);
-        $oTemplate->assign('move_delete_form_action', $base_uri.'src/'.$where);
+        // force return-to-message-list if this is the only message in the folder
+        if ($return_to_message_list_after_move || ($next < 0 && $prev < 0))
+            $oTemplate->assign('move_delete_form_action', $base_uri.'src/'.$where);
+        else
+            $oTemplate->assign('move_delete_form_action', $base_uri.'src/read_body.php');
         $oTemplate->assign('delete_form_extra', addHidden('mailbox', $aMailbox['NAME'])."\n" .
                                                 addHidden('msg[0]', $passed_id)."\n" .
                                                 addHidden('startMessage', $startMessage)."\n" );
         if (!(isset($passed_ent_id) && $passed_ent_id)) {
             $oTemplate->assign('can_be_moved', true);
             $oTemplate->assign('move_form_extra', addHidden('mailbox', $aMailbox['NAME'])."\n" .
-                                                  addHidden('msg[0]', $passed_id)."\n" );
+                                                  addHidden('msg[0]', $passed_id)."\n" .
+                                                  // only need when $return_to_message_list_after_move is off
+                                                  addHidden('passed_id', ($next >= 0 ? $next : $prev))."\n" .
+                                                  addHidden('startMessage', $startMessage)."\n" );
             $oTemplate->assign('last_move_target', isset($lastTargetMailbox) && !empty($lastTargetMailbox) ? $lastTargetMailbox : '');
             $oTemplate->assign('can_be_copied', $show_copy_buttons==1);
         } else {
@@ -929,6 +935,14 @@ if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) {
     handleMessageListForm($imapConnection,$aMailbox,$sButton='setDeleted', array($delete_id));
 }
 
+/**
+ * or move button... why is handleMessageListForm (per above) conditional anway?
+ */
+if ( sqgetGlobalVar('moveButton', $ignore, SQ_POST) ) {
+    $sError = handleMessageListForm($imapConnection,$aMailbox);
+    sqgetGlobalVar('targetMailbox', $lastTargetMailbox, SQ_POST);
+}
+
 /**
  * $message contains all information about the message
  * including header and body