Index: functions/mailbox_display.php
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/functions/mailbox_display.php,v
retrieving revision 1.321.2.30
diff -u -r1.321.2.30 mailbox_display.php
--- functions/mailbox_display.php	9 Nov 2005 21:08:19 -0000	1.321.2.30
+++ functions/mailbox_display.php	1 Dec 2005 13:24:46 -0000
@@ -18,6 +18,7 @@
 require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'class/html.class.php');
 require_once(SM_PATH . 'functions/imap_mailbox.php');
+require_once(SM_PATH . 'functions/forms.php');
 
 /* Constants:
  *   PG_SEL_MAX:   default value for page_selector_max
@@ -180,10 +181,12 @@
                             }
                             break;
                         default:
-                            $headertest = strtolower(decodeHeader($msg[$match_type], true, false));
-                            if (strstr('^^' . $headertest, $high_val)) {
-                                $hlt_color = $message_highlight_list_part['color'];
-                                break 3;
+                            if(isset($msg[$match_type])) {
+                                $headertest = strtolower(decodeHeader($msg[$match_type], true, false));
+                                if (strstr('^^' . $headertest, $high_val)) {
+                                    $hlt_color = $message_highlight_list_part['color'];
+                                    break 3;
+                                }
                             }
                             break;
                     }
@@ -252,39 +255,60 @@
                 echo html_tag( 'td', $td_str, 'left', $hlt_color );
                 break;
             case 5: /* flags */
-                $stuff = false;
                 $td_str = "<b><small>";
 
-                if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) {
-                    $td_str .= _("A");
-                    $stuff = true;
-                }
-                if ($msg['TYPE0'] == 'multipart') {
-                    $td_str .= '+';
-                    $stuff = true;
+                if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) {
+                    $msg_alt = _("This message is Flagged");
+                    $td_str .= '<IMG SRC="../plugins/msg_flags/flagged.gif" border="0" height="10" width="10" alt="'. $msg_alt .'" title="'. $msg_alt .'"> ';
                 }
                 if ($default_use_priority) {
                     if ( ($msg['PRIORITY'] == 1) || ($msg['PRIORITY'] == 2) ) {
-                        $td_str .= "<font color=\"$color[1]\">!</font>";
-                        $stuff = true;
+                        $msg_alt = _("This message is High Priority");
+                        $td_str .= '<IMG SRC="../plugins/msg_flags/prio_high.gif" border="0" height="10" width="5" alt="'. $msg_alt .'" title="'. $msg_alt .'"> ';
+                    }
+                    elseif ($msg['PRIORITY'] == 5) {
+                        $msg_alt = _("This message is Low Priority");
+                        $td_str .= '<IMG SRC="../plugins/msg_flags/prio_low.gif" border="0" height="10" width="5" alt="'. $msg_alt .'" title="'. $msg_alt .'"> ';
+                    }
+                    else {
+                        $td_str .= '<IMG SRC="../plugins/msg_flags/transparent.gif" border="0" height="10" width="6">';
+                    }
+                }
+                if ($msg['TYPE0'] == 'multipart') {
+                    $msg_alt = _("This message is Mulitpart");
+                    $td_str .= '<IMG SRC="../plugins/msg_flags/attach.gif" border="0" height="10" width="6" alt="'. $msg_alt .'" title="'. $msg_alt .'">';
+                }
+                else {
+                    $td_str .= '<IMG SRC="../plugins/msg_flags/transparent.gif" border="0" height="10" width="6">';
                     }
-                    if ($msg['PRIORITY'] == 5) {
-                        $td_str .= "<font color=\"$color[8]\">?</font>";
-                        $stuff = true;
+
+                $msg_icon = '';
+
+                if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == true) {
+                    $msg_alt = _("This message is Read");
+                    $msg_icon .= "../plugins/msg_flags/msg_read";
                     }
+                else {
+                    $msg_alt = _("This message is New");
+                    $msg_icon .= '../plugins/msg_flags/msg_new';
                 }
                 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) {
-                    $td_str .= "<font color=\"$color[1]\">D</font>";
-                    $stuff = true;
+                    $msg_alt .= _(" & Deleted");
+                    $msg_icon .= '_deleted';
                 }
-                if (!$stuff) {
-                    $td_str .= '&nbsp;';
+                if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) {
+                    $msg_alt .= _(" & Answered");
+                    $msg_icon .= '_reply';
                 }
+
+                $td_str .= '<IMG SRC="' . $msg_icon . '.gif" border="0" alt="'. $msg_alt . '" title="' . $msg_alt . '" height="12" width="18" ></small></b>';
+
+                $td_str .= '&nbsp;';
                 do_hook("msg_envelope");
                 $td_str .= '</small></b>';
                 echo html_tag( 'td',
                                $td_str,
-                               'center',
+                               'right',
                                $hlt_color,
                                'nowrap' );
                 break;
@@ -518,6 +542,7 @@
     echo '     <tr><td>';
     echo '       <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[5].'">';
     echo '<tr><td>';
+
     printHeader($mailbox, $srt, $color, !$thread_sort_messages);
 
     displayMessageArray($imapConnection, $num_msgs, $start_msg,
@@ -751,6 +776,8 @@
              .'&nbsp;' . _("mailbox") . "\n";
     }
 
+    echo getButton('SUBMIT', 'markFlagged',_("Flag"));
+    echo getButton('SUBMIT', 'markUnflagged',_("Unflag"));
     echo getButton('SUBMIT', 'markRead',_("Read"));
     echo getButton('SUBMIT', 'markUnread',_("Unread"));
     echo getButton('SUBMIT', 'delete',_("Delete")) ."&nbsp;\n";
@@ -767,6 +794,10 @@
          . "   </TR>\n";
 
     /* draws thread sorting links */
+    /* Hacked by Avel :-P */
+   if(isset($_GET['submit']) && isset($_GET['what'])) {
+     $allow_thread_sort = false;
+   }
     if ($allow_thread_sort == TRUE) {
         if ($thread_sort_messages == 1 ) {
             $set_thread = 2;
@@ -781,7 +812,10 @@
                               . "$sort" . '&amp;start_messages=1&amp;set_thread=' . "$set_thread"
                               . '&amp;mailbox=' . urlencode($mailbox) . '">' . $thread_name
                               . '</a></small>&nbsp;'
-                     , '', '', '' )
+                     , 'left', '', '' ) .
+                    html_tag( 'td' ,
+		    		concat_hook_function('mailbox_form_buttons_below', NULL)
+                     , 'right', '', '' )
                  , '', '', '' );
     }
 
@@ -837,6 +871,8 @@
         $subjectwidth -= $widths[$item];
     }
 
+    /* Hacked by Avel :-P */
+   if(!isset($_GET['submit']) && !isset($_GET['what'])) {
     foreach ($index_order as $item) {
         switch ($item) {
         case 1: /* checkbox */
@@ -877,6 +913,7 @@
             break;
         }
     }
+   }
     echo "</tr>\n";
 }
 
@@ -924,7 +961,9 @@
                 . "\n<!-- \n"
                 . "function " . $func_name . "() {\n"
                 . "  for (var i = 0; i < document." . $form_name . ".elements.length; i++) {\n"
-                . "    if(document." . $form_name . ".elements[i].type == 'checkbox'){\n"
+                . "    if(document." . $form_name . ".elements[i].type == 'checkbox' \n "
+                . "       && document." . $form_name . ".elements[i].name.substring(0,3) == 'msg' "
+		. "       ){\n"
                 . "      document." . $form_name . ".elements[i].checked = "
                 . "        !(document." . $form_name . ".elements[i].checked);\n"
                 . "    }\n"
