This updates the next/previous option. It kinda works, but not fully yet.
[squirrelmail.git] / functions / mailbox_display.php3
CommitLineData
3302d0d4 1<?
2 /**
3 ** mailbox_display.php3
4 **
5 ** This contains functions that display mailbox information, such as the
6 ** table row that has sender, date, subject, etc...
7 **
8 **/
9
926da13e 10 function printMessageInfo($imapConnection, $i, $from, $subject, $date, $answered, $seen) {
11// getMessageHeaders($imapConnection, $i, $from, $subject, $date);
3302d0d4 12 $dateParts = explode(" ", trim($date));
13 $dateString = getDateString($dateParts); // this will reformat the date string into a good format for us.
14 $senderName = getSenderName($from);
15 if (strlen(Chop($subject)) == 0)
16 $subject = "(no subject)";
17
926da13e 18 echo "<TR>\n";
19 if ($seen == false) {
20 echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$i</B></FONT></TD>\n";
21 echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$senderName</B></FONT></TD>\n";
22 echo " <TD><CENTER><B><FONT FACE=\"Arial,Helvetica\">$dateString</FONT></B></CENTER></TD>\n";
23 echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT></TD>\n";
24 } else {
25 echo " <TD><FONT FACE=\"Arial,Helvetica\">$i</FONT></TD>\n";
26 echo " <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";
27 echo " <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
28 echo " <TD><FONT FACE=\"Arial,Helvetica\">$subject</FONT></TD>\n";
29 }
30 echo "</TR>\n";
31 }
32
33 /**
34 ** This function loops through a group of messages in the mailbox and shows them
35 **/
36 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
37 $i = 1;
38 $j = 1;
39 while ($j <= $numMessages) {
40 getMessageHeaders($imapConnection, $j, $from, $subject, $date);
41 getMessageFlags($imapConnection, $j, $flags);
42
43 echo "$date --";
44 $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date)));
45 $messages[$i]["ID"] = $j;
46 $messages[$i]["FROM"] = $from;
47 $messages[$i]["SUBJECT"] = $subject;
48// echo "$messages[$i][\"DATE\"]<BR>";
49
50 $messages[$i]["FLAG_DELETED"] = false;
51 $messages[$i]["FLAG_ANSWERED"] = false;
52 $messages[$i]["FLAG_SEEN"] = false;
53
54 $q = 0;
55 while ($q < count($flags)) {
56 if ($flags[$q] == "Deleted")
57 $messages[$i]["FLAG_DELETED"] = true;
58 else if ($flags[$q] == "Answered")
59 $messages[$i]["FLAG_ANSWERED"] = true;
60 else if ($flags[$q] == "Seen")
61 $messages[$i]["FLAG_SEEN"] = true;
62 $q++;
3302d0d4 63 }
926da13e 64
65 if ($messages[$i]["FLAG_DELETED"] == false)
66 $i++;
3302d0d4 67 $j++;
68 }
69
926da13e 70 $numMessagesOld = $numMessages;
71 $numMessages = $i;
72
73 if ($sort == 0)
74 $msgs = ary_sort($messages, "DATE", -1);
75 else
76 $msgs = ary_sort($messages, "DATE", 1);
77
78
79 if ($startMessage + 24 < $numMessages) {
80 $nextGroup = $startMessage + 24 + 1; // +1 to go to beginning of next group
81 $endMessage = $startMessage + 24;
82 } else {
83 $nextGroup = -1;
84 $endMessage = $numMessages;
85 }
86
87 $prevGroup = $startMessage - 25;
88
89 echo "Messages: $numMessages, $numMessagesOld<BR>";
90 echo "Start: $startMessage to $endMessage<BR>";
91 echo "NextGroup: $nextGroup<BR>";
92 echo "PrevGroup: $prevGroup<BR>";
93
94 if (($nextGroup > -1) && ($prevGroup > 0)) {
95 echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Next</A>\n";
96 echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$prevGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>\n";
97 }
98 else if (($nextGroup == -1) && ($prevGroup >= 0)) {
99 echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$prevGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>\n";
3302d0d4 100 }
926da13e 101 else if (($nextGroup > -1) && ($prevGroup < 0)) {
102 echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Next</A>\n";
103 }
104
105 /** This is the beginning of the message list table. It wraps around all messages */
106 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>";
107 echo "<TR><TD BGCOLOR=DCDCDC>";
108 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=FFFFFF>";
109 echo "<TR BGCOLOR=FFFFCC ALIGN=\"center\">";
110 echo " <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
111 echo " <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT></TD>";
112 echo " <TD WIDTH=15%><FONT FACE=\"Arial,Helvetica\"><B>Date</B></FONT>";
113 if ($sort == 0)
114 echo " <A HREF=\"right_main.php3?sort=1&startMessage=1&mailbox=$mailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
115 else
116 echo " <A HREF=\"right_main.php3?sort=0&startMessage=1&mailbox=$mailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
117 echo " <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT></TD>\n";
118 echo "</TR>";
119
120 // loop through and display the info for each message.
121 for ($i = $startMessage;$i <= $endMessage; $i++) {
122 printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]);
123 }
124
125 echo "</TABLE>\n";
126 echo "</TD></TR></TABLE>"; /** End of message-list table */
3302d0d4 127 }
128?>