From 926da13e320077a43c18149ae43f64403bfff62f Mon Sep 17 00:00:00 2001 From: lkehresman Date: Mon, 22 Nov 1999 20:39:47 +0000 Subject: [PATCH] This updates the next/previous option. It kinda works, but not fully yet. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@16 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mailbox_display.php3 | 134 ++++++++++++++++++++++++++------- src/left_main.php3 | 2 +- src/right_main.php3 | 53 ++----------- 3 files changed, 114 insertions(+), 75 deletions(-) diff --git a/functions/mailbox_display.php3 b/functions/mailbox_display.php3 index d04a3e15..83bcca29 100644 --- a/functions/mailbox_display.php3 +++ b/functions/mailbox_display.php3 @@ -7,44 +7,122 @@ ** **/ - function printMessageInfo($imapConnection, $i, $from, $subject, $date) { - getMessageHeaders($imapConnection, $i, $from, $subject, $date); - getMessageFlags($imapConnection, $i, $flags); + function printMessageInfo($imapConnection, $i, $from, $subject, $date, $answered, $seen) { +// getMessageHeaders($imapConnection, $i, $from, $subject, $date); $dateParts = explode(" ", trim($date)); $dateString = getDateString($dateParts); // this will reformat the date string into a good format for us. $senderName = getSenderName($from); if (strlen(Chop($subject)) == 0) $subject = "(no subject)"; - $j = 0; - $deleted = false; - $seen = false; - $answered = false; - while ($j < count($flags)) { - if ($flags[$j] == "Deleted") { - $deleted = true; - } else if ($flags[$j] == "Answered") { - $answered = true; - } else if ($flags[$j] == "Seen") { - $seen = true; + echo "\n"; + if ($seen == false) { + echo " $i\n"; + echo " $senderName\n"; + echo "
$dateString
\n"; + echo " $subject\n"; + } else { + echo " $i\n"; + echo " $senderName\n"; + echo "
$dateString
\n"; + echo " $subject\n"; + } + echo "\n"; + } + + /** + ** This function loops through a group of messages in the mailbox and shows them + **/ + function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) { + $i = 1; + $j = 1; + while ($j <= $numMessages) { + getMessageHeaders($imapConnection, $j, $from, $subject, $date); + getMessageFlags($imapConnection, $j, $flags); + + echo "$date --"; + $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date))); + $messages[$i]["ID"] = $j; + $messages[$i]["FROM"] = $from; + $messages[$i]["SUBJECT"] = $subject; +// echo "$messages[$i][\"DATE\"]
"; + + $messages[$i]["FLAG_DELETED"] = false; + $messages[$i]["FLAG_ANSWERED"] = false; + $messages[$i]["FLAG_SEEN"] = false; + + $q = 0; + while ($q < count($flags)) { + if ($flags[$q] == "Deleted") + $messages[$i]["FLAG_DELETED"] = true; + else if ($flags[$q] == "Answered") + $messages[$i]["FLAG_ANSWERED"] = true; + else if ($flags[$q] == "Seen") + $messages[$i]["FLAG_SEEN"] = true; + $q++; } + + if ($messages[$i]["FLAG_DELETED"] == false) + $i++; $j++; } - if ($deleted == false) { - echo "\n"; - if ($seen == false) { - echo " $i\n"; - echo " $senderName\n"; - echo "
$dateString
\n"; - echo " $subject\n"; - } else { - echo " $i\n"; - echo " $senderName\n"; - echo "
$dateString
\n"; - echo " $subject\n"; - } - echo "\n"; + $numMessagesOld = $numMessages; + $numMessages = $i; + + if ($sort == 0) + $msgs = ary_sort($messages, "DATE", -1); + else + $msgs = ary_sort($messages, "DATE", 1); + + + if ($startMessage + 24 < $numMessages) { + $nextGroup = $startMessage + 24 + 1; // +1 to go to beginning of next group + $endMessage = $startMessage + 24; + } else { + $nextGroup = -1; + $endMessage = $numMessages; + } + + $prevGroup = $startMessage - 25; + + echo "Messages: $numMessages, $numMessagesOld
"; + echo "Start: $startMessage to $endMessage
"; + echo "NextGroup: $nextGroup
"; + echo "PrevGroup: $prevGroup
"; + + if (($nextGroup > -1) && ($prevGroup > 0)) { + echo "Next\n"; + echo "Previous\n"; + } + else if (($nextGroup == -1) && ($prevGroup >= 0)) { + echo "Previous\n"; } + else if (($nextGroup > -1) && ($prevGroup < 0)) { + echo "Next\n"; + } + + /** This is the beginning of the message list table. It wraps around all messages */ + echo ""; + echo "
"; + echo ""; + echo ""; + echo " "; + echo " "; + echo " \n"; + else + echo " \n"; + echo " \n"; + echo ""; + + // loop through and display the info for each message. + for ($i = $startMessage;$i <= $endMessage; $i++) { + printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]); + } + + echo "
NumFromDate"; + if ($sort == 0) + echo " Subject
\n"; + echo "
"; /** End of message-list table */ } ?> \ No newline at end of file diff --git a/src/left_main.php3 b/src/left_main.php3 index 60232d24..7a2d670c 100644 --- a/src/left_main.php3 +++ b/src/left_main.php3 @@ -85,7 +85,7 @@ echo "  "; $mailboxURL = urlencode($mailbox); - echo ""; + echo ""; echo readShortMailboxName($mailbox, "."); echo "
\n"; } diff --git a/src/right_main.php3 b/src/right_main.php3 index b647a6ba..eb8e3782 100644 --- a/src/right_main.php3 +++ b/src/right_main.php3 @@ -74,58 +74,19 @@ // switch to the mailbox, and get the number of messages in it. selectMailbox($imapConnection, $mailbox, $numMessages); + $numMessages = $numMessages - 1; // I did this so it's 0 based like the message array // make a URL safe $mailbox for use in the links $urlMailbox = urlencode($mailbox); - - displayPageHeader($mailbox); - $i = 1; - while ($i <= $numMessages) { - getMessageHeaders($imapConnection, $i, $from, $subject, $date); - - $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date))); - $messages[$i]["ID"] = $i; - $messages[$i]["FROM"] = $from; - $messages[$i]["SUBJECT"] = $subject; - $i++; - } - - if ($sort == 0) - $msgs = ary_sort($messages, "DATE", -1); - else - $msgs = ary_sort($messages, "DATE", 1); - - if ($endMessage > 24) { - echo "Next   "; - $endMessage = 24; - } - - /** Display "Next, Previous" on top */ - - /** This is the beginning of the message list table. It wraps around all messages */ - echo ""; - echo "
"; - echo ""; - echo ""; - echo " "; - echo " "; - echo " \n"; - else - echo " \n"; - echo " \n"; - echo ""; - // loop through and display the info for each message. - for ($i = $startMessage;$i <= $endMessage; $i++) { - printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"]); - } + // Display the header at the top of the page + displayPageHeader($mailbox); - echo "
NumFromDate"; - if ($sort == 0) - echo " Subject
\n"; - echo "
"; /** End of message-list table */ + // Get the list of messages for this mailbox + echo "$numMessages : $startMessage : $sort

"; + showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort); - /** Display "Next, Previous" on bottom */ + // close the connection fclose($imapConnection); ?>
-- 2.25.1