Fixes for minor bugs pointed out by Tyler Akins.
[squirrelmail.git] / functions / mailbox_display.php
index 74cdc82ccade18b8187b4de9290a34b37a83f370..d0706aae41d238e8660f7b011c2a17752e05f115 100644 (file)
@@ -118,7 +118,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
     * AAAAH! Make my eyes stop bleeding!
     * Who wrote this?!
     */
-    if (sizeof($message_highlight_list)){
+    if (is_array($message_highlight_list) && count($message_highlight_list)){
         foreach ($message_highlight_list as $message_highlight_list_part) {
             if (trim($message_highlight_list_part['value']) != '') {
                 $high_val   = strtolower($message_highlight_list_part['value']);
@@ -142,7 +142,7 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
     if (!isset($hlt_color)) {
         $hlt_color = $color_string;
     }
-    $checked = ($checkall == 1) ? true : false;
+    $checked = ($checkall == 1) ? ' CHECKED' : '';
     $col = 0;
     if (sizeof($index_order)) {
         foreach ($index_order as $index_order_part) {
@@ -455,12 +455,19 @@ function calc_msort($msgs, $sort) {
      * 4 = Subject (up)
      * 5 = Subject (dn)
      */
+
     if (($sort == 0) || ($sort == 1)) {
-        $msort = array_cleave ($msgs, 'TIME_STAMP');
+        foreach ($msgs as $item) {
+            $msort[] = $item['TIME_STAMP'];
+        }
     } elseif (($sort == 2) || ($sort == 3)) {
-        $msort = array_cleave ($msgs, 'FROM-SORT');
+        foreach ($msgs as $item) {
+            $msort[] = $item['FROM-SORT'];
+        }
     } elseif (($sort == 4) || ($sort == 5)) {
-        $msort = array_cleave ($msgs, 'SUBJECT-SORT');
+        foreach ($msgs as $item) {
+            $msort[] = $item['SUBJECT-SORT'];
+        }
     } else {
         $msort = $msgs;
     }
@@ -543,8 +550,7 @@ function fillMessageArray($imapConnection, $id, $count) {
 function displayMessageArray($imapConnection, $num_msgs, $start_msg,
                              $msort, $mailbox, $sort, $color,
                              $show_num, $where=0, $what=0) {
-    global $imapServerAddress, $use_mailbox_cache,
-           $index_order, $checkall,
+    global $imapServerAddress, $use_mailbox_cache, $index_order,
            $indent_array, $thread_sort_messages, $allow_server_sort,
            $server_sort_order, $PHP_SELF;
 
@@ -1193,21 +1199,7 @@ function processSubject($subject) {
 function getMbxList($imapConnection) {
     global $lastTargetMailbox;
     echo  '         <small>&nbsp;<tt><select name="targetMailbox">';
-    $boxes = sqimap_mailbox_list($imapConnection);
-    foreach ($boxes as $boxes_part) {
-        if (!in_array('noselect', $boxes_part['flags'])) {
-            $box = $boxes_part['unformatted'];
-            $box2 = str_replace(' ', '&nbsp;', imap_utf7_decode_local($boxes_part['unformatted-disp']));
-            if($box2 == 'INBOX') {
-                $box2 = _("INBOX");
-            }
-            if ($lastTargetMailbox == $box) {
-                echo "       <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
-            } else {
-                echo "         <OPTION VALUE=\"$box\">$box2</OPTION>\n";
-            }
-        }
-    }
+    echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)) ); 
     echo '         </SELECT></TT>&nbsp;';
 }