-$aLastSelectedMailbox['NAME'] = $mailbox;
-$aLastSelectedMailbox['EXISTS'] = $aMbxResponse['EXISTS'];
-$aLastSelectedMailbox['UIDVALIDITY'] = $aMbxResponse['UIDVALIDITY'];
-$aLastSelectedMailbox['UIDNEXT'] = $aMbxResponse['UIDNEXT'];
-$aLastSelectedMailbox['PERMANENTFLAGS'] = $aMbxResponse['PERMANENTFLAGS'];
-$aLastSelectedMailbox['OFFSET'] = (isset($startMessage) && $startMessage) ? $startMessage -1 : 0;
-$aLastSelectedMailbox['PAGEOFFSET'] = (isset($startMessage) && $startMessage) ? $startMessage : 1;
-$aLastSelectedMailbox['SORT'] = ($sort !== false) ? $sort : 0;
-$aLastSelectedMailbox['LIMIT'] = ($show_num != 999999) ? $show_num : $aMbxResponse['EXISTS'];
-
-$aLastSelectedMailbox['UIDSET'] = $aMbxResponse['SORT_ARRAY'];
-$aLastSelectedMailbox['SEEN'] = (isset($aMbxResponse['SEEN'])) ? $aMbxResponse['SEEN'] : $aMbxResponse['EXISTS'];
-$aLastSelectedMailbox['RECENT'] = (isset($aMbxResponse['RECENT'])) ? $aMbxResponse['RECENT'] : 0;
-
-$aLastSelectedMailbox['AUTO_EXPUNGE'] = $auto_expunge;
-
-/* decide if we are thread sorting or not */
-$aLastSelectedMailbox['ALLOW_THREAD'] = $allow_thread_sort;
-if ($allow_thread_sort == TRUE) {
- if (isset($set_thread)) {
- $aLastSelectedMailbox['SORT_ARRAY'] = false;
- if (sqsession_is_registered('indent_array')) {
- sqsession_unregister('indent_array');
- }
- if (sqsession_is_registered('server_sort_array')) {
- sqsession_unregister('server_sort_array');
- }
- if ($set_thread == 1) {
- setPref($data_dir, $username, "thread_$mailbox", 1);
- $thread_sort_messages = '1';
- } else if ($set_thread == 2) {
- setPref($data_dir, $username, "thread_$mailbox", 0);
- $thread_sort_messages = '0';
- }
+/*
+ * If we try to forward messages as attachment we have to open a new window
+ * in case of compose in new window or redirect to compose.php
+ */
+if (isset($aMailbox['FORWARD_SESSION'])) {
+ if ($compose_new_win) {
+ // write the session in order to make sure that the compose window has
+ // access to the composemessages array which is stored in the session
+ session_write_close();
+ sqsession_is_active();
+ $comp_uri = SM_PATH . 'src/compose.php?mailbox='. urlencode($mailbox).
+ '&session='.$aMailbox['FORWARD_SESSION'];
+ displayPageHeader($color, $mailbox, "comp_in_new('$comp_uri');", false);