Index: src/move_messages.php =================================================================== --- src/move_messages.php (revision 748) +++ src/move_messages.php (working copy) @@ -130,11 +130,16 @@ sqgetGlobalVar('msgs', $msgs, SQ_SESSION); sqgetGlobalVar('composesession', $composesession, SQ_SESSION); -sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION); +if (!sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION)) { + $lastTargetMailbox = 'INBOX'; +} + sqgetGlobalVar('moveButton', $moveButton, SQ_POST); +sqgetGlobalVar('moveButton2', $moveButton2, SQ_POST); sqgetGlobalVar('expungeButton', $expungeButton, SQ_POST); sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_POST); +sqgetGlobalVar('targetMailbox2', $targetMailbox2, SQ_POST); sqgetGlobalVar('expungeButton', $expungeButton, SQ_POST); sqgetGlobalVar('undeleteButton', $undeleteButton, SQ_POST); sqgetGlobalVar('markRead', $markRead, SQ_POST); @@ -156,13 +161,14 @@ // make sure that cache is not used $location = set_url_var($location,'use_mailbox_cache',null,false); -/* remember changes to mailbox setting */ -if (!isset($lastTargetMailbox)) { - $lastTargetMailbox = 'INBOX'; -} +/** + * If user changes target mailbox and selects action which is not related to + * targetMailbox, remember top targetMailbox selection. If bottom targetMailbox + * is selected, it will be modified later + */ if ($targetMailbox != $lastTargetMailbox) { - $lastTargetMailbox = $targetMailbox; - sqsession_register($lastTargetMailbox, 'lastTargetMailbox'); + // save target mailbox in session + sqsession_register($targetMailbox, 'lastTargetMailbox'); } $exception = false; @@ -199,19 +205,25 @@ } else { $exception = true; } -} elseif (!isset($moveButton)) { +} elseif (!isset($moveButton) && !isset($moveButton2)) { + // It is not move action if (count($id)) { $cnt = count($id); if (!isset($attache)) { if (isset($markRead)) { + // mark as read action sqimap_toggle_flag($imapConnection, $id, '\\Seen',true,true); } elseif (isset($markUnread)) { + // mark as unread action sqimap_toggle_flag($imapConnection, $id, '\\Seen',false,true); } elseif (isset($markFlagged)) { + // flag action sqimap_toggle_flag($imapConnection, $id, '\\Flagged',true,true); } elseif (isset($markUnflagged)) { + // unflag action sqimap_toggle_flag($imapConnection, $id, '\\Flagged',false,true); } else { + // FIXME: default delete action sqimap_msgs_list_delete($imapConnection, $mailbox, $id); if ($auto_expunge) { $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true); @@ -225,6 +237,7 @@ } } } else { + // forward action $composesession = attachSelectedMessages($id, $imapConnection); $location = set_url_var($location, 'session', $composesession, false); if ($compose_new_win) { @@ -237,7 +250,15 @@ } else { $exception = true; } -} else { // Move messages +} else { + // Move messages + + // bottom form action + if (isset($moveButton2)) { + $targetMailbox = $targetMailbox2; + sqsession_register($targetMailbox2, 'lastTargetMailbox'); + } + if (count($id)) { // move messages only when target mailbox is not the same as source mailbox if ($mailbox!=$targetMailbox) { @@ -260,6 +281,7 @@ $exception = true; } } + // Log out this session sqimap_logout($imapConnection); if ($exception) { Index: functions/mailbox_display.php =================================================================== --- functions/mailbox_display.php (revision 696) +++ functions/mailbox_display.php (working copy) @@ -900,7 +900,7 @@ /** Print second set of controls only when more than 10 messages are displayed */ if ($num_msgs > 10) { echo ''; - nsm_print_mailbox_controls($mailbox, $sort); + nsm_print_mailbox_controls($mailbox, $sort, true); echo ''; } @@ -931,9 +931,10 @@ * mail_message_listing_end(). * @param string Current mailbox name * @param int Sorting order + * @param boolean (since 1.4) Is used to detect bottom mailbox controls * @since 1.3 */ -function nsm_print_mailbox_controls($mailbox, $sort) { +function nsm_print_mailbox_controls($mailbox, $sort, $second_ctrl=false) { global $color, $imapConnection, $auto_expunge, $use_msg_flags, $PHP_SELF, $allow_thread_sort, $thread_sort_messages; @@ -964,16 +965,21 @@ ) . html_tag( 'tr' ) ."\n" . html_tag( 'td', '', 'left', '', 'valign="middle" nowrap' ); - getMbxList($imapConnection); - echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n"; + getMbxList($imapConnection,($second_ctrl ? '2' : '')); + echo getButton('SUBMIT', 'moveButton' . ($second_ctrl ? '2' : ''),_("Move")) . "\n"; echo getButton('SUBMIT', 'attache',_("Forward")) . "\n"; /** * Hook allows plugins to add buttons to src/move_messages.form. * Hook output is displayed next to mailbox selection dropdown. + * + * Since 1.4 hook uses boolean argument to detect bottom controls. + * If bottom controls are used, plugins should add different submit + * action, use targetMailbox2 instead of targetMailbox and save + * targetMailbox2 value in lastTargetMailbox session variable. * @since 1.3 */ - do_hook('mailbox_controls_left'); + do_hook('mailbox_controls_left', $second_ctrl); echo " \n" . html_tag( 'td', '', 'right', '', 'nowrap' ); @@ -983,7 +989,8 @@ * Hook allows plugins to add buttons to src/move_messages.php form. * Hook output is displayed on the right side of mailbox controls header before * standard right side buttons. - * Plugin actions can be processed in move_before_move hook. + * Plugin actions can be processed in move_before_move hook. Plugin actions + * should not depend on target mailbox selection in left side of controls. * @since 1.3 */ do_hook('mailbox_controls_right'); @@ -1509,11 +1516,12 @@ /** * Creates targetMailbox selection box * - * @param stream imapConnection IMAP connection resource + * @param stream IMAP connection resource + * @param string (since 1.4) Mailbox dropdown suffix */ -function getMbxList($imapConnection) { +function getMbxList($imapConnection, $suffix='') { global $lastTargetMailbox; - echo '  '; echo sqimap_mailbox_option_list($imapConnection, array($lastTargetMailbox) ); echo '  '; }