patch #551871 for feature request #545070 from Stefan Tietke (stfn) regarding utf7...
[squirrelmail.git] / functions / mailbox_display.php
index f05e7af7f3f33d512c98dbb6ee636d5aecb4614b..3c412693200f800e502b12216387a4275a5506fc 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 require_once('../functions/strings.php');
+require_once('../functions/imap_utf7_decode_local.php');
 
 /* Default value for page_selector_max. */
 define('PG_SEL_MAX', 10);
@@ -190,11 +191,11 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort,
          $stuff = true;
        }
        if ($default_use_priority) {
-         if ( ($msg['PRIORITY'][0] == 1) || ($msg['PRIORITY'][0] == 2) ) {
+         if ( ($msg['PRIORITY'] == 1) || ($msg['PRIORITY'] == 2) ) {
            echo "<font color=\"$color[1]\">!</font>\n";
            $stuff = true;
          }
-         if ($msg['PRIORITY'][0] == 5) {
+         if ($msg['PRIORITY'] == 5) {
            echo "<font color=\"$color[8]\">?</font>\n";
            $stuff = true;
          }
@@ -411,9 +412,10 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
          $messages[$j]['FLAG_FLAGGED'] = true;
        }
        $num++;
-*/
       }
+*/
       $j++;
+
     }
 
     /*
@@ -625,6 +627,7 @@ function displayMessageArray($imapConnection, $num_msgs, $start_msg,
  * $Message is a message that is centered on top of the list
  * $More is a second line that is left aligned
  */
 function mail_message_listing_beginning ($imapConnection, $moveURL, 
                                         $mailbox = '', $sort = -1,
                                         $msg_cnt_str = '', 
@@ -632,14 +635,16 @@ function mail_message_listing_beginning ($imapConnection, $moveURL,
                                         $start_msg = 1) {
   global $color, $index_order, $auto_expunge, $move_to_trash, $base_uri,
     $checkall, $sent_folder, $draft_folder, $thread_sort_messages, 
-    $allow_thread_sort, $allow_server_sort, $server_sort_order;
+    $allow_thread_sort, $allow_server_sort, $server_sort_order,
+    $lastTargetMailbox;
+
   $urlMailbox = urlencode($mailbox);
 
   /*
    * This is the beginning of the message list table.
    * It wraps around all messages
    */
-  echo "<FORM name=messageList method=post action=\"$moveURL\">\n"
+  echo "<FORM name=\"messageList\" method=post action=\"$moveURL\">\n"
     . "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"1\" "
     . "CELLSPACING=\"0\">\n<TR BGCOLOR=\"$color[0]\"><TD>"
     . "    <TABLE BGCOLOR=\"$color[4]\" width=\"100%\" CELLPADDING=\"2\" "
@@ -650,7 +655,7 @@ function mail_message_listing_beginning ($imapConnection, $moveURL,
     . "  </TR></TABLE>\n"
     . '</TD></TR>'
     . "<TR><TD BGCOLOR=\"$color[0]\">\n"
-    . "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0"
+    . "<TABLE BGCOLOR=\"$color[0]\" BORDER=0 cellpadding=0 "
     . "cellspacing=0 width=\"100%\">\n"
     . "   <TR>\n"
     . "      <TD ALIGN=LEFT VALIGN=MIDDLE NOWRAP>\n"
@@ -669,11 +674,17 @@ function mail_message_listing_beginning ($imapConnection, $moveURL,
   foreach ($boxes as $boxes_part) {
     if (!in_array('noselect', $boxes_part['flags'])) {
       $box = $boxes_part['unformatted'];
-      $box2 = str_replace(' ', '&nbsp;', $boxes_part['unformatted-disp']);
+      $box2 = imap_utf7_decode_local(
+               str_replace(' ', '&nbsp;', $boxes_part['unformatted-disp']));
       if( $box2 == 'INBOX' ) {
        $box2 = _("INBOX");
       }
-      echo "         <OPTION VALUE=\"$box\">$box2</option>\n";
+      if ($lastTargetMailbox == $box) {
+        echo "       <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
+      }
+      else {
+        echo "         <OPTION VALUE=\"$box\">$box2</OPTION>\n";
+      }
     }
   }
   echo '         </SELECT></TT>&nbsp;'
@@ -697,15 +708,15 @@ function mail_message_listing_beginning ($imapConnection, $moveURL,
   if ($allow_thread_sort == TRUE) {
     if ($thread_sort_messages == 1 ) {
       $set_thread = 2;
-      $thread_name = 'Unthread View';
+      $thread_name = _("Unthread View");
     } 
        elseif ($thread_sort_messages == 0) {
       $set_thread = 1;
-      $thread_name = 'Thread View';
+      $thread_name = _("Thread View");
     }
     echo   '<tr><td>&nbsp;<a href=' . "$base_uri" . 'src/right_main.php?sort=' 
       . "$sort" . '&start_messages=1&set_thread=' . "$set_thread"
-      . '&mailbox=' . urlencode($mailbox) . '><small>' . _("$thread_name")
+      . '&mailbox=' . urlencode($mailbox) . '><small>' . $thread_name
       . '</a></small>&nbsp;</td></tr>';
   }
 
@@ -795,7 +806,7 @@ function ShowSortButton($sort, $mailbox, $Up, $Down) {
   echo ' <a href="right_main.php?newsort=' . $which
     . '&amp;startMessage=1&amp;mailbox=' . urlencode($mailbox)
     . '"><IMG SRC="../images/' . $img
-    . '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
+    . '" BORDER=0 WIDTH=12 HEIGHT=10 ALT="sort"></a>';
 }
 
 function get_selectall_link($start_msg, $sort) {