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) {
15 global $color, $msgs, $msort;
17 global $message_highlight_list;
22 $senderName = sqimap_find_displayable_name($msg["FROM"]);
23 $urlMailbox = urlencode($mailbox);
24 $subject = trim($msg["SUBJECT"]);
26 $subject = _("(no subject)");
30 if ($msg["FLAG_FLAGGED"] == true) { $flag = "<font color=$color[2]>"; $flag_end = "</font>"; }
31 if ($msg["FLAG_SEEN"] == false) { $bold = "<b>"; $bold_end = "</b>"; }
32 if ($mailbox == $sent_folder) { $italic = "<i>"; $italic_end = "</i>"; }
33 if ($msg["FLAG_DELETED"]) { $fontstr = "<font color=\"$color[9]\">"; $fontstr_end = "</font>"; }
35 for ($i=0; $i < count($message_highlight_list); $i++
) {
36 if (trim($message_highlight_list[$i]["value"]) != "") {
37 if ($message_highlight_list[$i]["match_type"] == "to_cc") {
38 if (strpos("^^".strtolower($msg["TO"]), strtolower($message_highlight_list[$i]["value"])) ||
strpos("^^".strtolower($msg["CC"]), strtolower($message_highlight_list[$i]["value"]))) {
39 $hlt_color = $message_highlight_list[$i]["color"];
42 } else if (strpos("^^".strtolower($msg[strtoupper($message_highlight_list[$i]["match_type"])]),strtolower($message_highlight_list[$i]["value"]))) {
43 $hlt_color = $message_highlight_list[$i]["color"];
50 $hlt_color = $color[4];
52 if ($where && $what) {
53 $search_stuff = "&where=".urlencode($where)."&what=".urlencode($what);
57 $checked = " checked";
61 for ($i=1; $i <= count($index_order); $i++
) {
62 switch ($index_order[$i]) {
64 echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
67 echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
70 echo " <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
73 echo " <td bgcolor=$hlt_color>$bold";
74 echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
75 do_hook("subject_link");
76 echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
80 echo " <td bgcolor=$hlt_color align=center width=1% nowrap><b><small>\n";
81 if ($msg["FLAG_ANSWERED"] == true) {
85 if ($msg["TYPE0"] == "multipart") {
89 if (ereg("(1|2)",substr($msg["PRIORITY"],0,1))) {
90 echo "<font color=$color[1]>!</font>\n";
93 if ($msg["FLAG_DELETED"]) {
94 echo "<font color=\"$color[1]\">D</font>\n";
98 if (!$stuff) echo " \n";
99 echo "</small></b></td>\n";
102 echo " <td bgcolor=$hlt_color width=1%>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
112 ** This function loops through a group of messages in the mailbox and shows them
114 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
115 global $msgs, $msort;
117 global $message_highlight_list;
118 global $auto_expunge;
120 if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false);
121 sqimap_mailbox_select($imapConnection, $mailbox);
125 if ($numMessages >= 1) {
127 for ($q = 0; $q < $numMessages; $q++
) {
128 if($mailbox == $sent_folder)
129 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, true);
131 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, false);
133 $from[$q] = $hdr->from
;
134 $date[$q] = $hdr->date
;
135 $subject[$q] = $hdr->subject
;
137 $priority[$q] = $hdr->priority
;
139 $size[$q] = $hdr->size
;
140 $type[$q] = $hdr->type0
;
141 $flags[$q] = sqimap_get_flags ($imapConnection, $q+
1);
145 // if it's not sorted
146 if ($startMessage +
($show_num - 1) < $numMessages) {
147 $endMessage = $startMessage +
($show_num-1);
149 $endMessage = $numMessages;
152 if ($endMessage < $startMessage) {
153 $startMessage = $startMessage - $show_num;
154 if ($startMessage < 1)
159 $real_startMessage = $numMessages - $startMessage +
1;
160 $real_endMessage = $numMessages - $startMessage - $show_num;
161 if ($real_endMessage <= 0)
162 $real_endMessage = 1;
165 for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
166 if($mailbox == $sent_folder)
167 $hdr = sqimap_get_small_header ($imapConnection, $q, true);
169 $hdr = sqimap_get_small_header ($imapConnection, $q, false);
171 $from[$j] = $hdr->from
;
172 $date[$j] = $hdr->date
;
173 $subject[$j] = $hdr->subject
;
175 $priority[$j] = $hdr->priority
;
177 $size[$j] = $hdr->size
;
178 $type[$j] = $hdr->type0
;
179 $flags[$j] = sqimap_get_flags ($imapConnection, $q);
188 $end = $startMessage +
$show_num - 1;
193 $date[$j] = ereg_replace(" ", " ", $date[$j]);
194 $tmpdate = explode(" ", trim($date[$j]));
196 $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
197 $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
198 $messages[$j]["ID"] = $id[$j];
199 $messages[$j]["FROM"] = decodeHeader($from[$j]);
200 $messages[$j]["FROM-SORT"] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
201 $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
202 $messages[$j]["SUBJECT-SORT"] = strtolower(decodeHeader($subject[$j]));
203 $messages[$j]["TO"] = decodeHeader($to[$j]);
204 $messages[$j]["PRIORITY"] = $priority[$j];
205 $messages[$j]["CC"] = $cc[$j];
206 $messages[$j]["SIZE"] = $size[$j];
207 $messages[$j]["TYPE0"] = $type[$j];
209 # fix SUBJECT-SORT to remove Re:
210 $re_abbr = # Add more here!
211 "vedr|sv|" . # Danish
213 if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
214 $messages[$j]['SUBJECT-SORT'] = $regs[2];
217 while ($num < count($flags[$j])) {
218 if ($flags[$j][$num] == "Deleted") {
219 $messages[$j]["FLAG_DELETED"] = true;
221 elseif ($flags[$j][$num] == "Answered") {
222 $messages[$j]["FLAG_ANSWERED"] = true;
224 elseif ($flags[$j][$num] == "Seen") {
225 $messages[$j]["FLAG_SEEN"] = true;
227 elseif ($flags[$j][$num] == "Flagged") {
228 $messages[$j]["FLAG_FLAGGED"] = true;
235 /* Only ignore messages flagged as deleted if we are using a
236 * trash folder or auto_expunge */
237 if (($move_to_trash ||
$auto_expunge) && $sort != 6)
239 /** Find and remove the ones that are deleted */
242 while ($j < $numMessages) {
243 if ($messages[$j]["FLAG_DELETED"] == true) {
247 $msgs[$i] = $messages[$j];
258 // There's gotta be messages in the array for it to sort them.
259 if ($numMessages > 0 && ! $use_cache) {
260 /** 0 = Date (up) 4 = Subject (up)
261 ** 1 = Date (dn) 5 = Subject (dn)
265 session_unregister("msgs");
266 if (($sort == 0) ||
($sort == 1))
267 $msort = array_cleave ($msgs, "TIME_STAMP");
268 if (($sort == 2) ||
($sort == 3))
269 $msort = array_cleave ($msgs, "FROM-SORT");
270 if (($sort == 4) ||
($sort == 5))
271 $msort = array_cleave ($msgs, "SUBJECT-SORT");
282 session_register("msort");
284 displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
285 session_register("msgs");
288 // generic function to convert the msgs array into an HTML table
289 function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
290 global $folder_prefix, $sent_folder;
291 global $imapServerAddress;
292 global $index_order, $real_endMessage, $real_startMessage, $checkall;
294 // if cache isn't already set, do it now
295 if (!session_is_registered("msgs"))
296 session_register("msgs");
297 if (!session_is_registered("msort"))
298 session_register("msort");
300 if ($startMessage +
($show_num - 1) < $numMessages) {
301 $endMessage = $startMessage +
($show_num-1);
303 $endMessage = $numMessages;
306 if ($endMessage < $startMessage) {
307 $startMessage = $startMessage - $show_num;
308 if ($startMessage < 1)
312 $nextGroup = $startMessage +
$show_num;
313 $prevGroup = $startMessage - $show_num;
314 $urlMailbox = urlencode($mailbox);
316 do_hook("mailbox_index_before");
319 if ($startMessage < $endMessage) {
320 $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
321 } elseif ($startMessage == $endMessage) {
322 $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
331 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
332 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
333 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
335 elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
336 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
337 $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
339 elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
340 $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
341 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
344 mail_message_listing_beginning($imapConnection,
345 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
346 $mailbox, $sort, $Message, $More, $startMessage);
348 $groupNum = $startMessage %
($show_num - 1);
349 $real_startMessage = $startMessage;
351 if ($endMessage - $startMessage < $show_num - 1) {
352 $endMessage = $endMessage - $startMessage +
1;
354 } else if ($startMessage > $show_num) {
355 $endMessage = $show_num;
360 $endVar = $endMessage +
1;
362 // loop through and display the info for each message.
363 $t = 0; // $t is used for the checkbox number
364 if ($numMessages == 0) { // if there's no messages in this folder
365 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
366 echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER></TD></TR>";
367 } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
377 } while (isset ($key) && ($k < $i));
378 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
387 } while (isset ($key) && ($k < $i));
390 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
395 } while ($i && $i < $endVar);
401 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
402 echo "<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td>";
403 echo "$More</td><td align=right>\n";
404 if (!$startMessage) $startMessage=1;
405 if ( $checkall == "1")
406 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$real_startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
408 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$real_startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
410 echo "</td></tr></table>";
412 echo "</table>"; /** End of message-list table */
414 do_hook("mailbox_index_after");
417 /* Displays the standard message list header.
418 * To finish the table, you need to do a "</table></table>";
419 * $moveURL is the URL to submit the delete/move form to
420 * $mailbox is the current mailbox
421 * $sort is the current sorting method (-1 for no sorting available [searches])
422 * $Message is a message that is centered on top of the list
423 * $More is a second line that is left aligned
425 function mail_message_listing_beginning($imapConnection, $moveURL,
426 $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
428 global $color, $index_order, $auto_expunge, $move_to_trash;
429 global $checkall, $sent_folder;
430 $urlMailbox = urlencode($mailbox);
432 /** This is the beginning of the message list table. It wraps around all messages */
433 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>";
437 echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
440 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
441 echo "<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td>";
442 echo "$More</td><td align=right>\n";
443 if ( $checkall == "1")
444 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
446 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
448 echo "</td></tr></table>";
451 /** The delete and move options */
452 echo "<TR><TD BGCOLOR=\"$color[0]\">";
454 echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n";
455 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
457 echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
460 echo " <NOBR><SMALL>". _("Move selected to:") ."</SMALL>";
461 echo " <TT><SMALL><SELECT NAME=\"targetMailbox\">";
463 $boxes = sqimap_mailbox_list($imapConnection);
464 for ($i = 0; $i < count($boxes); $i++
) {
465 if ($boxes[$i]["flags"][0] != "noselect" &&
466 $boxes[$i]["flags"][1] != "noselect" &&
467 $boxes[$i]["flags"][2] != "noselect") {
468 $box = $boxes[$i]["unformatted"];
469 $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
470 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
473 echo " </SELECT></SMALL></TT>";
474 echo " <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"". _("Move") ."\"></SMALL></NOBR>\n";
476 echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
477 if (! $auto_expunge) {
478 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT NAME=\"expungeButton\" VALUE=\"". _("Expunge") ."\"> ". _("mailbox") ."</SMALL></NOBR> \n";
480 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\"> ". _("checked messages") ."</SMALL></NOBR>\n";
485 do_hook("mailbox_form_before");
488 echo "<TR><TD BGCOLOR=\"$color[0]\">";
489 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">";
490 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
492 $urlMailbox=urlencode($mailbox);
495 for ($i=1; $i <= count($index_order); $i++
) {
496 switch ($index_order[$i]) {
499 echo " <TD WIDTH=1%><B> </B></TD>";
503 if ($mailbox == $sent_folder)
504 echo " <TD WIDTH=30%><B>". _("To") ."</B>";
506 echo " <TD WIDTH=30%><B>". _("From") ."</B>";
509 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";
511 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";
513 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";
518 echo " <TD nowrap WIDTH=1%><B>". _("Date") ."</B>";
520 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";
522 echo " <A HREF=\"right_main.php?newsort=6&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
524 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";
526 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";
531 echo " <TD WIDTH=%><B>". _("Subject") ."</B>\n";
533 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";
535 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";
537 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";
542 echo " <TD WIDTH=1%><b>" . _("Size")."</b></TD>\n";