Links successfully to todo and bug manager
[squirrelmail.git] / functions / mailbox_display.php
CommitLineData
3302d0d4 1<?
2 /**
a09387f4 3 ** mailbox_display.php
3302d0d4 4 **
5 ** This contains functions that display mailbox information, such as the
6 ** table row that has sender, date, subject, etc...
7 **
8 **/
9
54a8ae32 10 function printMessageInfo($imapConnection, $i, $from, $subject, $dateString, $answered, $seen) {
3302d0d4 11 $senderName = getSenderName($from);
12 if (strlen(Chop($subject)) == 0)
13 $subject = "(no subject)";
14
926da13e 15 echo "<TR>\n";
16 if ($seen == false) {
17 echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$i</B></FONT></TD>\n";
18 echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$senderName</B></FONT></TD>\n";
19 echo " <TD><CENTER><B><FONT FACE=\"Arial,Helvetica\">$dateString</FONT></B></CENTER></TD>\n";
20 echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT></TD>\n";
21 } else {
22 echo " <TD><FONT FACE=\"Arial,Helvetica\">$i</FONT></TD>\n";
23 echo " <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";
24 echo " <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
25 echo " <TD><FONT FACE=\"Arial,Helvetica\">$subject</FONT></TD>\n";
26 }
27 echo "</TR>\n";
28 }
29
30 /**
31 ** This function loops through a group of messages in the mailbox and shows them
32 **/
33 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
926da13e 34 $j = 1;
35 while ($j <= $numMessages) {
5b10f02a 36 $q = 0;
926da13e 37 getMessageHeaders($imapConnection, $j, $from, $subject, $date);
38 getMessageFlags($imapConnection, $j, $flags);
39
5b10f02a 40 $messages[$j]["TIME_STAMP"] = getTimeStamp(explode(" ", trim($date)));
41 $messages[$j]["DATE_STRING"] = getDateString(explode(" ", trim($date)));
42 $messages[$j]["ID"] = $j;
43 $messages[$j]["FROM"] = $from;
44 $messages[$j]["SUBJECT"] = $subject;
45 $messages[$j]["FLAG_DELETED"] = false;
46 $messages[$j]["FLAG_ANSWERED"] = false;
47 $messages[$j]["FLAG_SEEN"] = false;
926da13e 48
926da13e 49 while ($q < count($flags)) {
5b10f02a 50 if ($flags[$q] == "Deleted") {
51 $messages[$j]["FLAG_DELETED"] = true;
52 }
53 else if ($flags[$q] == "Answered") {
54 $messages[$j]["FLAG_ANSWERED"] = true;
55 }
56 else if ($flags[$q] == "Seen") {
57 $messages[$j]["FLAG_SEEN"] = true;
58 }
926da13e 59 $q++;
3302d0d4 60 }
926da13e 61
5b10f02a 62 $j++;
63 }
64
65 /** Find and remove the ones that are deleted */
66 $i = 1;
67 $j = 1;
68 while ($j <= $numMessages) {
69 if ($messages[$j]["FLAG_DELETED"] == true) {
70 $j++;
71 continue;
72 }
73 $msgs[$i]["TIME_STAMP"] = $messages[$j]["TIME_STAMP"];
74 $msgs[$i]["DATE_STRING"] = $messages[$j]["DATE_STRING"];
75 $msgs[$i]["ID"] = $messages[$j]["ID"];
76 $msgs[$i]["FROM"] = $messages[$j]["FROM"];
77 $msgs[$i]["SUBJECT"] = $messages[$j]["SUBJECT"];
78 $msgs[$i]["FLAG_DELETED"] = $messages[$j]["FLAG_DELETED"];
79 $msgs[$i]["FLAG_ANSWERED"] = $messages[$j]["FLAG_ANSWERED"];
80 $msgs[$i]["FLAG_SEEN"] = $messages[$j]["FLAG_SEEN"];
81 $i++;
3302d0d4 82 $j++;
83 }
84
926da13e 85 $numMessagesOld = $numMessages;
5b10f02a 86 $numMessages = $i - 1;
926da13e 87
88 if ($sort == 0)
5b10f02a 89 $msgs = ary_sort($msgs, "TIME_STAMP", -1);
926da13e 90 else
5b10f02a 91 $msgs = ary_sort($msgs, "TIME_STAMP", 1);
926da13e 92
93 if ($startMessage + 24 < $numMessages) {
926da13e 94 $endMessage = $startMessage + 24;
95 } else {
926da13e 96 $endMessage = $numMessages;
97 }
98
5b10f02a 99 $nextGroup = $startMessage + 25;
926da13e 100 $prevGroup = $startMessage - 25;
20db5033 101 $urlMailbox = urlencode($mailbox);
926da13e 102
20db5033 103 /** This is the beginning of the message list table. It wraps around all messages */
104 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>";
926da13e 105
20db5033 106 echo "<TR BGCOLOR=FFFFFF><TD>";
107 echo "<CENTER><FONT FACE=\"Arial,Helvetica\">Viewing messages <B>$startMessage</B> to <B>$endMessage</B> ($numMessages total)</FONT></CENTER>\n";
108 echo "</TD></TR>\n";
26b6c99c 109
20db5033 110 echo "<TR BGCOLOR=FFFFFF><TD>";
5b10f02a 111 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
a09387f4 112 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Previous</FONT></A>\n";
113 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>\n";
926da13e 114 }
5b10f02a 115 else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
a09387f4 116 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Previous</FONT></A>\n";
3302d0d4 117 }
5b10f02a 118 else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
a09387f4 119 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>\n";
926da13e 120 }
20db5033 121 echo "</TD></TR>\n";
926da13e 122
926da13e 123 echo "<TR><TD BGCOLOR=DCDCDC>";
124 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=FFFFFF>";
125 echo "<TR BGCOLOR=FFFFCC ALIGN=\"center\">";
126 echo " <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
127 echo " <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT></TD>";
128 echo " <TD WIDTH=15%><FONT FACE=\"Arial,Helvetica\"><B>Date</B></FONT>";
129 if ($sort == 0)
a09387f4 130 echo " <A HREF=\"right_main.php?sort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
926da13e 131 else
a09387f4 132 echo " <A HREF=\"right_main.php?sort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
926da13e 133 echo " <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT></TD>\n";
134 echo "</TR>";
135
136 // loop through and display the info for each message.
54a8ae32 137 for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) {
138 printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]);
926da13e 139 }
926da13e 140 echo "</TABLE>\n";
20db5033 141
142 echo "</TD></TR>\n";
143 echo "<TR BGCOLOR=FFFFFF><TD>";
144 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
a09387f4 145 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Previous</FONT></A>\n";
146 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>\n";
20db5033 147 }
148 else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
a09387f4 149 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Previous</FONT></A>\n";
20db5033 150 }
151 else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
a09387f4 152 echo "<A HREF=\"right_main.php?sort=$sort&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>\n";
20db5033 153 }
926da13e 154 echo "</TD></TR></TABLE>"; /** End of message-list table */
3302d0d4 155 }
26b6c99c 156?>