X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=c5b304b1747dbdce161a30ed21a09b61c7b49093;hb=4bbba0d8cf096277dc7375cfb54193be092b83e5;hp=2130cd2e6a958d9364584206e72ebd1ac36f02c3;hpb=aae41ae986d847f7bb15d98f98e16bc65595f215;p=squirrelmail.git
diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php
index 2130cd2e..c5b304b1 100644
--- a/functions/mailbox_display.php
+++ b/functions/mailbox_display.php
@@ -1,4 +1,4 @@
-
+\n";
- if ($seen == false) {
- echo "
| \n";
- echo " $senderName | \n";
- echo " $dateString | \n";
- echo " $subject | \n";
- } else {
- echo " | \n";
- echo " $senderName | \n";
- echo " $dateString | \n";
- echo " $subject | \n";
- }
- echo "\n";
+
+ if ($msg["FLAG_FLAGGED"] == true) { $flag = ""; $flag_end = ""; }
+ if ($msg["FLAG_SEEN"] == false) { $bold = ""; $bold_end = ""; }
+ if ($mailbox == $sent_folder) { $italic = ""; $italic_end = ""; }
+
+ 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";
}
/**
** 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 = sqimap_get_flags ($imapConnection, 1, $numMessages);
- }
-
- $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]);
- $messages[$j]["FLAG_DELETED"] = false;
- $messages[$j]["FLAG_ANSWERED"] = false;
- $messages[$j]["FLAG_SEEN"] = false;
-
- $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;
+ function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
+ global $msgs, $msort;
+ global $sent_folder;
+
+ 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] == "Seen") {
- $messages[$j]["FLAG_SEEN"] = 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]["TIME_STAMP"] = $messages[$j]["TIME_STAMP"];
- $msgs[$i]["DATE_STRING"] = $messages[$j]["DATE_STRING"];
- $msgs[$i]["ID"] = $messages[$j]["ID"];
- $msgs[$i]["FROM"] = $messages[$j]["FROM"];
- $msgs[$i]["SUBJECT"] = $messages[$j]["SUBJECT"];
- $msgs[$i]["FLAG_DELETED"] = $messages[$j]["FLAG_DELETED"];
- $msgs[$i]["FLAG_ANSWERED"] = $messages[$j]["FLAG_ANSWERED"];
- $msgs[$i]["FLAG_SEEN"] = $messages[$j]["FLAG_SEEN"];
-
- $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++;
- }
+ 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");
}
+ displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
+ }
+
+ // generic function to convert the msgs array into an HTML table
+ function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
+ global $folder_prefix, $sent_folder;
+ global $imapServerAddress;
- if ($startMessage + 24 < $numMessages) {
- $endMessage = $startMessage + 24;
+ // do a check to see if the config stuff has already been included or not
+// if (!isset($imapServerAddress))
+// include("../config/config.php");
+
+ // if cache isn't already set, do it now
+ 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 */
@@ -170,53 +162,41 @@
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 |