c51dd746accf0d9d900c290cdad6db37abb257e1
6 ** This contains functions that display mailbox information, such as the
7 ** table row that has sender, date, subject, etc...
12 $mailbox_display_php = true;
14 function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
16 global $color, $msgs, $msort;
18 global $message_highlight_list;
23 $senderName = sqimap_find_displayable_name($msg['FROM']);
24 $urlMailbox = urlencode($mailbox);
25 $subject = trim($msg['SUBJECT']);
27 $subject = _("(no subject)");
31 if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true)
33 $flag = "<font color=$color[2]>";
34 $flag_end = '</font>';
41 if (!isset($msg['FLAG_SEEN']) ||
$msg['FLAG_SEEN'] == false)
51 if ($mailbox == $sent_folder)
61 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'])
63 $fontstr = "<font color=\"$color[9]\">";
64 $fontstr_end = '</font>';
72 for ($i=0; $i < count($message_highlight_list); $i++
) {
73 if (trim($message_highlight_list[$i]['value']) != '') {
74 if ($message_highlight_list[$i]['match_type'] == 'to_cc') {
75 if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) ||
strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) {
76 $hlt_color = $message_highlight_list[$i]['color'];
79 } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) {
80 $hlt_color = $message_highlight_list[$i]['color'];
86 if (!isset($hlt_color))
87 $hlt_color = $color[4];
89 if ($where && $what) {
90 $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
94 $checked = ' checked';
98 for ($i=1; $i <= count($index_order); $i++
) {
99 switch ($index_order[$i]) {
101 echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
104 echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
107 echo " <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
110 echo " <td bgcolor=$hlt_color>$bold";
111 if (! isset($search_stuff)) { $search_stuff = ''; }
112 echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
113 do_hook("subject_link");
115 if (strlen($subject) > 55)
116 echo substr($subject, 0, 50) . '...';
119 echo "$flag_end</a>$bold_end</td>\n";
123 echo " <td bgcolor=$hlt_color align=center width=1% nowrap><b><small>\n";
124 if (isset($msg['FLAG_ANSWERED']) &&
125 $msg['FLAG_ANSWERED'] == true) {
129 if ($msg['TYPE0'] == 'multipart') {
133 if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
134 echo "<font color=$color[1]>!</font>\n";
137 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
138 echo "<font color=\"$color[1]\">D</font>\n";
142 if (!$stuff) echo " \n";
143 echo "</small></b></td>\n";
146 echo " <td bgcolor=$hlt_color width=1%>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
156 ** This function loops through a group of messages in the mailbox and shows them
158 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
159 global $msgs, $msort;
161 global $message_highlight_list;
162 global $auto_expunge;
164 if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false);
165 sqimap_mailbox_select($imapConnection, $mailbox);
169 if ($numMessages >= 1) {
171 for ($q = 0; $q < $numMessages; $q++
) {
172 if($mailbox == $sent_folder)
173 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, true);
175 $hdr = sqimap_get_small_header ($imapConnection, $q+
1, false);
177 $from[$q] = $hdr->from
;
178 $date[$q] = $hdr->date
;
179 $subject[$q] = $hdr->subject
;
181 $priority[$q] = $hdr->priority
;
183 $size[$q] = $hdr->size
;
184 $type[$q] = $hdr->type0
;
185 $flags[$q] = sqimap_get_flags ($imapConnection, $q+
1);
189 // if it's not sorted
190 if ($startMessage +
($show_num - 1) < $numMessages) {
191 $endMessage = $startMessage +
($show_num-1);
193 $endMessage = $numMessages;
196 if ($endMessage < $startMessage) {
197 $startMessage = $startMessage - $show_num;
198 if ($startMessage < 1)
203 $real_startMessage = $numMessages - $startMessage +
1;
204 $real_endMessage = $numMessages - $startMessage - $show_num;
205 if ($real_endMessage <= 0)
206 $real_endMessage = 1;
209 for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
210 if($mailbox == $sent_folder)
211 $hdr = sqimap_get_small_header ($imapConnection, $q, true);
213 $hdr = sqimap_get_small_header ($imapConnection, $q, false);
215 $from[$j] = $hdr->from
;
216 $date[$j] = $hdr->date
;
217 $subject[$j] = $hdr->subject
;
219 $priority[$j] = $hdr->priority
;
221 $size[$j] = $hdr->size
;
222 $type[$j] = $hdr->type0
;
223 $flags[$j] = sqimap_get_flags ($imapConnection, $q);
232 $end = $startMessage +
$show_num - 1;
233 if ($numMessages < $show_num)
234 $end_loop = $numMessages;
236 $end_loop = $show_num;
241 if ($end > $numMessages) $end = $numMessages;
242 while ($j < $end_loop) {
243 if (isset($date[$j])) {
244 $date[$j] = ereg_replace(' ', ' ', $date[$j]);
245 $tmpdate = explode(' ', trim($date[$j]));
247 $tmpdate = $date = array("","","","","","");
250 $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
251 $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']);
252 $messages[$j]['ID'] = $id[$j];
253 $messages[$j]['FROM'] = decodeHeader($from[$j]);
254 $messages[$j]['FROM-SORT'] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
255 $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
256 $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
257 $messages[$j]['TO'] = decodeHeader($to[$j]);
258 $messages[$j]['PRIORITY'] = $priority[$j];
259 $messages[$j]['CC'] = $cc[$j];
260 $messages[$j]['SIZE'] = $size[$j];
261 $messages[$j]['TYPE0'] = $type[$j];
263 # fix SUBJECT-SORT to remove Re:
264 $re_abbr = # Add more here!
265 'vedr|sv|' . # Danish
267 if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
268 $messages[$j]['SUBJECT-SORT'] = $regs[2];
271 while ($num < count($flags[$j])) {
272 if ($flags[$j][$num] == 'Deleted') {
273 $messages[$j]['FLAG_DELETED'] = true;
275 elseif ($flags[$j][$num] == 'Answered') {
276 $messages[$j]['FLAG_ANSWERED'] = true;
278 elseif ($flags[$j][$num] == 'Seen') {
279 $messages[$j]['FLAG_SEEN'] = true;
281 elseif ($flags[$j][$num] == 'Flagged') {
282 $messages[$j]['FLAG_FLAGGED'] = true;
289 /* Only ignore messages flagged as deleted if we are using a
290 * trash folder or auto_expunge */
291 if (((isset($move_to_trash) && $move_to_trash)
292 ||
(isset($auto_expunge) && $auto_expunge)) && $sort != 6)
294 /** Find and remove the ones that are deleted */
297 while ($j < $numMessages) {
298 if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) {
302 $msgs[$i] = $messages[$j];
309 if (! isset($messages))
315 // There's gotta be messages in the array for it to sort them.
316 if ($numMessages > 0 && ! $use_cache) {
317 /** 0 = Date (up) 4 = Subject (up)
318 ** 1 = Date (dn) 5 = Subject (dn)
322 session_unregister("msgs");
323 if (($sort == 0) ||
($sort == 1))
324 $msort = array_cleave ($msgs, 'TIME_STAMP');
325 if (($sort == 2) ||
($sort == 3))
326 $msort = array_cleave ($msgs, 'FROM-SORT');
327 if (($sort == 4) ||
($sort == 5))
328 $msort = array_cleave ($msgs, 'SUBJECT-SORT');
339 session_register('msort');
341 displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
342 session_register('msgs');
345 // generic function to convert the msgs array into an HTML table
346 function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
347 global $folder_prefix, $sent_folder;
348 global $imapServerAddress;
349 global $index_order, $real_endMessage, $real_startMessage, $checkall;
351 // if cache isn't already set, do it now
352 if (!session_is_registered('msgs'))
353 session_register('msgs');
354 if (!session_is_registered('msort'))
355 session_register('msort');
357 if ($startMessage +
($show_num - 1) < $numMessages) {
358 $endMessage = $startMessage +
($show_num-1);
360 $endMessage = $numMessages;
363 if ($endMessage < $startMessage) {
364 $startMessage = $startMessage - $show_num;
365 if ($startMessage < 1)
369 $nextGroup = $startMessage +
$show_num;
370 $prevGroup = $startMessage - $show_num;
371 $urlMailbox = urlencode($mailbox);
373 do_hook('mailbox_index_before');
376 if ($startMessage < $endMessage) {
377 $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
378 } elseif ($startMessage == $endMessage) {
379 $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
388 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
389 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
390 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
392 elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
393 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
394 $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
396 elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
397 $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
398 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
403 mail_message_listing_beginning($imapConnection,
404 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
405 $mailbox, $sort, $Message, $More, $startMessage);
407 $groupNum = $startMessage %
($show_num - 1);
408 $real_startMessage = $startMessage;
410 if ($endMessage - $startMessage < $show_num - 1) {
411 $endMessage = $endMessage - $startMessage +
1;
413 } else if ($startMessage > $show_num) {
414 $endMessage = $show_num;
419 $endVar = $endMessage +
1;
421 // loop through and display the info for each message.
422 $t = 0; // $t is used for the checkbox number
423 if ($numMessages == 0) { // if there's no messages in this folder
424 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
425 echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER></TD></TR>";
426 } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
437 } while (isset ($key) && ($k < $i));
438 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
448 } while (isset ($key) && ($k < $i));
451 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
456 } while ($i && $i < $endVar);
462 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
463 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
464 echo "$More</td><td align=right>\n";
465 if (!$startMessage) $startMessage=1;
466 if ( $checkall == '1')
467 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$real_startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
469 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$real_startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
471 echo '</td></tr></table>';
473 echo '</table>'; /** End of message-list table */
475 do_hook('mailbox_index_after');
478 /* Displays the standard message list header.
479 * To finish the table, you need to do a "</table></table>";
480 * $moveURL is the URL to submit the delete/move form to
481 * $mailbox is the current mailbox
482 * $sort is the current sorting method (-1 for no sorting available [searches])
483 * $Message is a message that is centered on top of the list
484 * $More is a second line that is left aligned
486 function mail_message_listing_beginning($imapConnection, $moveURL,
487 $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
489 global $color, $index_order, $auto_expunge, $move_to_trash;
490 global $checkall, $sent_folder;
491 $urlMailbox = urlencode($mailbox);
493 /** This is the beginning of the message list table. It wraps around all messages */
494 echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">';
498 echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
501 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
502 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
503 echo "$More</td><td align=right>\n";
504 if ( $checkall == '1')
505 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
507 echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
509 echo '</td></tr></table>';
512 /** The delete and move options */
513 echo "<TR><TD BGCOLOR=\"$color[0]\">";
515 echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n";
516 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
518 echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
521 echo ' <NOBR><SMALL>'. _("Move selected to:") .'</SMALL>';
522 echo ' <TT><SMALL><SELECT NAME="targetMailbox">';
524 $boxes = sqimap_mailbox_list($imapConnection);
525 for ($i = 0; $i < count($boxes); $i++
) {
526 if (!in_array("noselect", $boxes[$i]["flags"])) {
527 $box = $boxes[$i]['unformatted'];
528 $box2 = replace_spaces($boxes[$i]['unformatted-disp']);
529 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
532 echo ' </SELECT></SMALL></TT>';
533 echo ' <SMALL><INPUT TYPE=SUBMIT NAME="moveButton" VALUE="'. _("Move") ."\"></SMALL></NOBR>\n";
535 echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
536 if (! $auto_expunge) {
537 echo ' <NOBR><SMALL><INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'"> '. _("mailbox") ."</SMALL></NOBR> \n";
539 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\"> ". _("checked messages") ."</SMALL></NOBR>\n";
544 do_hook('mailbox_form_before');
547 echo "<TR><TD BGCOLOR=\"$color[0]\">";
548 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">";
549 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
551 $urlMailbox=urlencode($mailbox);
554 for ($i=1; $i <= count($index_order); $i++
) {
555 switch ($index_order[$i]) {
558 echo ' <TD WIDTH="1%"><B> </B></TD>';
562 if ($mailbox == $sent_folder)
563 echo ' <TD WIDTH="30%"><B>'. _("To") .'</B>';
565 echo ' <TD WIDTH="30%"><B>'. _("From") .'</B>';
568 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";
570 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";
572 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";
577 echo ' <TD nowrap WIDTH="1%"><B>'. _("Date") .'</B>';
579 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";
581 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";
583 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";
585 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";
590 echo ' <TD WIDTH=%><B>'. _("Subject") ."</B>\n";
592 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";
594 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";
596 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";
601 echo ' <TD WIDTH="1%"><b>' . _("Size")."</b></TD>\n";