fix bug 550586
[squirrelmail.git] / src / read_body.php
index 6122ea7169fd1a37df5ffc2e381d2bb75a220f9b..df3114793cdf30d3c7b115a8616d3fd39b712869 100644 (file)
@@ -28,10 +28,14 @@ require_once('../functions/smtp.php');
  */
 function findNextMessage() {
     global $msort, $currentArrayIndex, $msgs, $sort, 
-           $allow_thread_sort, $allow_server_sort,
+           $thread_sort_messages, $allow_server_sort,
            $server_sort_array;
+    if (!is_array($server_sort_array)) {
+        $thread_sort_messages = 0;
+        $allow_server_sort = FALSE;
+    }
     $result = -1;
-    if ($allow_thread_sort == true || $allow_server_sort == true) {
+    if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) {
         reset($server_sort_array);
         while(list($key, $value) = each ($server_sort_array)) {
             if ($currentArrayIndex == $value) {
@@ -44,13 +48,13 @@ function findNextMessage() {
             }
         }
     } 
-    elseif ($sort == 6 && $allow_server_sort != true &&
-            $allow_thread_sort != true) {
+    elseif ($sort == 6 && $allow_server_sort != TRUE &&
+            $thread_sort_messages != 1) {
         if ($currentArrayIndex != 1) {
             $result = $currentArrayIndex - 1;
         }
     }
-    elseif ($allow_server_sort != true && $allow_thread_sort != true) {
+    elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) {
         if (!is_array($msort)) {
             return -1;
         }
@@ -86,10 +90,14 @@ function RemoveAddress(&$addr_list, $addr) {
 /** returns the index of the previous message from the array. */
 function findPreviousMessage() {
     global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
-           $mailbox, $data_dir, $username, $allow_thread_sort,
+           $mailbox, $data_dir, $username, $thread_sort_messages,
            $allow_server_sort, $server_sort_array;
     $result = -1;
-    if ($allow_thread_sort == true || $allow_server_sort == TRUE) {
+    if (!is_array($server_sort_array)) {
+        $thread_sort_messages = 0;
+        $allow_server_sort = FALSE;
+    }
+    if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) {
         reset($server_sort_array);
         while(list($key, $value) = each ($server_sort_array)) {
             if ($currentArrayIndex == $value) {
@@ -103,13 +111,13 @@ function findPreviousMessage() {
         }
     }
     elseif ($sort == 6 && $allow_server_sort != TRUE && 
-            $allow_thread_sort != true) {
+            $thread_sort_messages != 1) {
         $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
         if ($currentArrayIndex != $numMessages) {
             $result = $currentArrayIndex + 1;
         }
     } 
-    elseif ($allow_thread_sort != true && $allow_server_sort != TRUE) {
+    elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
         if (!is_array($msort)) {
             return -1;
         }
@@ -206,6 +214,8 @@ function SendMDN ( $recipient , $sender) {
     $subject = $header->subject;
     $now = getLongDateString( time() );
 
+    set_my_charset();
+
     $body = _("Your message") . "\r\n\r\n" .
             "\t" . _("To:") . ' ' . $to . "\r\n" .
             "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
@@ -274,7 +284,7 @@ function ClearAttachments() {
                $rem_attachments[] = $info;
            }
        }
-        $attachments = rem_attachments;
+        $attachments = $rem_attachments;
 }
 
 function formatRecipientString($recipients, $item ) {
@@ -690,7 +700,7 @@ if (($mailbox == $draft_folder) && ($save_as_draft)) {
 }
 if ($mailbox == $sent_folder) {
     echo '|&nbsp;<A HREF="' . $base_uri .
-         "src/compose.php?mailbox=$mailbox&amp;identity=$identity&amp;send_to=$url_to_string&amp;send_to_cc=$url_cc_string&amp;send_to_bcc=$url_bcc_string&amp;subject=$url_subj&amp;mailprio=$priority_level&amp;draft_id=$passed_id&amp;ent_num=$ent_num" . '"';
+         "src/compose.php?mailbox=$mailbox&amp;identity=$identity&amp;send_to=$url_to_string&amp;send_to_cc=$url_cc_string&amp;send_to_bcc=$url_bcc_string&amp;subject=$url_subj&amp;mailprio=$priority_level&amp;ent_num=$ent_num" . '"';
     if ($compose_new_win == '1') {
         echo ' TARGET="compose_window" onClick="comp_in_new()"';
     }
@@ -948,7 +958,7 @@ if ($default_use_mdn) {
                     _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
                     "\")) {  \n" .
                     "                       window.location=($url); \n" .
-                    '                       window.reload()' . "\n" .
+                    '                       window.location.reload()' . "\n" .
                     '               }' . "\n" .
                     '// -->' . "\n" .
                     '</script>' . "\n";