Added basic support for message highlighting. Note that this needs quite
[squirrelmail.git] / functions / mailbox_display.php
index b36e00a901554d051f50202c7746e24ac7eb670a..afdbdb5c2201678ec430761fa22617b0709f20c9 100644 (file)
@@ -13,6 +13,7 @@
    function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage) {
       global $color, $msgs, $msort;
                global $sent_folder;
+      global $message_highlight_list;
 
                $msg = $msgs[$key];
 
       
       if ($msg["FLAG_FLAGGED"] == true) { $flag = "<font color=$color[2]>"; $flag_end = "</font>"; }
       if ($msg["FLAG_SEEN"] == false) { $bold = "<b>"; $bold_end = "</b>"; }
-      if ($msg["FLAG_ANSWERED"] == true) { $ans = "&nbsp;[A]"; }
                if ($mailbox == $sent_folder) { $italic = "<i>"; $italic_end = "</i>"; }
       
-      echo "   <td width=1% align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."></TD>\n";
-      echo "   <td width=30%>$italic$bold$flag$senderName$flag_end$bold_end$italic_end</td>\n";
-      echo "   <td nowrap width=1%><center>$bold$flag".$msg["DATE_STRING"]."$flag_end$bold_end</center></td>\n";
-      echo "   <td width=%>$bold<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0\">$flag$subject$flag_end</a>$ans$bold_end</td>\n";
+      for ($i=0; $i < count($message_highlight_list); $i++) {
+         if (eregi($message_highlight_list[$i]["value"],$msg["FROM"])) {
+            $hlt_color = $message_highlight_list[$i]["color"];
+            continue;
+         }   
+      }   
+      if (!$hlt_color)
+         $hlt_color = $color[4];
+      
+      echo "   <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."></TD>\n";
+      echo "   <td width=30% bgcolor=$hlt_color>$italic$bold$flag$senderName$flag_end$bold_end$italic_end</td>\n";
+      echo "   <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag".$msg["DATE_STRING"]."$flag_end$bold_end</center></td>\n";
+               if ($msg["FLAG_ANSWERED"] == true) echo "   <td bgcolor=$hlt_color width=1%><b><small>A</small></b></td>";
+               else    echo "   <td bgcolor=$hlt_color width=1%>&nbsp;</td>";
+      echo "   <td bgcolor=$hlt_color width=%>$bold<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0\">$flag$subject$flag_end</a>$bold_end</td>\n";
 
       echo "</tr>\n";
    }
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
       global $msgs, $msort;
                global $sent_folder;
+      global $message_highlight_list;
 
       if (!$use_cache) {
          if ($numMessages >= 1) {
             for ($q = 0; $q < $numMessages; $q++) {
                                        if ($mailbox == $sent_folder)
-                       sqimap_get_small_header ($imapConnection, $q+1, $f, $s, $d, true);
+                       $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
                                        else
-                       sqimap_get_small_header ($imapConnection, $q+1, $f, $s, $d, false);
+                       $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
                                                
-               $from[$q] = $f;
-               $date[$q] = $d;
-               $subject[$q] = $s;
+                                       $from[$q] = $hdr->from;
+                                       $date[$q] = $hdr->date;
+                                       $subject[$q] = $hdr->subject;
+
                $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
             }
          }
           ** 2 = Name (up)
           ** 3 = Name (dn)
           **/
-
+         session_unregister("msgs");
          if (($sort == 0) || ($sort == 1))
             $msort = array_cleave ($msgs, "TIME_STAMP");
          if (($sort == 2) || ($sort == 3))
          session_register("msort");
       }
       displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
+     session_register("msgs");
    }
 
    // generic function to convert the msgs array into an HTML table
 
       $boxes = sqimap_mailbox_list($imapConnection);
       for ($i = 0; $i < count($boxes); $i++) {
-         $box = $boxes[$i]["unformatted"];
-         $box2 = replace_spaces($boxes[$i]["formatted"]);
-         echo "         <OPTION VALUE=\"$box\">$box2\n";
+                       if ($boxes[$i]["flags"][0] != "noselect" && $boxes[$i]["flags"][1] != "noselect" && $boxes[$i]["flags"][2] != "noselect") {
+               $box = $boxes[$i]["unformatted"];
+               $box2 = replace_spaces($boxes[$i]["formatted"]);
+               echo "         <OPTION VALUE=\"$box\">$box2\n";
+                       }       
       }
       echo "         </SELECT></SMALL></TT>";
       echo "         <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"". _("Move") ."\"></SMALL></NOBR>\n";
          echo "   <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
       else
          echo "   <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
+      echo "   <TD WIDTH=1%>&nbsp;</TD>\n";
       /** SUBJECT HEADER **/
       echo "   <TD WIDTH=%><B>". _("Subject") ."</B>\n";
       if ($sort == 4)
          echo "   <A HREF=\"right_main.php?newsort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
       else
          echo "   <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
+
       echo "</TR>";
 
       
       // loop through and display the info for each message.
       $t = 0; // $t is used for the checkbox number
       if ($numMessages == 0) { // if there's no messages in this folder
-         echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=4><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp</CENTER></TD></TR>";
+         echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=5><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
       } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
          $i = $startMessage - 1;
          reset($msort);
          echo "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">" . _("Next") . "</A>\n";
       }
       echo "</TD></TR></TABLE>"; /** End of message-list table */
+
    }
 ?>