0599282bd82737081c142ce66ecb9fcc8c124f4b
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>"; }
34 for ($i=0; $i < count($message_highlight_list); $i++
) {
35 if (trim($message_highlight_list[$i]["value"]) != "") {
36 if ($message_highlight_list[$i]["match_type"] == "to_cc") {
37 if (strpos("^^".strtolower($msg["TO"]), strtolower($message_highlight_list[$i]["value"])) ||
strpos("^^".strtolower($msg["CC"]), strtolower($message_highlight_list[$i]["value"]))) {
38 $hlt_color = $message_highlight_list[$i]["color"];
41 } else if (strpos("^^".strtolower($msg[strtoupper($message_highlight_list[$i]["match_type"])]),strtolower($message_highlight_list[$i]["value"]))) {
42 $hlt_color = $message_highlight_list[$i]["color"];
49 $hlt_color = $color[4];
51 if ($where && $what) {
52 $search_stuff = "&where=".urlencode($where)."&what=".urlencode($what);
56 $checked = " checked";
60 for ($i=1; $i <= count($index_order); $i++
) {
61 switch ($index_order[$i]) {
63 echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
66 echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$senderName$flag_end$bold_end$italic_end</td>\n";
69 echo " <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag".$msg["DATE_STRING"]."$flag_end$bold_end</center></td>\n";
72 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";
76 echo " <td bgcolor=$hlt_color width=1% nowrap><b><small>\n";
77 if ($msg["FLAG_ANSWERED"] == true) {
81 if ($msg["TYPE0"] == "multipart") {
85 if (ereg("(1|2)",substr($msg["PRIORITY"],0,1))) {
86 echo "<font color=$color[1]>!</font>\n";
89 if ($msg["FLAG_DELETED"]) {
90 echo "<font color=\"$color[1]\">D</font>\n";
94 if (!$stuff) echo " \n";
95 echo "</small></b></td>\n";
98 echo " <td bgcolor=$hlt_color width=1%>$bold".show_readable_size($msg['SIZE'])."$bold_end</td>\n";
108 ** This function loops through a group of messages in the mailbox and shows them
110 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
111 global $msgs, $msort;
113 global $message_highlight_list;
114 global $auto_expunge;
116 sqimap_mailbox_expunge($imapConnection, $mailbox, false);
117 sqimap_mailbox_select($imapConnection, $mailbox);
121 if ($numMessages >= 1) {
123 for ($q = 0; $q < $numMessages; $q++
) {
124 if($mailbox == $sent_folder)
125 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, true);
127 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, false);
129 $from[$q] = $hdr->from
;
130 $date[$q] = $hdr->date
;
131 $subject[$q] = $hdr->subject
;
133 $priority[$q] = $hdr->priority
;
135 $size[$q] = $hdr->size
;
136 $type[$q] = $hdr->type0
;
137 $flags[$q] = sqimap_get_flags ($imapConnection, $q+
1);
141 // if it's not sorted
142 if ($startMessage +
($show_num - 1) < $numMessages) {
143 $endMessage = $startMessage +
($show_num-1);
145 $endMessage = $numMessages;
148 if ($endMessage < $startMessage) {
149 $startMessage = $startMessage - $show_num;
150 if ($startMessage < 1)
155 $real_startMessage = $numMessages - $startMessage +
1;
156 $real_endMessage = $numMessages - $startMessage - $show_num;
157 if ($real_endMessage <= 0)
158 $real_endMessage = 1;
161 for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
162 if($mailbox == $sent_folder)
163 $hdr = sqimap_get_small_header ($imapConnection, $q, true);
165 $hdr = sqimap_get_small_header ($imapConnection, $q, false);
167 $from[$j] = $hdr->from
;
168 $date[$j] = $hdr->date
;
169 $subject[$j] = $hdr->subject
;
171 $priority[$j] = $hdr->priority
;
173 $size[$j] = $hdr->size
;
174 $type[$j] = $hdr->type0
;
175 $flags[$j] = sqimap_get_flags ($imapConnection, $q);
184 $end = $startMessage +
$show_num - 1;
189 $date[$j] = ereg_replace(" ", " ", $date[$j]);
190 $tmpdate = explode(" ", trim($date[$j]));
192 $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
193 $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
194 $messages[$j]["ID"] = $id[$j];
195 $messages[$j]["FROM"] = decodeHeader($from[$j]);
196 $messages[$j]["FROM-SORT"] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
197 $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
198 $messages[$j]["SUBJECT-SORT"] = strtolower(decodeHeader($subject[$j]));
199 $messages[$j]["TO"] = decodeHeader($to[$j]);
200 $messages[$j]["PRIORITY"] = $priority[$j];
201 $messages[$j]["CC"] = $cc[$j];
202 $messages[$j]["SIZE"] = $size[$j];
203 $messages[$j]["TYPE0"] = $type[$j];
205 # fix SUBJECT-SORT to remove Re:
206 $re_abbr = # Add more here!
207 "vedr|sv|" . # Danish
209 if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
210 $messages[$j]['SUBJECT-SORT'] = $regs[2];
213 while ($num < count($flags[$j])) {
214 if ($flags[$j][$num] == "Deleted") {
215 $messages[$j]["FLAG_DELETED"] = true;
217 elseif ($flags[$j][$num] == "Answered") {
218 $messages[$j]["FLAG_ANSWERED"] = true;
220 elseif ($flags[$j][$num] == "Seen") {
221 $messages[$j]["FLAG_SEEN"] = true;
223 elseif ($flags[$j][$num] == "Flagged") {
224 $messages[$j]["FLAG_FLAGGED"] = true;
231 /* Only ignore messages flagged as deleted if we are using a
232 * trash folder or auto_expunge */
233 if (($move_to_trash ||
$auto_expunge) && $sort != 6)
235 /** Find and remove the ones that are deleted */
238 while ($j < $numMessages) {
239 if ($messages[$j]["FLAG_DELETED"] == true) {
243 $msgs[$i] = $messages[$j];
254 // There's gotta be messages in the array for it to sort them.
255 if ($numMessages > 0 && ! $use_cache) {
256 /** 0 = Date (up) 4 = Subject (up)
257 ** 1 = Date (dn) 5 = Subject (dn)
261 session_unregister("msgs");
262 if (($sort == 0) ||
($sort == 1))
263 $msort = array_cleave ($msgs, "TIME_STAMP");
264 if (($sort == 2) ||
($sort == 3))
265 $msort = array_cleave ($msgs, "FROM-SORT");
266 if (($sort == 4) ||
($sort == 5))
267 $msort = array_cleave ($msgs, "SUBJECT-SORT");
278 session_register("msort");
280 displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
281 session_register("msgs");
284 // generic function to convert the msgs array into an HTML table
285 function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
286 global $folder_prefix, $sent_folder;
287 global $imapServerAddress;
288 global $index_order, $real_endMessage, $real_startMessage;
290 // if cache isn't already set, do it now
291 if (!session_is_registered("msgs"))
292 session_register("msgs");
293 if (!session_is_registered("msort"))
294 session_register("msort");
296 if ($startMessage +
($show_num - 1) < $numMessages) {
297 $endMessage = $startMessage +
($show_num-1);
299 $endMessage = $numMessages;
302 if ($endMessage < $startMessage) {
303 $startMessage = $startMessage - $show_num;
304 if ($startMessage < 1)
308 $nextGroup = $startMessage +
$show_num;
309 $prevGroup = $startMessage - $show_num;
310 $urlMailbox = urlencode($mailbox);
312 do_hook("mailbox_index_before");
315 if ($startMessage < $endMessage) {
316 $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
317 } elseif ($startMessage == $endMessage) {
318 $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
327 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
328 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
329 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
331 elseif (($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 .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
335 elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
336 $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
337 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
340 mail_message_listing_beginning($imapConnection,
341 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
342 $mailbox, $sort, $Message, $More, $startMessage);
344 $groupNum = $startMessage %
($show_num - 1);
345 $real_startMessage = $startMessage;
347 if ($endMessage - $startMessage < $show_num - 1) {
348 $endMessage = $endMessage - $startMessage +
1;
350 } else if ($startMessage > $show_num) {
351 $endMessage = $show_num;
356 $endVar = $endMessage +
1;
358 // loop through and display the info for each message.
359 $t = 0; // $t is used for the checkbox number
360 if ($numMessages == 0) { // if there's no messages in this folder
361 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
362 echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER></TD></TR>";
363 } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
373 } while (isset ($key) && ($k < $i));
374 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
383 } while (isset ($key) && ($k < $i));
386 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
391 } while ($i && $i < $endVar);
397 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
398 echo "<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td>";
399 echo "$More</td><td align=right>\n";
400 if (!$startMessage) $startMessage=1;
401 if ( $checkall == "1")
402 echo "\n<A HREF=\"right_main.php?mailbox=$mailbox&startMessage=$real_startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
404 echo "\n<A HREF=\"right_main.php?mailbox=$mailbox&startMessage=$real_startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
406 echo "</td></tr></table>";
408 echo "</table>"; /** End of message-list table */
410 do_hook("mailbox_index_after");
413 /* Displays the standard message list header.
414 * To finish the table, you need to do a "</table></table>";
415 * $moveURL is the URL to submit the delete/move form to
416 * $mailbox is the current mailbox
417 * $sort is the current sorting method (-1 for no sorting available [searches])
418 * $Message is a message that is centered on top of the list
419 * $More is a second line that is left aligned
421 function mail_message_listing_beginning($imapConnection, $moveURL,
422 $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
424 global $color, $index_order, $auto_expunge, $move_to_trash;
426 $urlMailbox = urlencode($mailbox);
428 /** This is the beginning of the message list table. It wraps around all messages */
429 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>";
433 echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
436 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
437 echo "<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td>";
438 echo "$More</td><td align=right>\n";
439 if ( $checkall == "1")
440 echo "\n<A HREF=\"right_main.php?mailbox=$mailbox&startMessage=$startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
442 echo "\n<A HREF=\"right_main.php?mailbox=$mailbox&startMessage=$startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
444 echo "</td></tr></table>";
447 /** The delete and move options */
448 echo "<TR><TD BGCOLOR=\"$color[0]\">";
450 echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n";
451 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
453 echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
456 echo " <NOBR><SMALL>". _("Move selected to:") ."</SMALL>";
457 echo " <TT><SMALL><SELECT NAME=\"targetMailbox\">";
459 $boxes = sqimap_mailbox_list($imapConnection);
460 for ($i = 0; $i < count($boxes); $i++
) {
461 if ($boxes[$i]["flags"][0] != "noselect" &&
462 $boxes[$i]["flags"][1] != "noselect" &&
463 $boxes[$i]["flags"][2] != "noselect") {
464 $box = $boxes[$i]["unformatted"];
465 $box2 = replace_spaces($boxes[$i]["unformatted-disp"]);
466 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
469 echo " </SELECT></SMALL></TT>";
470 echo " <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"". _("Move") ."\"></SMALL></NOBR>\n";
472 echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
473 if (! $move_to_trash && ! $auto_expunge) {
474 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT NAME=\"expungeButton\" VALUE=\"". _("Expunge") ."\"> ". _("mailbox") ."</SMALL></NOBR> \n";
476 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\"> ". _("checked messages") ."</SMALL></NOBR>\n";
481 do_hook("mailbox_form_before");
484 echo "<TR><TD BGCOLOR=\"$color[0]\">";
485 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">";
486 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
488 $urlMailbox=urlencode($mailbox);
491 for ($i=1; $i <= count($index_order); $i++
) {
492 switch ($index_order[$i]) {
495 echo " <TD WIDTH=1%><B> </B></TD>";
499 if ($mailbox == $sent_folder)
500 echo " <TD WIDTH=30%><B>". _("To") ."</B>";
502 echo " <TD WIDTH=30%><B>". _("From") ."</B>";
505 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";
507 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";
509 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";
514 echo " <TD nowrap WIDTH=1%><B>". _("Date") ."</B>";
516 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";
518 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";
520 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";
522 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";
527 echo " <TD WIDTH=%><B>". _("Subject") ."</B>\n";
529 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";
531 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";
533 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";
538 echo " <TD WIDTH=1%><b>" . _("Size")."</b></TD>\n";