X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=afdbdb5c2201678ec430761fa22617b0709f20c9;hp=da874a999068ef725d3d6385cd4abaa91aa1eb6c;hb=9d157cec2821461fe4d348a47e2312db5e84c052;hpb=9f2215a1f40978a370a7538229ca2f55f55026ee
diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php
index da874a99..afdbdb5c 100644
--- a/functions/mailbox_display.php
+++ b/functions/mailbox_display.php
@@ -10,9 +10,12 @@
$mailbox_info = true;
- function printMessageInfo($imapConnection, $t, $msg, $mailbox, $sort, $startMessage) {
- //require ("../config/config.php");
- global $color;
+ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage) {
+ global $color, $msgs, $msort;
+ global $sent_folder;
+ global $message_highlight_list;
+
+ $msg = $msgs[$key];
$senderName = $msg["FROM"];
$urlMailbox = urlencode($mailbox);
@@ -21,12 +24,23 @@
if ($msg["FLAG_FLAGGED"] == true) { $flag = ""; $flag_end = ""; }
if ($msg["FLAG_SEEN"] == false) { $bold = ""; $bold_end = ""; }
- if ($msg["FLAG_ANSWERED"] == true) { $ans = " [A]"; }
+ if ($mailbox == $sent_folder) { $italic = ""; $italic_end = ""; }
+
+ 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 "
| \n";
- echo " $bold$flag$senderName$flag_end$bold_end | \n";
- echo " $bold$flag".$msg["DATE_STRING"]."$flag_end$bold_end | \n";
- echo " $bold$flag$subject$flag_end$ans$bold_end | \n";
+ echo " | \n";
+ echo " $italic$bold$flag$senderName$flag_end$bold_end$italic_end | \n";
+ echo " $bold$flag".$msg["DATE_STRING"]."$flag_end$bold_end | \n";
+ if ($msg["FLAG_ANSWERED"] == true) echo " A | ";
+ else echo " | ";
+ echo " $bold$flag$subject$flag_end$bold_end | \n";
echo "\n";
}
@@ -34,141 +48,122 @@
/**
** This function loops through a group of messages in the mailbox and shows them
**/
- function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color) {
- include ("../config/config.php");
-
- if ($numMessages >= 1) {
- for ($q = 0; $q < $numMessages; $q++) {
- sqimap_get_small_header ($imapConnection, $q+1, $f, $s, $d);
- $from[$q] = $f;
- $date[$q] = $d;
- $subject[$q] = $s;
- $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
- }
- }
-
- $j = 0;
- while ($j < $numMessages) {
- $date[$j] = ereg_replace(" ", " ", $date[$j]);
- $tmpdate = explode(" ", trim($date[$j]));
-
- $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
- $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
- $messages[$j]["ID"] = $j+1;
- $messages[$j]["FROM"] = decodeHeader($from[$j]);
- $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
-
- $num = 0;
- while ($num < count($flags[$j])) {
- if ($flags[$j][$num] == "Deleted") {
- $messages[$j]["FLAG_DELETED"] = true;
- }
- else if ($flags[$j][$num] == "Answered") {
- $messages[$j]["FLAG_ANSWERED"] = true;
- }
- else if ($flags[$j][$num] == "Seen") {
- $messages[$j]["FLAG_SEEN"] = true;
+ 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)
+ $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
+ else
+ $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
+
+ $from[$q] = $hdr->from;
+ $date[$q] = $hdr->date;
+ $subject[$q] = $hdr->subject;
+
+ $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
}
- else if ($flags[$j][$num] == "Flagged") {
- $messages[$j]["FLAG_FLAGGED"] = true;
+ }
+
+ $j = 0;
+ while ($j < $numMessages) {
+ $date[$j] = ereg_replace(" ", " ", $date[$j]);
+ $tmpdate = explode(" ", trim($date[$j]));
+
+ $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
+ $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
+ $messages[$j]["ID"] = $j+1;
+ $messages[$j]["FROM"] = decodeHeader($from[$j]);
+ $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
+
+ $num = 0;
+ while ($num < count($flags[$j])) {
+ if ($flags[$j][$num] == "Deleted") {
+ $messages[$j]["FLAG_DELETED"] = true;
+ }
+ else if ($flags[$j][$num] == "Answered") {
+ $messages[$j]["FLAG_ANSWERED"] = true;
+ }
+ else if ($flags[$j][$num] == "Seen") {
+ $messages[$j]["FLAG_SEEN"] = true;
+ }
+ else if ($flags[$j][$num] == "Flagged") {
+ $messages[$j]["FLAG_FLAGGED"] = true;
+ }
+ $num++;
}
- $num++;
+ $j++;
}
- $j++;
- }
-
- /** Find and remove the ones that are deleted */
- $i = 0;
- $j = 0;
- while ($j < $numMessages) {
- if ($messages[$j]["FLAG_DELETED"] == true) {
+
+ /** Find and remove the ones that are deleted */
+ $i = 0;
+ $j = 0;
+ while ($j < $numMessages) {
+ if ($messages[$j]["FLAG_DELETED"] == true) {
+ $j++;
+ continue;
+ }
+ $msgs[$i] = $messages[$j];
+
+ $i++;
$j++;
- continue;
}
- $msgs[$i] = $messages[$j];
-
- $i++;
- $j++;
- }
-
- $numMessages = $i;
+ $numMessages = $i;
+ }
// There's gotta be messages in the array for it to sort them.
- if ($numMessages > 0) {
+ if (($numMessages > 0) && (!$use_cache)) {
/** 0 = Date (up) 4 = Subject (up)
** 1 = Date (dn) 5 = Subject (dn)
** 2 = Name (up)
** 3 = Name (dn)
**/
-
- if ($sort == 0)
- $msgs = ary_sort($msgs, "TIME_STAMP", -1);
- else if ($sort == 1)
- $msgs = ary_sort($msgs, "TIME_STAMP", 1);
- else {
-
- $original = $msgs;
- $i = 0;
- while ($i < count($msgs)) {
- $msgs[$i]["FROM"] = strtolower($msgs[$i]["FROM"]);
- $msgs[$i]["SUBJECT"] = strtolower($msgs[$i]["SUBJECT"]);
- $i++;
- }
-
- if ($sort == 2)
- $msgs = ary_sort($msgs, "FROM", -1);
- else if ($sort == 3)
- $msgs = ary_sort($msgs, "FROM", 1);
- else if ($sort == 4)
- $msgs = ary_sort($msgs, "SUBJECT", -1);
- else if ($sort == 5)
- $msgs = ary_sort($msgs, "SUBJECT", 1);
- else
- $msgs = ary_sort($msgs, "TIME_STAMP", -1);
-
- $i = 0;
- while ($i < count($msgs)) {
- $j = 0;
- $loop = true;
- while ($j < count($original)) {
- if ($msgs[$i]["ID"] == $original[$j]["ID"]) {
- $msgs[$i]["FROM"] = $original[$j]["FROM"];
- $msgs[$i]["SUBJECT"] = $original[$j]["SUBJECT"];
-
- // exit out of this loop if we find the thing.
- $j = count($original) + 1;
- }
- $j++;
- }
- $i++;
- }
+ session_unregister("msgs");
+ if (($sort == 0) || ($sort == 1))
+ $msort = array_cleave ($msgs, "TIME_STAMP");
+ if (($sort == 2) || ($sort == 3))
+ $msort = array_cleave ($msgs, "FROM");
+ if (($sort == 4) || ($sort == 5))
+ $msort = array_cleave ($msgs, "SUBJECT");
+
+ if(($sort % 2) == 1) {
+ asort($msort);
+ } else {
+ arsort($msort);
}
+ session_register("msort");
}
-
-// session_register("messages");
-// $messages = serialize($msgs);
-
- displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $mailbox, $sort, $color);
+ 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
- function displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $mailbox, $sort, $color) {
+ function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
+ global $folder_prefix, $sent_folder;
+ global $imapServerAddress;
+
// do a check to see if the config stuff has already been included or not
- if (!isset($imapServerAddress))
- include("../config/config.php");
+// if (!isset($imapServerAddress))
+// include("../config/config.php");
// if cache isn't already set, do it now
-// if (!session_is_registered("messages"))
-// session_register("messages");
-
- if ($startMessage + 24 < $numMessages) {
- $endMessage = $startMessage + 24;
+ if (!session_is_registered("msgs"))
+ session_register("msgs");
+ if (!session_is_registered("msort"))
+ session_register("msort");
+
+ if ($startMessage + ($show_num - 1) < $numMessages) {
+ $endMessage = $startMessage + ($show_num-1);
} else {
$endMessage = $numMessages;
}
- $nextGroup = $startMessage + 25;
- $prevGroup = $startMessage - 25;
+ $nextGroup = $startMessage + $show_num;
+ $prevGroup = $startMessage - $show_num;
$urlMailbox = urlencode($mailbox);
/** This is the beginning of the message list table. It wraps around all messages */
@@ -179,30 +174,30 @@
echo "". _("Viewing messages ") ."$startMessage". _(" to ") ."$endMessage ($numMessages total)\n";
echo "\n";
} else if ($startMessage == $endMessage) {
- echo "\"TD>";
+ echo "
";
echo "". _("Viewing message ") ."$startMessage ($numMessages ". _("total") .")\n";
echo " |
\n";
}
echo "";
if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
- echo "". _("Previous") ."\n";
- echo "". _("Next") ."\n";
+ echo "". _("Previous") ."\n";
+ echo "". _("Next") ."\n";
}
else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
- echo "". _("Previous") ."\n";
+ echo "". _("Previous") ."\n";
echo "Next\n";
}
else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
echo "Previous\n";
- echo "". _("Next") ."\n";
+ echo "". _("Next") ."\n";
}
echo " |
\n";
/** The delete and move options */
echo "";
- echo "\n\n\n |