6 ** This contains functions that display mailbox information, such as the
7 ** table row that has sender, date, subject, etc...
11 $mailbox_display_php = true;
13 function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
14 global $color, $msgs, $msort;
16 global $message_highlight_list;
21 $senderName = sqimap_find_displayable_name($msg["FROM"]);
22 $urlMailbox = urlencode($mailbox);
23 $subject = trim($msg["SUBJECT"]);
25 $subject = _("(no subject)");
29 if ($msg["FLAG_FLAGGED"] == true) { $flag = "<font color=$color[2]>"; $flag_end = "</font>"; }
30 if ($msg["FLAG_SEEN"] == false) { $bold = "<b>"; $bold_end = "</b>"; }
31 if ($mailbox == $sent_folder) { $italic = "<i>"; $italic_end = "</i>"; }
33 for ($i=0; $i < count($message_highlight_list); $i++
) {
34 if (trim($message_highlight_list[$i]["value"]) != "") {
35 if ($message_highlight_list[$i]["match_type"] == "to_cc") {
36 if (strpos("^^".strtolower($msg["TO"]), strtolower($message_highlight_list[$i]["value"])) ||
strpos("^^".strtolower($msg["CC"]), strtolower($message_highlight_list[$i]["value"]))) {
37 $hlt_color = $message_highlight_list[$i]["color"];
40 } else if (strpos("^^".strtolower($msg[strtoupper($message_highlight_list[$i]["match_type"])]),strtolower($message_highlight_list[$i]["value"]))) {
41 $hlt_color = $message_highlight_list[$i]["color"];
48 $hlt_color = $color[4];
50 if ($where && $what) {
51 $search_stuff = "&where=".urlencode($where)."&what=".urlencode($what);
54 for ($i=1; $i <= count($index_order); $i++
) {
55 switch ($index_order[$i]) {
57 echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
60 echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$senderName$flag_end$bold_end$italic_end</td>\n";
63 echo " <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag".$msg["DATE_STRING"]."$flag_end$bold_end</center></td>\n";
66 echo " <td bgcolor=$hlt_color>$bold<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\">$flag$subject$flag_end</a>$bold_end</td>\n";
70 echo " <td bgcolor=$hlt_color width=1% nowrap><b><small>\n";
71 if ($msg["FLAG_ANSWERED"] == true) {
75 if ($msg["TYPE0"] == "multipart") {
79 if (ereg("(1|2)",substr($msg["PRIORITY"],0,1))) {
80 echo "<font color=$color[1]>!</font>\n";
83 if ($msg["FLAG_DELETED"]) {
84 echo "<font color=\"$color[1]\">D</font>\n";
88 if (!$stuff) echo " \n";
89 echo "</small></b></td>\n";
92 echo " <td bgcolor=$hlt_color width=1%>$bold".show_readable_size($msg['SIZE'])."$bold_end</td>\n";
102 ** This function loops through a group of messages in the mailbox and shows them
104 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
105 global $msgs, $msort;
107 global $message_highlight_list;
108 global $auto_expunge;
111 sqimap_mailbox_expunge($imapConnection, $mailbox);
112 sqimap_mailbox_select($imapConnection, $mailbox);
116 if ($numMessages >= 1) {
117 for ($q = 0; $q < $numMessages; $q++
) {
118 if($mailbox == $sent_folder)
119 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, true);
121 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, false);
124 $from[$q] = $hdr->from
;
125 $date[$q] = $hdr->date
;
126 $subject[$q] = $hdr->subject
;
128 $priority[$q] = $hdr->priority
;
130 $size[$q] = $hdr->size
;
131 $type[$q] = $hdr->type0
;
132 $flags[$q] = sqimap_get_flags ($imapConnection, $q+
1);
137 while ($j < $numMessages) {
138 $date[$j] = ereg_replace(" ", " ", $date[$j]);
139 $tmpdate = explode(" ", trim($date[$j]));
141 $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
142 $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
143 $messages[$j]["ID"] = $j+
1;
144 $messages[$j]["FROM"] = decodeHeader($from[$j]);
145 $messages[$j]["FROM-SORT"] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
146 $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
147 $messages[$j]["SUBJECT-SORT"] = strtolower(decodeHeader($subject[$j]));
148 $messages[$j]["TO"] = decodeHeader($to[$j]);
149 $messages[$j]["PRIORITY"] = $priority[$j];
150 $messages[$j]["CC"] = $cc[$j];
151 $messages[$j]["SIZE"] = $size[$j];
152 $messages[$j]["TYPE0"] = $type[$j];
154 # fix SUBJECT-SORT to remove Re:
155 $re_abbr = # Add more here!
156 "vedr|sv|" . # Danish
158 if (eregi("^($re_abbr):[ ]*(.*)$",
159 $messages[$j]['SUBJECT-SORT'], $regs))
160 $messages[$j]['SUBJECT-SORT'] = $regs[2];
163 while ($num < count($flags[$j])) {
164 if ($flags[$j][$num] == "Deleted") {
165 $messages[$j]["FLAG_DELETED"] = true;
167 elseif ($flags[$j][$num] == "Answered") {
168 $messages[$j]["FLAG_ANSWERED"] = true;
170 elseif ($flags[$j][$num] == "Seen") {
171 $messages[$j]["FLAG_SEEN"] = true;
173 elseif ($flags[$j][$num] == "Flagged") {
174 $messages[$j]["FLAG_FLAGGED"] = true;
181 /* Only ignore messages flagged as deleted if we are using a
182 * trash folder or auto_expunge */
183 if ($move_to_trash ||
$auto_expunge)
185 /** Find and remove the ones that are deleted */
188 while ($j < $numMessages) {
189 if ($messages[$j]["FLAG_DELETED"] == true) {
193 $msgs[$i] = $messages[$j];
202 // There's gotta be messages in the array for it to sort them.
203 if ($numMessages > 0 && ! $use_cache) {
204 /** 0 = Date (up) 4 = Subject (up)
205 ** 1 = Date (dn) 5 = Subject (dn)
209 session_unregister("msgs");
210 if (($sort == 0) ||
($sort == 1))
211 $msort = array_cleave ($msgs, "TIME_STAMP");
212 if (($sort == 2) ||
($sort == 3))
213 $msort = array_cleave ($msgs, "FROM-SORT");
214 if (($sort == 4) ||
($sort == 5))
215 $msort = array_cleave ($msgs, "SUBJECT-SORT");
222 session_register("msort");
224 displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
225 session_register("msgs");
228 // generic function to convert the msgs array into an HTML table
229 function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
230 global $folder_prefix, $sent_folder;
231 global $imapServerAddress;
234 // if cache isn't already set, do it now
235 if (!session_is_registered("msgs"))
236 session_register("msgs");
237 if (!session_is_registered("msort"))
238 session_register("msort");
241 if ($startMessage +
($show_num - 1) < $numMessages) {
242 $endMessage = $startMessage +
($show_num-1);
244 $endMessage = $numMessages;
247 if ($endMessage < $startMessage) {
248 $startMessage = $startMessage - $show_num;
249 if ($startMessage < 1)
253 $nextGroup = $startMessage +
$show_num;
254 $prevGroup = $startMessage - $show_num;
255 $urlMailbox = urlencode($mailbox);
257 do_hook("mailbox_index_before");
260 if ($startMessage < $endMessage) {
261 $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
262 } elseif ($startMessage == $endMessage) {
263 $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
267 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
268 $More = "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
269 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=1&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
271 elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
272 $More = "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
273 $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
275 elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
276 $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
277 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
280 mail_message_listing_beginning($imapConnection,
281 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
282 $mailbox, $sort, $Message, $More);
285 // loop through and display the info for each message.
286 $t = 0; // $t is used for the checkbox number
287 if ($numMessages == 0) { // if there's no messages in this folder
288 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
289 echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER></TD></TR>";
290 } elseif ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
297 } while (isset ($key) && ($k < $i));
298 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, 0, 0);
306 } while (isset ($key) && ($k < $i));
309 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, 0, 0);
314 } while ($i < ($endMessage+
1));
322 echo "<TR BGCOLOR=\"$color[4]\"><TD>$More</td></tr>\n";
324 echo "</table>"; /** End of message-list table */
326 do_hook("mailbox_index_after");
329 /* Displays the standard message list header.
330 * To finish the table, you need to do a "</table></table>";
331 * $moveURL is the URL to submit the delete/move form to
332 * $mailbox is the current mailbox
333 * $sort is the current sorting method (-1 for no sorting available [searches])
334 * $Message is a message that is centered on top of the list
335 * $More is a second line that is left aligned
337 function mail_message_listing_beginning($imapConnection, $moveURL,
338 $mailbox = '', $sort = -1, $Message = '', $More = '')
340 global $color, $index_order, $auto_expunge, $move_to_trash;
342 /** This is the beginning of the message list table. It wraps around all messages */
343 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>";
347 echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
352 echo "<TR BGCOLOR=\"$color[4]\"><TD>$More</td></tr>\n";
355 /** The delete and move options */
356 echo "<TR><TD BGCOLOR=\"$color[0]\">";
358 echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n";
359 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
361 echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
362 echo " <NOBR><SMALL>". _("Move selected to:") ."</SMALL>";
363 echo " <TT><SMALL><SELECT NAME=\"targetMailbox\">";
365 $boxes = sqimap_mailbox_list($imapConnection);
366 for ($i = 0; $i < count($boxes); $i++
) {
367 if ($boxes[$i]["flags"][0] != "noselect" &&
368 $boxes[$i]["flags"][1] != "noselect" &&
369 $boxes[$i]["flags"][2] != "noselect") {
370 $box = $boxes[$i]["unformatted"];
371 $box2 = replace_spaces($boxes[$i]["formatted"]);
372 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
375 echo " </SELECT></SMALL></TT>";
376 echo " <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"". _("Move") ."\"></SMALL></NOBR>\n";
378 echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
379 if (! $move_to_trash && ! $auto_expunge) {
380 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT NAME=\"expungeButton\" VALUE=\"". _("Expunge") ."\"> ". _("mailbox") ."</SMALL></NOBR> \n";
382 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\"> ". _("checked messages") ."</SMALL></NOBR>\n";
387 do_hook("mailbox_form_before");
390 echo "<TR><TD BGCOLOR=\"$color[0]\">";
391 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">";
392 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
395 for ($i=1; $i <= count($index_order); $i++
) {
396 switch ($index_order[$i]) {
399 echo " <TD WIDTH=1%><B> </B></TD>";
403 if ($mailbox == $sent_folder)
404 echo " <TD WIDTH=30%><B>". _("To") ."</B>";
406 echo " <TD WIDTH=30%><B>". _("From") ."</B>";
409 echo " <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
411 echo " <A HREF=\"right_main.php?newsort=2&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
413 echo " <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
417 echo " <TD nowrap WIDTH=1%><B>". _("Date") ."</B>";
419 echo " <A HREF=\"right_main.php?newsort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
421 echo " <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
423 echo " <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
427 echo " <TD WIDTH=%><B>". _("Subject") ."</B>\n";
429 echo " <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
431 echo " <A HREF=\"right_main.php?newsort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
433 echo " <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n";
437 echo " <TD WIDTH=1%><b>" . _("Size")."</b></TD>\n";