Right-to-Left fixes by Saleh Madi <webmail@p-i-s.com>
[squirrelmail.git] / functions / mailbox_display.php
1 <?php
2
3 /**
4 * mailbox_display.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This contains functions that display mailbox information, such as the
10 * table row that has sender, date, subject, etc...
11 *
12 * $Id$
13 */
14
15 require_once(SM_PATH . 'functions/strings.php');
16 require_once(SM_PATH . 'functions/html.php');
17 require_once(SM_PATH . 'class/html.class.php');
18 require_once(SM_PATH . 'functions/imap_mailbox.php');
19 require_once(SM_PATH . 'functions/set_language_align.php');
20
21 /* --------------------- Get globals ------------------------------------- */
22 $language_align = set_language_align();
23
24 /* Default value for page_selector_max. */
25 define('PG_SEL_MAX', 10);
26
27 function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
28 $start_msg, $where, $what) {
29 global $checkall,
30 $color, $msgs, $msort,
31 $default_use_priority,
32 $message_highlight_list,
33 $index_order,
34 $indent_array, /* indent subject by */
35 $pos, /* Search postion (if any) */
36 $thread_sort_messages, /* thread sorting on/off */
37 $server_sort_order, /* sort value when using server-sorting */
38 $row_count,
39 $allow_server_sort; /* enable/disable server-side sorting */
40 $color_string = $color[4];
41
42 if ($GLOBALS['alt_index_colors']) {
43 if (!isset($row_count)) {
44 $row_count = 0;
45 }
46 $row_count++;
47 if ($row_count % 2) {
48 if (!isset($color[12])) {
49 $color[12] = '#EAEAEA';
50 }
51 $color_string = $color[12];
52 }
53 }
54 $msg = $msgs[$key];
55
56 if($mailbox == 'None') {
57 $boxes = sqimap_mailbox_list($imapConnection);
58 $mailbox = $boxes[0]['unformatted'];
59 unset($boxes);
60 }
61 $urlMailbox = urlencode($mailbox);
62
63 if (handleAsSent($mailbox)) {
64 $msg['FROM'] = $msg['TO'];
65 /*
66 * This is done in case you're looking into Sent folders,
67 * because you can have multiple receivers.
68 */
69 $senderNames = explode(',', $msg['FROM']);
70 $senderName = '';
71 if (sizeof($senderNames)){
72 foreach ($senderNames as $senderNames_part) {
73 if ($senderName != '') {
74 $senderName .= ', ';
75 }
76 $senderName .= sqimap_find_displayable_name($senderNames_part);
77 }
78 }
79 } else {
80 $senderName = sqimap_find_displayable_name($msg['FROM']);
81 }
82
83 $subject = processSubject($msg['SUBJECT'], $indent_array[$msg['ID']]);
84
85 echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
86
87 if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
88 $flag = "<font color=\"$color[2]\">";
89 $flag_end = '</font>';
90 } else {
91 $flag = '';
92 $flag_end = '';
93 }
94 if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
95 $bold = '<b>';
96 $bold_end = '</b>';
97 } else {
98 $bold = '';
99 $bold_end = '';
100 }
101 if (handleAsSent($mailbox)) {
102 $italic = '<i>';
103 $italic_end = '</i>';
104 } else {
105 $italic = '';
106 $italic_end = '';
107 }
108 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
109 $fontstr = "<font color=\"$color[9]\">";
110 $fontstr_end = '</font>';
111 } else {
112 $fontstr = '';
113 $fontstr_end = '';
114 }
115
116 if ($where && $what) {
117 $searchstr = '&amp;where='.$where.'&amp;what='.$what;
118 } else {
119 $searchstr = '';
120 }
121 /**
122 * AAAAH! Make my eyes stop bleeding!
123 * Who wrote this?!
124 */
125 if (is_array($message_highlight_list) && count($message_highlight_list)){
126 foreach ($message_highlight_list as $message_highlight_list_part) {
127 if (trim($message_highlight_list_part['value']) != '') {
128 $high_val = strtolower($message_highlight_list_part['value']);
129 $match_type = strtoupper($message_highlight_list_part['match_type']);
130 if ($match_type == 'TO_CC') {
131 if (strstr('^^' . strtolower($msg['TO']), $high_val) ||
132 strstr('^^' . strtolower($msg['CC']), $high_val)) {
133 $hlt_color = $message_highlight_list_part['color'];
134 continue;
135 }
136 } else {
137 if (strstr('^^' . strtolower($msg[$match_type]), $high_val)) {
138 $hlt_color = $message_highlight_list_part['color'];
139 continue;
140 }
141 }
142 }
143 }
144 }
145
146 if (!isset($hlt_color)) {
147 $hlt_color = $color_string;
148 }
149 $checked = ($checkall == 1) ? ' CHECKED' : '';
150 $col = 0;
151 if (sizeof($index_order)) {
152 foreach ($index_order as $index_order_part) {
153 switch ($index_order_part) {
154 case 1: /* checkbox */
155 echo html_tag( 'td',
156 "<input type=checkbox name=\"msg[$t]\" value=\"".$msg['ID']."\"$checked>",
157 'center',
158 $hlt_color );
159 break;
160 case 2: /* from */
161 echo html_tag( 'td',
162 $italic . $bold . $flag . $fontstr . $senderName .
163 $fontstr_end . $flag_end . $bold_end . $italic_end,
164 'left',
165 $hlt_color );
166 break;
167 case 3: /* date */
168 $date_string = $msg['DATE_STRING'] . '';
169 if ($date_string == '') {
170 $date_string = _("Unknown date");
171 }
172 echo html_tag( 'td',
173 $bold . $flag . $fontstr . $date_string .
174 $fontstr_end . $flag_end . $bold_end,
175 'center',
176 $hlt_color,
177 'nowrap' );
178 break;
179 case 4: /* subject */
180 $td_str = $bold;
181 if ($thread_sort_messages == 1) {
182 if (isset($indent_array[$msg['ID']])) {
183 $td_str .= str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$indent_array[$msg['ID']]);
184 }
185 }
186 $td_str .= '<a href="read_body.php?mailbox='.$urlMailbox
187 . '&amp;passed_id='. $msg["ID"]
188 . '&amp;startMessage='.$start_msg.$searchstr.'"';
189 do_hook("subject_link");
190 if ($subject != $msg['SUBJECT']) {
191 $title = get_html_translation_table(HTML_SPECIALCHARS);
192 $title = array_flip($title);
193 $title = strtr($msg['SUBJECT'], $title);
194 $title = str_replace('"', "''", $title);
195 $td_str .= " title=\"$title\"";
196 }
197 $td_str .= ">$flag$subject$flag_end</a>$bold_end";
198 echo html_tag( 'td', $td_str, 'left', $hlt_color );
199 break;
200 case 5: /* flags */
201 $stuff = false;
202 $td_str = "<b><small>";
203
204 if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) {
205 $td_str .= _("A");
206 $stuff = true;
207 }
208 if ($msg['TYPE0'] == 'multipart') {
209 $td_str .= '+';
210 $stuff = true;
211 }
212 if ($default_use_priority) {
213 if ( ($msg['PRIORITY'] == 1) || ($msg['PRIORITY'] == 2) ) {
214 $td_str .= "<font color=\"$color[1]\">!</font>";
215 $stuff = true;
216 }
217 if ($msg['PRIORITY'] == 5) {
218 $td_str .= "<font color=\"$color[8]\">?</font>";
219 $stuff = true;
220 }
221 }
222 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) {
223 $td_str .= "<font color=\"$color[1]\">D</font>";
224 $stuff = true;
225 }
226 if (!$stuff) {
227 $td_str .= '&nbsp;';
228 }
229 $td_str .= '</small></b>';
230 echo html_tag( 'td',
231 $td_str,
232 'center',
233 $hlt_color,
234 'nowrap' );
235 break;
236 case 6: /* size */
237 echo html_tag( 'td',
238 $bold . $fontstr . show_readable_size($msg['SIZE']) .
239 $fontstr_end . $bold_end,
240 'right',
241 $hlt_color );
242 break;
243 }
244 ++$col;
245 }
246 }
247 if ($not_last) {
248 echo '</tr>' . "\n" . '<tr><td COLSPAN="' . $col . '" BGCOLOR="' .
249 $color[0] . '" HEIGHT="1"></td></tr>' . "\n";
250 } else {
251 echo '</tr>'."\n";
252 }
253 }
254
255 function getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id) {
256 if ($id != 'no') {
257 if ($start_msg + ($show_num - 1) < $num_msgs) {
258 $end_msg = $start_msg + ($show_num-1);
259 } else {
260 $end_msg = $num_msgs;
261 }
262 $id = array_slice($id, ($start_msg-1), ($end_msg));
263
264 $end = $start_msg + $show_num - 1;
265 if ($num_msgs < $show_num) {
266 $end_loop = $num_msgs;
267 } else if ($end > $num_msgs) {
268 $end_loop = $num_msgs - $start_msg + 1;
269 } else {
270 $end_loop = $show_num;
271 }
272 return fillMessageArray($imapConnection,$id,$end_loop);
273 } else {
274 return false;
275 }
276 }
277
278 function getThreadMessages($imapConnection, $start_msg, $show_num, $num_msgs) {
279 $id = get_thread_sort($imapConnection);
280 return getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
281 }
282
283 function getServerSortMessages($imapConnection, $start_msg, $show_num,
284 $num_msgs, $server_sort_order, $mbxresponse) {
285 $id = sqimap_get_sort_order($imapConnection, $server_sort_order,$mbxresponse);
286 return getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
287 }
288
289 function getSelfSortMessages($imapConnection, $start_msg, $show_num,
290 $num_msgs, $sort, $mbxresponse) {
291 $msgs = array();
292 if ($num_msgs >= 1) {
293 $id = sqimap_get_php_sort_order ($imapConnection, $mbxresponse);
294 if ($sort < 6 ) {
295 $end = $num_msgs;
296 $end_loop = $end;
297 } else {
298 /* if it's not sorted */
299 if ($start_msg + ($show_num - 1) < $num_msgs) {
300 $end_msg = $start_msg + ($show_num - 1);
301 } else {
302 $end_msg = $num_msgs;
303 }
304 if ($end_msg < $start_msg) {
305 $start_msg = $start_msg - $show_num;
306 if ($start_msg < 1) {
307 $start_msg = 1;
308 }
309 }
310 $id = array_slice(array_reverse($id), ($start_msg-1), ($end_msg));
311 $end = $start_msg + $show_num - 1;
312 if ($num_msgs < $show_num) {
313 $end_loop = $num_msgs;
314 } else if ($end > $num_msgs) {
315 $end_loop = $num_msgs - $start_msg + 1;
316 } else {
317 $end_loop = $show_num;
318 }
319 }
320 $msgs = fillMessageArray($imapConnection,$id,$end_loop);
321 }
322 return $msgs;
323 }
324
325
326
327 /*
328 * This function loops through a group of messages in the mailbox
329 * and shows them to the user.
330 */
331 function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
332 $start_msg, $sort, $color, $show_num,
333 $use_cache, $mode='') {
334 global $msgs, $msort, $auto_expunge, $thread_sort_messages, $language_align,
335 $allow_server_sort, $server_sort_order;
336
337 /* If autoexpunge is turned on, then do it now. */
338 $mbxresponse = sqimap_mailbox_select($imapConnection, $mailbox);
339 $srt = $sort;
340 /* If autoexpunge is turned on, then do it now. */
341 if ($auto_expunge == true) {
342 $exp_cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, false, '');
343 $mbxresponse['EXISTS'] = $mbxresponse['EXISTS'] - $exp_cnt;
344 $num_msgs = $mbxresponse['EXISTS'];
345 }
346
347 if ($mbxresponse['EXISTS'] > 0) {
348 /* if $start_msg is lower than $num_msgs, we probably deleted all messages
349 * in the last page. We need to re-adjust the start_msg
350 */
351
352 if($start_msg > $num_msgs) {
353 $start_msg -= $show_num;
354 if($start_msg < 1) {
355 $start_msg = 1;
356 }
357 }
358
359 /* This code and the next if() block check for
360 * server-side sorting methods. The $id array is
361 * formatted and $sort is set to 6 to disable
362 * SM internal sorting
363 */
364
365 if ($thread_sort_messages == 1) {
366 $mode = 'thread';
367 } elseif ($allow_server_sort == 1) {
368 $mode = 'serversort';
369 } else {
370 $mode = '';
371 }
372
373 sqsession_unregister('msort');
374 sqsession_unregister('msgs');
375 switch ($mode) {
376 case 'thread':
377 $id = get_thread_sort($imapConnection);
378 $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
379 if ($msgs === false) {
380 echo '<b><small><center><font color=red>' .
381 _("Thread sorting is not supported by your IMAP server.<br>Please report this to the system administrator.").
382 '</center></small></b>';
383 $thread_sort_messages = 0;
384 $msort = $msgs = array();
385 } else {
386 $msort= $msgs;
387 $sort = 6;
388 }
389 break;
390 case 'serversort':
391 $id = sqimap_get_sort_order($imapConnection, $sort, $mbxresponse);
392 $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
393 if ($msgs === false) {
394 echo '<b><small><center><font color=red>' .
395 _( "Server-side sorting is not supported by your IMAP server.<br>Please report this to the system administrator.").
396 '</center></small></b>';
397 $sort = $server_sort_order;
398 $allow_server_sort = FALSE;
399 $msort = $msgs = array();
400 $id = array();
401 } else {
402 $msort = $msgs;
403 $sort = 6;
404 }
405 break;
406 default:
407 if (!$use_cache) {
408 $msgs = getSelfSortMessages($imapConnection, $start_msg, $show_num,
409 $num_msgs, $sort, $mbxresponse);
410 $msort = calc_msort($msgs, $sort);
411 } /* !use cache */
412 break;
413 } // switch
414 sqsession_register($msort, 'msort');
415 sqsession_register($msgs, 'msgs');
416 } /* if exists > 0 */
417
418 $res = getEndMessage($start_msg, $show_num, $num_msgs);
419 $start_msg = $res[0];
420 $end_msg = $res[1];
421
422 $paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg,
423 $num_msgs, $show_num, $sort);
424
425 $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
426
427 do_hook('mailbox_index_before');
428 echo '<table dir="' . $language_align['dir'] . '" border="0" width="100%" cellpadding="0" cellspacing="0">';
429 echo '<tr><td>';
430
431 mail_message_listing_beginning($imapConnection, $mailbox, $sort,
432 $msg_cnt_str, $paginator_str, $start_msg);
433 echo '</td></tr>';
434 /* line between the button area and the list */
435 echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'"></td></tr>';
436
437 echo '<tr><td>';
438 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
439 echo ' <tr><td>';
440 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[5].'">';
441 echo '<tr><td>';
442 printHeader($mailbox, $srt, $color, !$thread_sort_messages);
443
444 displayMessageArray($imapConnection, $num_msgs, $start_msg,
445 $msort, $mailbox, $sort, $color, $show_num,0,0);
446 echo '</td></tr></table></td></tr></table>';
447
448 mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color);
449 echo '</td></tr></table>';
450 }
451
452 function calc_msort($msgs, $sort) {
453
454 /*
455 * 0 = Date (up)
456 * 1 = Date (dn)
457 * 2 = Name (up)
458 * 3 = Name (dn)
459 * 4 = Subject (up)
460 * 5 = Subject (dn)
461 */
462
463 if (($sort == 0) || ($sort == 1)) {
464 foreach ($msgs as $item) {
465 $msort[] = $item['TIME_STAMP'];
466 }
467 } elseif (($sort == 2) || ($sort == 3)) {
468 foreach ($msgs as $item) {
469 $msort[] = $item['FROM-SORT'];
470 }
471 } elseif (($sort == 4) || ($sort == 5)) {
472 foreach ($msgs as $item) {
473 $msort[] = $item['SUBJECT-SORT'];
474 }
475 } else {
476 $msort = $msgs;
477 }
478 if ($sort < 6) {
479 if ($sort % 2) {
480 asort($msort);
481 } else {
482 arsort($msort);
483 }
484 }
485 return $msort;
486 }
487
488 function fillMessageArray($imapConnection, $id, $count) {
489 $msgs_list = sqimap_get_small_header_list($imapConnection, $id);
490 $messages = array();
491 if (sizeof($msgs_list)) {
492 foreach ($msgs_list as $hdr) {
493 $unique_id[] = $hdr->uid;
494 $from[] = $hdr->from;
495 $date[] = $hdr->date;
496 $subject[] = $hdr->subject;
497 $to[] = $hdr->to;
498 $priority[] = $hdr->priority;
499 $cc[] = $hdr->cc;
500 $size[] = $hdr->size;
501 $type[] = $hdr->type0;
502 $flag_deleted[] = $hdr->flag_deleted;
503 $flag_answered[] = $hdr->flag_answered;
504 $flag_seen[] = $hdr->flag_seen;
505 $flag_flagged[] = $hdr->flag_flagged;
506 }
507 }
508
509 for($j = 0; $j < $count; ++$j) {
510 if (isset($date[$j])) {
511 $date[$j] = str_replace(' ', ' ', $date[$j]);
512 $tmpdate = explode(' ', trim($date[$j]));
513 } else {
514 $tmpdate = $date = array('', '', '', '', '', '');
515 }
516 $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
517 $messages[$j]['DATE_STRING'] =
518 getDateString($messages[$j]['TIME_STAMP']);
519 $messages[$j]['ID'] = $unique_id[$j];
520 $messages[$j]['FROM'] = decodeHeader($from[$j]);
521 $messages[$j]['FROM-SORT'] =
522 strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
523 $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
524 $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
525 $messages[$j]['TO'] = decodeHeader($to[$j]);
526 $messages[$j]['PRIORITY'] = $priority[$j];
527 $messages[$j]['CC'] = $cc[$j];
528 $messages[$j]['SIZE'] = $size[$j];
529 $messages[$j]['TYPE0'] = $type[$j];
530 $messages[$j]['FLAG_DELETED'] = $flag_deleted[$j];
531 $messages[$j]['FLAG_ANSWERED'] = $flag_answered[$j];
532 $messages[$j]['FLAG_SEEN'] = $flag_seen[$j];
533 $messages[$j]['FLAG_FLAGGED'] = $flag_flagged[$j];
534
535 /*
536 * fix SUBJECT-SORT to remove Re:
537 * vedr|sv (Danish)
538 * re|aw (English)
539 *
540 * TODO: i18n should be incorporated here. E.g. we catch the ones
541 * we know about, but also define in i18n what the localized
542 * "Re: " is for this or that locale.
543 */
544 if (preg_match("/^(vedr|sv|re|aw):\s*(.*)$/si",
545 $messages[$j]['SUBJECT-SORT'], $matches)){
546 $messages[$j]['SUBJECT-SORT'] = $matches[2];
547 }
548 }
549 return $messages;
550 }
551
552
553 /* Generic function to convert the msgs array into an HTML table. */
554 function displayMessageArray($imapConnection, $num_msgs, $start_msg,
555 $msort, $mailbox, $sort, $color,
556 $show_num, $where=0, $what=0) {
557 global $imapServerAddress, $use_mailbox_cache, $index_order,
558 $indent_array, $thread_sort_messages, $allow_server_sort,
559 $server_sort_order, $PHP_SELF;
560
561 $res = getEndMessage($start_msg, $show_num, $num_msgs);
562 $start_msg = $res[0];
563 $end_msg = $res[1];
564
565 $urlMailbox = urlencode($mailbox);
566
567 /* get indent level for subject display */
568 if ($thread_sort_messages == 1 && $num_msgs) {
569 $indent_array = get_parent_level($imapConnection);
570 }
571
572 $real_startMessage = $start_msg;
573 if ($sort == 6) {
574 if ($end_msg - $start_msg < $show_num - 1) {
575 $end_msg = $end_msg - $start_msg + 1;
576 $start_msg = 1;
577 } else if ($start_msg > $show_num) {
578 $end_msg = $show_num;
579 $start_msg = 1;
580 }
581 }
582 $endVar = $end_msg + 1;
583
584 /*
585 * Loop through and display the info for each message.
586 * ($t is used for the checkbox number)
587 */
588 $t = 0;
589
590 /* messages display */
591
592 if (!$num_msgs) {
593 /* if there's no messages in this folder */
594 echo html_tag( 'tr',
595 html_tag( 'td',
596 "<BR><b>" . _("THIS FOLDER IS EMPTY") . "</b><BR>&nbsp;",
597 'center',
598 $color[4],
599 'COLSPAN="' . count($index_order) . '"'
600 )
601 );
602 } elseif ($start_msg == $end_msg) {
603 /* if there's only one message in the box, handle it differently. */
604 if ($sort != 6) {
605 $i = $start_msg;
606 } else {
607 $i = 1;
608 }
609 reset($msort);
610 $k = 0;
611 do {
612 $key = key($msort);
613 next($msort);
614 $k++;
615 } while (isset ($key) && ($k < $i));
616 printMessageInfo($imapConnection, $t, true, $key, $mailbox,
617 $real_startMessage, $where, $what);
618 } else {
619 $i = $start_msg;
620 reset($msort);
621 $k = 0;
622 do {
623 $key = key($msort);
624 next($msort);
625 $k++;
626 } while (isset ($key) && ($k < $i));
627 $not_last = true;
628 do {
629 if (!$i || $i == $endVar-1) $not_last = false;
630 printMessageInfo($imapConnection, $t, $not_last, $key, $mailbox,
631 $real_startMessage, $where, $what);
632 $key = key($msort);
633 $t++;
634 $i++;
635 next($msort);
636 } while ($i && $i < $endVar);
637 }
638 }
639
640 /*
641 * Displays the standard message list header. To finish the table,
642 * you need to do a "</table></table>";
643 *
644 * $moveURL is the URL to submit the delete/move form to
645 * $mailbox is the current mailbox
646 * $sort is the current sorting method (-1 for no sorting available [searches])
647 * $Message is a message that is centered on top of the list
648 * $More is a second line that is left aligned
649 */
650
651 function mail_message_listing_beginning ($imapConnection,
652 $mailbox = '', $sort = -1,
653 $msg_cnt_str = '',
654 $paginator = '&nbsp;',
655 $start_msg = 1) {
656 global $color, $auto_expunge, $base_uri, $thread_sort_messages,
657 $allow_thread_sort, $allow_server_sort, $server_sort_order,
658 $PHP_SELF;
659
660 $php_self = $PHP_SELF;
661 /* fix for incorrect $PHP_SELF */
662 if (strpos($php_self, 'move_messages.php')) {
663 $php_self = str_replace('move_messages.php', 'right_main.php', $php_self);
664 }
665 $urlMailbox = urlencode($mailbox);
666
667 if (preg_match('/^(.+)\?.+$/',$php_self,$regs)) {
668 $source_url = $regs[1];
669 } else {
670 $source_url = $php_self;
671 }
672
673 if (!isset($msg)) {
674 $msg = '';
675 }
676 $moveURL = "move_messages.php?msg=$msg&amp;mailbox=$urlMailbox"
677 . "&amp;startMessage=$start_msg";
678 /*
679 * This is the beginning of the message list table.
680 * It wraps around all messages
681 */
682 echo "<FORM name=\"messageList\" method=post action=\"$moveURL\">\n"
683 . html_tag( 'table' ,
684 html_tag( 'tr',
685 html_tag( 'td' ,
686 html_tag( 'table' ,
687 html_tag( 'tr',
688 html_tag( 'td', $paginator, 'left' ) .
689 html_tag( 'td', $msg_cnt_str, 'right' )
690 )
691 , '', $color[4], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
692 , 'left', '', '' )
693 , '', $color[0] )
694 , '', '', 'border="0" width="100%" cellpadding="1" cellspacing="0"' );
695 /* line between header and button area */
696 echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'"></td></tr>';
697
698 echo '<tr><td>';
699 echo html_tag( 'tr' ) . "\n"
700 . html_tag( 'td' ,'' , 'left', '', '' )
701 . html_tag( 'table' ,'' , '', $color[9], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
702 . '<tr><td>'
703 . html_tag( 'table' ,'' , '', $color[0], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
704 . html_tag( 'tr',
705 getSmallStringCell(_("Move Selected To"), 'left', 'nowrap') .
706 getSmallStringCell(_("Transform Selected Messages"), 'right')
707 )
708 . html_tag( 'tr' ) ."\n"
709 . html_tag( 'td', '', 'left', '', 'valign="middle" nowrap' );
710 getMbxList($imapConnection);
711 echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n";
712 echo getButton('SUBMIT', 'attache',_("Forward")) . "\n";
713
714 echo " </TD>\n"
715 . html_tag( 'td', '', 'right', '', 'nowrap' );
716
717
718
719 if (!$auto_expunge) {
720 echo getButton('SUBMIT', 'expungeButton',_("Expunge"))
721 .'&nbsp;' . _("mailbox") . "\n";
722 }
723
724 echo getButton('SUBMIT', 'markRead',_("Read"));
725 echo getButton('SUBMIT', 'markUnread',_("Unread"));
726 echo getButton('SUBMIT', 'delete',_("Delete")) ."&nbsp\n";
727 if (!strpos($php_self,'mailbox')) {
728 $location = $php_self.'?mailbox=INBOX&amp;startMessage=1';
729 } else {
730 $location = $php_self;
731 }
732 echo '<INPUT TYPE="HIDDEN" NAME="location" VALUE="'.$location.'">';
733 echo "</TD>\n"
734 . " </TR>\n";
735
736 /* draws thread sorting links */
737 if ($allow_thread_sort == TRUE) {
738 if ($thread_sort_messages == 1 ) {
739 $set_thread = 2;
740 $thread_name = _("Unthread View");
741 } elseif ($thread_sort_messages == 0) {
742 $set_thread = 1;
743 $thread_name = _("Thread View");
744 }
745 echo html_tag( 'tr' ,
746 html_tag( 'td' ,
747 '&nbsp;<a href=' . $source_url . '?sort='
748 . "$sort" . '&start_messages=1&set_thread=' . "$set_thread"
749 . '&mailbox=' . urlencode($mailbox) . '><small>' . $thread_name
750 . '</a></small>&nbsp;'
751 , '', '', '' )
752 , '', '', '' );
753 }
754
755 echo "</TABLE></td></tr></table></td></tr>\n";
756
757 do_hook('mailbox_form_before');
758
759 /* if using server sort we highjack the
760 * the $sort var and use $server_sort_order
761 * instead. but here we reset sort for a bit
762 * since its easy
763 */
764 if ($allow_server_sort == TRUE) {
765 $sort = $server_sort_order;
766 }
767 }
768
769 function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color) {
770 if ($num_msgs) {
771 /* space between list and footer */
772 echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'" COLSPAN="1">';
773
774 echo '</td></tr><tr><td>';
775 echo html_tag( 'table',
776 html_tag( 'tr',
777 html_tag( 'td',
778 html_tag( 'table',
779 html_tag( 'tr',
780 html_tag( 'td', $paginator_str ) .
781 html_tag( 'td', $msg_cnt_str, 'right' )
782 )
783 , '', $color[4], 'width="100%" border="0" cellpadding="1" cellspacing="0"' )
784 )
785 )
786 , '', $color[9], 'width="100%" border="0" cellpadding="1" cellspacing="0"' );
787 echo '</td></tr>';
788 }
789 /* End of message-list table */
790
791 do_hook('mailbox_index_after');
792 echo "</FORM>\n";
793 }
794
795 function printHeader($mailbox, $sort, $color, $showsort=true) {
796 global $index_order;
797 echo html_tag( 'tr' ,'' , 'center', $color[5] );
798
799 /* calculate the width of the subject column based on the
800 * widths of the other columns */
801 $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
802 $subjectwidth = 100;
803 foreach($index_order as $item) {
804 $subjectwidth -= $widths[$item];
805 }
806
807 foreach ($index_order as $item) {
808 switch ($item) {
809 case 1: /* checkbox */
810 case 5: /* flags */
811 echo html_tag( 'td' ,'&nbsp;' , '', '', 'width="1%"' );
812 break;
813 case 2: /* from */
814 if (handleAsSent($mailbox)) {
815 echo html_tag( 'td' ,'' , 'left', '', 'width="25%"' )
816 . '<b>' . _("To") . '</b>';
817 } else {
818 echo html_tag( 'td' ,'' , 'left', '', 'width="25%"' )
819 . '<b>' . _("From") . '</b>';
820 }
821 if ($showsort) {
822 ShowSortButton($sort, $mailbox, 2, 3);
823 }
824 echo "</td>\n";
825 break;
826 case 3: /* date */
827 echo html_tag( 'td' ,'' , 'left', '', 'width="5%" nowrap' )
828 . '<b>' . _("Date") . '</b>';
829 if ($showsort) {
830 ShowSortButton($sort, $mailbox, 0, 1);
831 }
832 echo "</td>\n";
833 break;
834 case 4: /* subject */
835 echo html_tag( 'td' ,'' , 'left', '', 'width="'.$subjectwidth.'%"' )
836 . '<b>' . _("Subject") . '</b>';
837 if ($showsort) {
838 ShowSortButton($sort, $mailbox, 4, 5);
839 }
840 echo "</td>\n";
841 break;
842 case 6: /* size */
843 echo html_tag( 'td', '<b>' . _("Size") . '</b>', 'center', '', 'width="5%"' );
844 break;
845 }
846 }
847 echo "</tr>\n";
848 }
849
850
851 /*
852 * This function shows the sort button. Isn't this a good comment?
853 */
854 function ShowSortButton($sort, $mailbox, $Up, $Down ) {
855 global $PHP_SELF;
856 /* Figure out which image we want to use. */
857 if ($sort != $Up && $sort != $Down) {
858 $img = 'sort_none.png';
859 $which = $Up;
860 } elseif ($sort == $Up) {
861 $img = 'up_pointer.png';
862 $which = $Down;
863 } else {
864 $img = 'down_pointer.png';
865 $which = 6;
866 }
867
868 if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
869 $source_url = $regs[1];
870 } else {
871 $source_url = $PHP_SELF;
872 }
873
874 /* Now that we have everything figured out, show the actual button. */
875 echo ' <a href="' . $source_url .'?newsort=' . $which
876 . '&amp;startMessage=1&amp;mailbox=' . urlencode($mailbox)
877 . '"><IMG SRC="../images/' . $img
878 . '" BORDER=0 WIDTH=12 HEIGHT=10 ALT="sort"></a>';
879 }
880
881 function get_selectall_link($start_msg, $sort) {
882 global $checkall, $what, $where, $mailbox, $javascript_on;
883 global $PHP_SELF, $PG_SHOWNUM;
884
885 $result = '';
886 if ($javascript_on) {
887 $result = '<script language="JavaScript" type="text/javascript">'
888 . "\n<!-- \n"
889 . "function CheckAll() {\n"
890 . " for (var i = 0; i < document.messageList.elements.length; i++) {\n"
891 . " if(document.messageList.elements[i].type == 'checkbox'){\n"
892 . " document.messageList.elements[i].checked = "
893 . " !(document.messageList.elements[i].checked);\n"
894 . " }\n"
895 . " }\n"
896 . "}\n"
897 . "//-->\n"
898 . '</script><a href="#" onClick="CheckAll();">' . _("Toggle All")
899 . "</a>\n";
900 } else {
901 if (strpos($PHP_SELF, "?")) {
902 $result .= "<a href=\"$PHP_SELF&amp;mailbox=" . urlencode($mailbox)
903 . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
904 } else {
905 $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
906 . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
907 }
908 if (isset($checkall) && $checkall == '1') {
909 $result .= '0';
910 } else {
911 $result .= '1';
912 }
913
914 if (isset($where) && isset($what)) {
915 $result .= '&amp;where=' . urlencode($where)
916 . '&amp;what=' . urlencode($what);
917 }
918 $result .= "\">";
919
920 if (isset($checkall) && ($checkall == '1')) {
921 $result .= _("Unselect All");
922 } else {
923 $result .= _("Select All");
924 }
925 $result .= "</A>\n";
926 }
927
928 /* Return our final result. */
929 return ($result);
930 }
931
932 /*
933 * This function computes the "Viewing Messages..." string.
934 */
935 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
936 /* Compute the $msg_cnt_str. */
937 $result = '';
938 if ($start_msg < $end_msg) {
939 $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"),
940 $start_msg, $end_msg, $num_msgs);
941 } else if ($start_msg == $end_msg) {
942 $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
943 } else {
944 $result = '<br>';
945 }
946 /* Return our result string. */
947 return ($result);
948 }
949
950 /*
951 * Generate a paginator link.
952 */
953 function get_paginator_link($box, $start_msg, $use, $text) {
954 global $PHP_SELF;
955
956 $result = "<A HREF=\"right_main.php?use_mailbox_cache=$use"
957 . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
958 . "TARGET=\"right\">$text</A>";
959 return ($result);
960 /*
961 if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
962 $source_url = $regs[1];
963 } else {
964 $source_url = $PHP_SELF;
965 }
966
967 $result = '<A HREF="'. $source_url . "?use_mailbox_cache=$use"
968 . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
969 . "TARGET=\"right\">$text</A>";
970 return ($result);
971 */
972 }
973
974 /*
975 * This function computes the paginator string.
976 */
977 function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
978 $show_num, $sort) {
979 global $username, $data_dir, $use_mailbox_cache, $color, $PG_SHOWNUM;
980
981 /* Initialize paginator string chunks. */
982 $prv_str = '';
983 $nxt_str = '';
984 $pg_str = '';
985 $all_str = '';
986 $tgl_str = '';
987
988 $box = urlencode($box);
989
990 /* Create simple strings that will be creating the paginator. */
991 $spc = '&nbsp;'; /* This will be used as a space. */
992 $sep = '|'; /* This will be used as a seperator. */
993
994 /* Get some paginator preference values. */
995 $pg_sel = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
996 $pg_max = getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX);
997
998 /* Make sure that our start message number is not too big. */
999 $start_msg = min($start_msg, $num_msgs);
1000
1001 /* Decide whether or not we will use the mailbox cache. */
1002 /* Not sure why $use_mailbox_cache is even passed in. */
1003 if ($sort == 6) {
1004 $use = 0;
1005 } else {
1006 $use = 1;
1007 }
1008
1009 /* Compute the starting message of the previous and next page group. */
1010 $next_grp = $start_msg + $show_num;
1011 $prev_grp = $start_msg - $show_num;
1012
1013 /* Compute the basic previous and next strings. */
1014 if (($next_grp <= $num_msgs) && ($prev_grp >= 0)) {
1015 $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
1016 $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
1017 } else if (($next_grp > $num_msgs) && ($prev_grp >= 0)) {
1018 $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
1019 $nxt_str = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
1020 } else if (($next_grp <= $num_msgs) && ($prev_grp < 0)) {
1021 $prv_str = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
1022 $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
1023 }
1024
1025 /* Page selector block. Following code computes page links. */
1026 if ($pg_sel && ($num_msgs > $show_num)) {
1027 /* Most importantly, what is the current page!!! */
1028 $cur_pg = intval($start_msg / $show_num) + 1;
1029
1030 /* Compute total # of pages and # of paginator page links. */
1031 $tot_pgs = ceil($num_msgs / $show_num); /* Total number of Pages */
1032 $vis_pgs = min($pg_max, $tot_pgs - 1); /* Visible Pages */
1033
1034 /* Compute the size of the four quarters of the page links. */
1035
1036 /* If we can, just show all the pages. */
1037 if (($tot_pgs - 1) <= $pg_max) {
1038 $q1_pgs = $cur_pg - 1;
1039 $q2_pgs = $q3_pgs = 0;
1040 $q4_pgs = $tot_pgs - $cur_pg;
1041
1042 /* Otherwise, compute some magic to choose the four quarters. */
1043 } else {
1044 /*
1045 * Compute the magic base values. Added together,
1046 * these values will always equal to the $pag_pgs.
1047 * NOTE: These are DEFAULT values and do not take
1048 * the current page into account. That is below.
1049 */
1050 $q1_pgs = floor($vis_pgs/4);
1051 $q2_pgs = round($vis_pgs/4, 0);
1052 $q3_pgs = ceil($vis_pgs/4);
1053 $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0);
1054
1055 /* Adjust if the first quarter contains the current page. */
1056 if (($cur_pg - $q1_pgs) < 1) {
1057 $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs;
1058 $q1_pgs = $cur_pg - 1;
1059 $q2_pgs = 0;
1060 $q3_pgs += ceil($extra_pgs / 2);
1061 $q4_pgs += floor($extra_pgs / 2);
1062
1063 /* Adjust if the first and second quarters intersect. */
1064 } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
1065 $extra_pgs = $q2_pgs;
1066 $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 0.75);
1067 $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 0.75);
1068 $q3_pgs += ceil($extra_pgs / 2);
1069 $q4_pgs += floor($extra_pgs / 2);
1070
1071 /* Adjust if the fourth quarter contains the current page. */
1072 } else if (($cur_pg + $q4_pgs) >= $tot_pgs) {
1073 $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs;
1074 $q3_pgs = 0;
1075 $q4_pgs = $tot_pgs - $cur_pg;
1076 $q1_pgs += floor($extra_pgs / 2);
1077 $q2_pgs += ceil($extra_pgs / 2);
1078
1079 /* Adjust if the third and fourth quarter intersect. */
1080 } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
1081 $extra_pgs = $q3_pgs;
1082 $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
1083 $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
1084 $q1_pgs += floor($extra_pgs / 2);
1085 $q2_pgs += ceil($extra_pgs / 2);
1086 }
1087 }
1088
1089 /*
1090 * I am leaving this debug code here, commented out, because
1091 * it is a really nice way to see what the above code is doing.
1092 * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
1093 * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br>';
1094 */
1095
1096 /* Print out the page links from the compute page quarters. */
1097
1098 /* Start with the first quarter. */
1099 if (($q1_pgs == 0) && ($cur_pg > 1)) {
1100 $pg_str .= "...$spc";
1101 } else {
1102 for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
1103 $start = (($pg-1) * $show_num) + 1;
1104 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1105 }
1106 if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
1107 $pg_str .= "...$spc";
1108 }
1109 }
1110
1111 /* Continue with the second quarter. */
1112 for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
1113 $start = (($pg-1) * $show_num) + 1;
1114 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1115 }
1116
1117 /* Now print the current page. */
1118 $pg_str .= $cur_pg . $spc;
1119
1120 /* Next comes the third quarter. */
1121 for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
1122 $start = (($pg-1) * $show_num) + 1;
1123 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1124 }
1125
1126 /* And last, print the forth quarter page links. */
1127 if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
1128 $pg_str .= "...$spc";
1129 } else {
1130 if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
1131 $pg_str .= "...$spc";
1132 }
1133 for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
1134 $start = (($pg-1) * $show_num) + 1;
1135 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1136 }
1137 }
1138 } else if ($PG_SHOWNUM == 999999) {
1139 $pg_str = "<A HREF=\"right_main.php?PG_SHOWALL=0"
1140 . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
1141 . "TARGET=\"right\">" ._("Paginate") . '</A>' . $spc;
1142 }
1143
1144 /* If necessary, compute the 'show all' string. */
1145 if (($prv_str != '') || ($nxt_str != '')) {
1146 $all_str = "<A HREF=\"right_main.php?PG_SHOWALL=1"
1147 . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
1148 . "TARGET=\"right\">" . _("Show All") . '</A>';
1149 }
1150
1151 /* Last but not least, get the value for the toggle all link. */
1152 $tgl_str = get_selectall_link($start_msg, $sort);
1153
1154 /* Put all the pieces of the paginator string together. */
1155 /**
1156 * Hairy code... But let's leave it like it is since I am not certain
1157 * a different approach would be any easier to read. ;)
1158 */
1159 $result = '';
1160 $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
1161 $result .= ($nxt_str != '' ? $nxt_str . $spc . $sep . $spc : '');
1162 $result .= ($pg_str != '' ? $pg_str : '');
1163 $result .= ($all_str != '' ? $sep . $spc . $all_str . $spc : '');
1164 $result .= ($result != '' ? $sep . $spc . $tgl_str: $tgl_str);
1165
1166 /* If the resulting string is blank, return a non-breaking space. */
1167 if ($result == '') {
1168 $result = '&nbsp;';
1169 }
1170
1171 /* Return our final magical paginator string. */
1172 return ($result);
1173 }
1174
1175 function processSubject($subject, $threadlevel = 0) {
1176 global $languages, $squirrelmail_language;
1177 /* Shouldn't ever happen -- caught too many times in the IMAP functions */
1178 if ($subject == '')
1179 return _("(no subject)");
1180
1181 $trim_at = 55;
1182
1183 /* if this is threaded, substract two chars per indentlevel */
1184 if($threadlevel > 0 && $threadlevel <= 10)
1185 $trim_at -= (2*$threadlevel);
1186
1187 if (strlen($subject) <= $trim_at)
1188 return $subject;
1189
1190 $ent_strlen = strlen($subject);
1191 $trim_val = $trim_at - 5;
1192 $ent_offset = 0;
1193 /*
1194 * see if this is entities-encoded string
1195 * If so, Iterate through the whole string, find out
1196 * the real number of characters, and if more
1197 * than 55, substr with an updated trim value.
1198 */
1199 while ( (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
1200 (($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false) ) {
1201 $trim_val += ($ent_loc_end-$ent_loc)+1;
1202 $ent_strlen -= $ent_loc_end-$ent_loc;
1203 $ent_offset = $ent_loc_end+1;
1204 }
1205
1206 if ($ent_strlen <= $trim_at){
1207 return $subject;
1208 }
1209
1210 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
1211 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
1212 return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val);
1213 }
1214
1215 return substr($subject, 0, $trim_val) . '...';
1216 }
1217
1218 function getMbxList($imapConnection) {
1219 global $lastTargetMailbox;
1220 echo ' <small>&nbsp;<tt><select name="targetMailbox">';
1221 echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)) );
1222 echo ' </SELECT></TT>&nbsp;';
1223 }
1224
1225 function getButton($type, $name, $value) {
1226 return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '">';
1227 }
1228
1229 function getSmallStringCell($string, $align) {
1230 return html_tag('td',
1231 '<small>' . $string . ':&nbsp; </small>',
1232 $align,
1233 '',
1234 'nowrap' );
1235 }
1236
1237 function getEndMessage($start_msg, $show_num, $num_msgs) {
1238 if ($start_msg + ($show_num - 1) < $num_msgs){
1239 $end_msg = $start_msg + ($show_num - 1);
1240 } else {
1241 $end_msg = $num_msgs;
1242 }
1243
1244 if ($end_msg < $start_msg) {
1245 $start_msg = $start_msg - $show_num;
1246 if ($start_msg < 1) {
1247 $start_msg = 1;
1248 }
1249 }
1250 return (array($start_msg,$end_msg));
1251 }
1252
1253 function handleAsSent($mailbox) {
1254 global $sent_folder, $draft_folder, $handleAsSent_result;
1255
1256 /* First check if this is the sent or draft folder. */
1257 $handleAsSent_result = (($mailbox == $sent_folder)
1258 || ($mailbox == $draft_folder));
1259
1260 /* Then check the result of the handleAsSent hook. */
1261 do_hook('check_handleAsSent_result', $mailbox);
1262
1263 /* And return the result. */
1264 return ($handleAsSent_result);
1265 }
1266 ?>