Fix message highlighting for text with spaces in it.
[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
20 /* Default value for page_selector_max. */
21 define('PG_SEL_MAX', 10);
22
23 function elapsed($start)
24 {
25 $end = microtime();
26 list($start2, $start1) = explode(" ", $start);
27 list($end2, $end1) = explode(" ", $end);
28 $diff1 = $end1 - $start1;
29 $diff2 = $end2 - $start2;
30 if( $diff2 < 0 ){
31 $diff1 -= 1;
32 $diff2 += 1.0;
33 }
34 return $diff2 + $diff1;
35 }
36
37 function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
38 $start_msg, $where, $what) {
39 global $checkall,
40 $color, $msgs, $msort, $td_str, $msg,
41 $default_use_priority,
42 $message_highlight_list,
43 $index_order,
44 $indent_array, /* indent subject by */
45 $pos, /* Search postion (if any) */
46 $thread_sort_messages, /* thread sorting on/off */
47 $server_sort_order, /* sort value when using server-sorting */
48 $row_count,
49 $allow_server_sort; /* enable/disable server-side sorting */
50 $color_string = $color[4];
51
52 if ($GLOBALS['alt_index_colors']) {
53 if (!isset($row_count)) {
54 $row_count = 0;
55 }
56 $row_count++;
57 if ($row_count % 2) {
58 if (!isset($color[12])) {
59 $color[12] = '#EAEAEA';
60 }
61 $color_string = $color[12];
62 }
63 }
64 $msg = $msgs[$key];
65
66 if($mailbox == 'None') {
67 $boxes = sqimap_mailbox_list($imapConnection);
68 $mailbox = $boxes[0]['unformatted'];
69 unset($boxes);
70 }
71 $urlMailbox = urlencode($mailbox);
72
73 if (handleAsSent($mailbox)) {
74 $msg['FROM'] = $msg['TO'];
75 }
76 $msg['FROM'] = parseAddress($msg['FROM'],1);
77
78 /*
79 * This is done in case you're looking into Sent folders,
80 * because you can have multiple receivers.
81 */
82
83 $senderNames = $msg['FROM'];
84 $senderName = '';
85 if (sizeof($senderNames)){
86 foreach ($senderNames as $senderNames_part) {
87 if ($senderName != '') {
88 $senderName .= ', ';
89 }
90 if ($senderNames_part[1]) {
91 $senderName .= decodeHeader($senderNames_part[1]);
92 } else {
93 $senderName .= htmlspecialchars($senderNames_part[0]);
94 }
95 }
96 }
97 $senderName = str_replace('&nbsp;',' ',$senderName);
98 echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
99
100 if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
101 $flag = "<font color=\"$color[2]\">";
102 $flag_end = '</font>';
103 } else {
104 $flag = '';
105 $flag_end = '';
106 }
107 if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
108 $bold = '<b>';
109 $bold_end = '</b>';
110 } else {
111 $bold = '';
112 $bold_end = '';
113 }
114 if (handleAsSent($mailbox)) {
115 $italic = '<i>';
116 $italic_end = '</i>';
117 } else {
118 $italic = '';
119 $italic_end = '';
120 }
121 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
122 $fontstr = "<font color=\"$color[9]\">";
123 $fontstr_end = '</font>';
124 } else {
125 $fontstr = '';
126 $fontstr_end = '';
127 }
128
129 if ($where && $what) {
130 $searchstr = '&amp;where='.$where.'&amp;what='.$what;
131 } else {
132 $searchstr = '';
133 }
134
135 if (is_array($message_highlight_list) && count($message_highlight_list)) {
136 $msg['TO'] = parseAddress($msg['TO']);
137 $msg['CC'] = parseAddress($msg['CC']);
138 foreach ($message_highlight_list as $message_highlight_list_part) {
139 if (trim($message_highlight_list_part['value']) != '') {
140 $high_val = strtolower($message_highlight_list_part['value']);
141 $match_type = strtoupper($message_highlight_list_part['match_type']);
142 if($match_type == 'TO_CC') {
143 $match = array('TO', 'CC');
144 } else {
145 $match = array($match_type);
146 }
147 foreach($match as $match_type) {
148 switch($match_type) {
149 case('TO'):
150 case('CC'):
151 case('FROM'):
152 foreach ($msg[$match_type] as $address) {
153 $address[0] = decodeHeader($address[0], true, false);
154 $address[1] = decodeHeader($address[1], true, false);
155 if (strstr('^^' . strtolower($address[0]), $high_val) ||
156 strstr('^^' . strtolower($address[1]), $high_val)) {
157 $hlt_color = $message_highlight_list_part['color'];
158 break 4;
159 }
160 }
161 break;
162 default:
163 $headertest = strtolower(decodeHeader($msg[$match_type], true, false));
164 if (strstr('^^' . $headertest, $high_val)) {
165 $hlt_color = $message_highlight_list_part['color'];
166 break 3;
167 }
168 break;
169 }
170 }
171 }
172 }
173 }
174
175 if (!isset($hlt_color)) {
176 $hlt_color = $color_string;
177 }
178 $checked = ($checkall == 1) ? ' CHECKED' : '';
179 $col = 0;
180 $msg['SUBJECT'] = decodeHeader($msg['SUBJECT']);
181 $subject = processSubject($msg['SUBJECT'], $indent_array[$msg['ID']]);
182 $subject = str_replace('&nbsp;',' ',$subject);
183 if (sizeof($index_order)) {
184 foreach ($index_order as $index_order_part) {
185 switch ($index_order_part) {
186 case 1: /* checkbox */
187 echo html_tag( 'td',
188 "<input type=checkbox name=\"msg[$t]\" value=\"".$msg['ID']."\"$checked>",
189 'center',
190 $hlt_color );
191 break;
192 case 2: /* from */
193 echo html_tag( 'td',
194 $italic . $bold . $flag . $fontstr . $senderName .
195 $fontstr_end . $flag_end . $bold_end . $italic_end,
196 'left',
197 $hlt_color );
198 break;
199 case 3: /* date */
200 $date_string = $msg['DATE_STRING'] . '';
201 if ($date_string == '') {
202 $date_string = _("Unknown date");
203 }
204 echo html_tag( 'td',
205 $bold . $flag . $fontstr . $date_string .
206 $fontstr_end . $flag_end . $bold_end,
207 'center',
208 $hlt_color,
209 'nowrap' );
210 break;
211 case 4: /* subject */
212 $td_str = $bold;
213 if ($thread_sort_messages == 1) {
214 if (isset($indent_array[$msg['ID']])) {
215 $td_str .= str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$indent_array[$msg['ID']]);
216 }
217 }
218 $td_str .= '<a href="read_body.php?mailbox='.$urlMailbox
219 . '&amp;passed_id='. $msg["ID"]
220 . '&amp;startMessage='.$start_msg.$searchstr.'"';
221 $td_str .= ' ' .concat_hook_function('subject_link', array($start_msg, $searchstr));
222 if ($subject != $msg['SUBJECT']) {
223 $title = get_html_translation_table(HTML_SPECIALCHARS);
224 $title = array_flip($title);
225 $title = strtr($msg['SUBJECT'], $title);
226 $title = str_replace('"', "''", $title);
227 $td_str .= " title=\"$title\"";
228 }
229 $td_str .= ">$flag$subject$flag_end</a>$bold_end";
230 echo html_tag( 'td', $td_str, 'left', $hlt_color );
231 break;
232 case 5: /* flags */
233 $stuff = false;
234 $td_str = "<b><small>";
235
236 if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) {
237 $td_str .= _("A");
238 $stuff = true;
239 }
240 if ($msg['TYPE0'] == 'multipart') {
241 $td_str .= '+';
242 $stuff = true;
243 }
244 if ($default_use_priority) {
245 if ( ($msg['PRIORITY'] == 1) || ($msg['PRIORITY'] == 2) ) {
246 $td_str .= "<font color=\"$color[1]\">!</font>";
247 $stuff = true;
248 }
249 if ($msg['PRIORITY'] == 5) {
250 $td_str .= "<font color=\"$color[8]\">?</font>";
251 $stuff = true;
252 }
253 }
254 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) {
255 $td_str .= "<font color=\"$color[1]\">D</font>";
256 $stuff = true;
257 }
258 if (!$stuff) {
259 $td_str .= '&nbsp;';
260 }
261 do_hook("msg_envelope");
262 $td_str .= '</small></b>';
263 echo html_tag( 'td',
264 $td_str,
265 'center',
266 $hlt_color,
267 'nowrap' );
268 break;
269 case 6: /* size */
270 echo html_tag( 'td',
271 $bold . $fontstr . show_readable_size($msg['SIZE']) .
272 $fontstr_end . $bold_end,
273 'right',
274 $hlt_color );
275 break;
276 }
277 ++$col;
278 }
279 }
280 if ($not_last) {
281 echo '</tr>' . "\n" . '<tr><td COLSPAN="' . $col . '" BGCOLOR="' .
282 $color[0] . '" HEIGHT="1"></td></tr>' . "\n";
283 } else {
284 echo '</tr>'."\n";
285 }
286 }
287
288 function getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id) {
289 if ($id != 'no') {
290 $id = array_slice($id, ($start_msg-1), $show_num);
291 $end = $start_msg + $show_num - 1;
292 if ($num_msgs < $show_num) {
293 $end_loop = $num_msgs;
294 } else if ($end > $num_msgs) {
295 $end_loop = $num_msgs - $start_msg + 1;
296 } else {
297 $end_loop = $show_num;
298 }
299 return fillMessageArray($imapConnection,$id,$end_loop,$show_num);
300 } else {
301 return false;
302 }
303 }
304
305 function getThreadMessages($imapConnection, $start_msg, $show_num, $num_msgs) {
306 $id = get_thread_sort($imapConnection);
307 return getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
308 }
309
310 function getServerSortMessages($imapConnection, $start_msg, $show_num,
311 $num_msgs, $server_sort_order, $mbxresponse) {
312 $id = sqimap_get_sort_order($imapConnection, $server_sort_order,$mbxresponse);
313 return getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
314 }
315
316 function getSelfSortMessages($imapConnection, $start_msg, $show_num,
317 $num_msgs, $sort, $mbxresponse) {
318 $msgs = array();
319 if ($num_msgs >= 1) {
320 $id = sqimap_get_php_sort_order ($imapConnection, $mbxresponse);
321 if ($sort < 6 ) {
322 $end = $num_msgs;
323 $end_loop = $end;
324 /* set shownum to 999999 to fool sqimap_get_small_header_list
325 and rebuild the msgs_str to 1:* */
326 $show_num = 999999;
327 } else {
328 /* if it's not sorted */
329 if ($start_msg + ($show_num - 1) < $num_msgs) {
330 $end_msg = $start_msg + ($show_num - 1);
331 } else {
332 $end_msg = $num_msgs;
333 }
334 if ($end_msg < $start_msg) {
335 $start_msg = $start_msg - $show_num;
336 if ($start_msg < 1) {
337 $start_msg = 1;
338 }
339 }
340 $id = array_slice(array_reverse($id), ($start_msg-1), $show_num);
341 $end = $start_msg + $show_num - 1;
342 if ($num_msgs < $show_num) {
343 $end_loop = $num_msgs;
344 } else if ($end > $num_msgs) {
345 $end_loop = $num_msgs - $start_msg + 1;
346 } else {
347 $end_loop = $show_num;
348 }
349 }
350 $msgs = fillMessageArray($imapConnection,$id,$end_loop, $show_num);
351 }
352 return $msgs;
353 }
354
355
356
357 /*
358 * This function loops through a group of messages in the mailbox
359 * and shows them to the user.
360 */
361 function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
362 $start_msg, $sort, $color, $show_num,
363 $use_cache, $mode='') {
364 global $msgs, $msort, $auto_expunge, $thread_sort_messages,
365 $allow_server_sort, $server_sort_order;
366
367 /*
368 * For some reason, on PHP 4.3+, this being unset, and set in the session causes havoc
369 * so setting it to an empty array beforehand seems to clean up the issue, and stopping the
370 * "Your script possibly relies on a session side-effect which existed until PHP 4.2.3" error
371 */
372
373 if (!isset($msort)) {
374 $msort = array();
375 }
376
377 if (!isset($msgs)) {
378 $msgs = array();
379 }
380
381 //$start = microtime();
382 /* If autoexpunge is turned on, then do it now. */
383 $mbxresponse = sqimap_mailbox_select($imapConnection, $mailbox);
384 $srt = $sort;
385 /* If autoexpunge is turned on, then do it now. */
386 if ($auto_expunge == true) {
387 $exp_cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, false, '');
388 $mbxresponse['EXISTS'] = $mbxresponse['EXISTS'] - $exp_cnt;
389 $num_msgs = $mbxresponse['EXISTS'];
390 }
391
392 if ($mbxresponse['EXISTS'] > 0) {
393 /* if $start_msg is lower than $num_msgs, we probably deleted all messages
394 * in the last page. We need to re-adjust the start_msg
395 */
396
397 if($start_msg > $num_msgs) {
398 $start_msg -= $show_num;
399 if($start_msg < 1) {
400 $start_msg = 1;
401 }
402 }
403
404 /* This code and the next if() block check for
405 * server-side sorting methods. The $id array is
406 * formatted and $sort is set to 6 to disable
407 * SM internal sorting
408 */
409
410 if ($thread_sort_messages == 1) {
411 $mode = 'thread';
412 } elseif ($allow_server_sort == 1) {
413 $mode = 'serversort';
414 } else {
415 $mode = '';
416 }
417
418 if ($use_cache) {
419 sqgetGlobalVar('msgs', $msgs, SQ_SESSION);
420 sqgetGlobalVar('msort', $msort, SQ_SESSION);
421 } else {
422 sqsession_unregister('msort');
423 sqsession_unregister('msgs');
424 }
425 switch ($mode) {
426 case 'thread':
427 $id = get_thread_sort($imapConnection);
428 $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
429 if ($msgs === false) {
430 echo '<b><small><center><font color=red>' .
431 _("Thread sorting is not supported by your IMAP server.<br>Please report this to the system administrator.").
432 '</center></small></b>';
433 $thread_sort_messages = 0;
434 $msort = $msgs = array();
435 } else {
436 $msort= $msgs;
437 $sort = 6;
438 }
439 break;
440 case 'serversort':
441 $id = sqimap_get_sort_order($imapConnection, $sort, $mbxresponse);
442 $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
443 if ($msgs === false) {
444 echo '<b><small><center><font color=red>' .
445 _( "Server-side sorting is not supported by your IMAP server.<br>Please report this to the system administrator.").
446 '</center></small></b>';
447 $sort = $server_sort_order;
448 $allow_server_sort = FALSE;
449 $msort = $msgs = array();
450 $id = array();
451 } else {
452 $msort = $msgs;
453 $sort = 6;
454 }
455 break;
456 default:
457 if (!$use_cache) {
458 $msgs = getSelfSortMessages($imapConnection, $start_msg, $show_num,
459 $num_msgs, $sort, $mbxresponse);
460 $msort = calc_msort($msgs, $sort);
461 } /* !use cache */
462 break;
463 } // switch
464 sqsession_register($msort, 'msort');
465 sqsession_register($msgs, 'msgs');
466
467 } /* if exists > 0 */
468
469 $res = getEndMessage($start_msg, $show_num, $num_msgs);
470 $start_msg = $res[0];
471 $end_msg = $res[1];
472
473 $paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg,
474 $num_msgs, $show_num, $sort);
475
476 $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
477
478 do_hook('mailbox_index_before');
479 echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
480 echo '<tr><td>';
481
482 mail_message_listing_beginning($imapConnection, $mailbox, $sort,
483 $msg_cnt_str, $paginator_str, $start_msg);
484 echo '</td></tr>';
485 /* line between the button area and the list */
486 echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'"></td></tr>';
487
488 echo '<tr><td>';
489 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
490 echo ' <tr><td>';
491 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[5].'">';
492 echo '<tr><td>';
493 printHeader($mailbox, $srt, $color, !$thread_sort_messages);
494
495 displayMessageArray($imapConnection, $num_msgs, $start_msg,
496 $msort, $mailbox, $sort, $color, $show_num,0,0);
497 echo '</td></tr></table></td></tr></table>';
498
499 mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color);
500 echo '</td></tr></table>';
501 //$t = elapsed($start);
502 //echo("elapsed time = $t seconds\n");
503 }
504
505 function calc_msort($msgs, $sort) {
506
507 /*
508 * 0 = Date (up)
509 * 1 = Date (dn)
510 * 2 = Name (up)
511 * 3 = Name (dn)
512 * 4 = Subject (up)
513 * 5 = Subject (dn)
514 */
515
516 if (($sort == 0) || ($sort == 1)) {
517 foreach ($msgs as $item) {
518 $msort[] = $item['TIME_STAMP'];
519 }
520 } elseif (($sort == 2) || ($sort == 3)) {
521 foreach ($msgs as $item) {
522 $msort[] = $item['FROM-SORT'];
523 }
524 } elseif (($sort == 4) || ($sort == 5)) {
525 foreach ($msgs as $item) {
526 $msort[] = $item['SUBJECT-SORT'];
527 }
528 } else {
529 $msort = $msgs;
530 }
531 if ($sort < 6) {
532 if ($sort % 2) {
533 asort($msort);
534 } else {
535 arsort($msort);
536 }
537 }
538 return $msort;
539 }
540
541 function fillMessageArray($imapConnection, $id, $count, $show_num=false) {
542 return sqimap_get_small_header_list($imapConnection, $id, $show_num);
543 }
544
545
546 /* Generic function to convert the msgs array into an HTML table. */
547 function displayMessageArray($imapConnection, $num_msgs, $start_msg,
548 $msort, $mailbox, $sort, $color,
549 $show_num, $where=0, $what=0) {
550 global $imapServerAddress, $use_mailbox_cache, $index_order,
551 $indent_array, $thread_sort_messages, $allow_server_sort,
552 $server_sort_order, $PHP_SELF;
553
554 $res = getEndMessage($start_msg, $show_num, $num_msgs);
555 $start_msg = $res[0];
556 $end_msg = $res[1];
557
558 $urlMailbox = urlencode($mailbox);
559
560 /* get indent level for subject display */
561 if ($thread_sort_messages == 1 && $num_msgs) {
562 $indent_array = get_parent_level($imapConnection);
563 }
564
565 $real_startMessage = $start_msg;
566 if ($sort == 6) {
567 if ($end_msg - $start_msg < $show_num - 1) {
568 $end_msg = $end_msg - $start_msg + 1;
569 $start_msg = 1;
570 } else if ($start_msg > $show_num) {
571 $end_msg = $show_num;
572 $start_msg = 1;
573 }
574 }
575 $endVar = $end_msg + 1;
576
577 /*
578 * Loop through and display the info for each message.
579 * ($t is used for the checkbox number)
580 */
581 $t = 0;
582
583 /* messages display */
584
585 if (!$num_msgs) {
586 /* if there's no messages in this folder */
587 echo html_tag( 'tr',
588 html_tag( 'td',
589 "<BR><b>" . _("THIS FOLDER IS EMPTY") . "</b><BR>&nbsp;",
590 'center',
591 $color[4],
592 'COLSPAN="' . count($index_order) . '"'
593 )
594 );
595 } elseif ($start_msg == $end_msg) {
596 /* if there's only one message in the box, handle it differently. */
597 if ($sort != 6) {
598 $i = $start_msg;
599 } else {
600 $i = 1;
601 }
602 reset($msort);
603 $k = 0;
604 do {
605 $key = key($msort);
606 next($msort);
607 $k++;
608 } while (isset ($key) && ($k < $i));
609 printMessageInfo($imapConnection, $t, true, $key, $mailbox,
610 $real_startMessage, $where, $what);
611 } else {
612 $i = $start_msg;
613 reset($msort);
614 $k = 0;
615 do {
616 $key = key($msort);
617 next($msort);
618 $k++;
619 } while (isset ($key) && ($k < $i));
620 $not_last = true;
621 do {
622 if (!$i || $i == $endVar-1) $not_last = false;
623 printMessageInfo($imapConnection, $t, $not_last, $key, $mailbox,
624 $real_startMessage, $where, $what);
625 $key = key($msort);
626 $t++;
627 $i++;
628 next($msort);
629 } while ($i && $i < $endVar);
630 }
631 }
632
633 /*
634 * Displays the standard message list header. To finish the table,
635 * you need to do a "</table></table>";
636 *
637 * $moveURL is the URL to submit the delete/move form to
638 * $mailbox is the current mailbox
639 * $sort is the current sorting method (-1 for no sorting available [searches])
640 * $Message is a message that is centered on top of the list
641 * $More is a second line that is left aligned
642 */
643
644 function mail_message_listing_beginning ($imapConnection,
645 $mailbox = '', $sort = -1,
646 $msg_cnt_str = '',
647 $paginator = '&nbsp;',
648 $start_msg = 1) {
649 global $color, $auto_expunge, $base_uri, $thread_sort_messages,
650 $allow_thread_sort, $allow_server_sort, $server_sort_order,
651 $PHP_SELF;
652
653 $php_self = $PHP_SELF;
654 /* fix for incorrect $PHP_SELF */
655 if (strpos($php_self, 'move_messages.php')) {
656 $php_self = str_replace('move_messages.php', 'right_main.php', $php_self);
657 }
658 $urlMailbox = urlencode($mailbox);
659
660 if (preg_match('/^(.+)\?.+$/',$php_self,$regs)) {
661 $source_url = $regs[1];
662 } else {
663 $source_url = $php_self;
664 }
665
666 if (!isset($msg)) {
667 $msg = '';
668 }
669 $moveFields = '<input type="hidden" name="msg" value="'.htmlspecialchars($msg).'">' .
670 '<input type="hidden" name="mailbox" value="'.htmlspecialchars($mailbox).'">' .
671 '<input type="hidden" name="startMessage" value="'.htmlspecialchars($start_msg).'">';
672
673 // $moveURL = "move_messages.php?msg=$msg&amp;mailbox=$urlMailbox"
674 // . "&amp;startMessage=$start_msg";
675 /*
676 * This is the beginning of the message list table.
677 * It wraps around all messages
678 */
679 $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox);
680 $form_name = "FormMsgs" . $safe_name;
681 echo '<form name="' . $form_name . '" method="post" action="move_messages.php">' ."\n"
682 . $moveFields
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%" nowrap' );
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 $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox);
888 $func_name = "CheckAll" . $safe_name;
889 $form_name = "FormMsgs" . $safe_name;
890 $result = '<script language="JavaScript" type="text/javascript">'
891 . "\n<!-- \n"
892 . "function " . $func_name . "() {\n"
893 . " for (var i = 0; i < document." . $form_name . ".elements.length; i++) {\n"
894 . " if(document." . $form_name . ".elements[i].type == 'checkbox'){\n"
895 . " document." . $form_name . ".elements[i].checked = "
896 . " !(document." . $form_name . ".elements[i].checked);\n"
897 . " }\n"
898 . " }\n"
899 . "}\n"
900 . "//-->\n"
901 . '</script><a href="javascript:void(0)" onClick="' . $func_name . '();">' . _("Toggle All")
902 /* . '</script><a href="javascript:' . $func_name . '()">' . _("Toggle All")*/
903 . "</a>\n";
904 } else {
905 if (strpos($PHP_SELF, "?")) {
906 $result .= "<a href=\"$PHP_SELF&amp;mailbox=" . urlencode($mailbox)
907 . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
908 } else {
909 $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
910 . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
911 }
912 if (isset($checkall) && $checkall == '1') {
913 $result .= '0';
914 } else {
915 $result .= '1';
916 }
917
918 if (isset($where) && isset($what)) {
919 $result .= '&amp;where=' . urlencode($where)
920 . '&amp;what=' . urlencode($what);
921 }
922 $result .= "\">";
923
924 if (isset($checkall) && ($checkall == '1')) {
925 $result .= _("Unselect All");
926 } else {
927 $result .= _("Select All");
928 }
929 $result .= "</A>\n";
930 }
931
932 /* Return our final result. */
933 return ($result);
934 }
935
936 /*
937 * This function computes the "Viewing Messages..." string.
938 */
939 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
940 /* Compute the $msg_cnt_str. */
941 $result = '';
942 if ($start_msg < $end_msg) {
943 $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"),
944 $start_msg, $end_msg, $num_msgs);
945 } else if ($start_msg == $end_msg) {
946 $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
947 } else {
948 $result = '<br>';
949 }
950 /* Return our result string. */
951 return ($result);
952 }
953
954 /*
955 * Generate a paginator link.
956 */
957 function get_paginator_link($box, $start_msg, $use, $text) {
958 global $PHP_SELF;
959
960 $result = "<A HREF=\"right_main.php?use_mailbox_cache=$use"
961 . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
962 . "TARGET=\"right\">$text</A>";
963 return ($result);
964 /*
965 if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
966 $source_url = $regs[1];
967 } else {
968 $source_url = $PHP_SELF;
969 }
970
971 $result = '<A HREF="'. $source_url . "?use_mailbox_cache=$use"
972 . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
973 . "TARGET=\"right\">$text</A>";
974 return ($result);
975 */
976 }
977
978 /*
979 * This function computes the paginator string.
980 */
981 function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
982 $show_num, $sort) {
983 global $username, $data_dir, $use_mailbox_cache, $color, $PG_SHOWNUM;
984
985 /* Initialize paginator string chunks. */
986 $prv_str = '';
987 $nxt_str = '';
988 $pg_str = '';
989 $all_str = '';
990 $tgl_str = '';
991
992 $box = urlencode($box);
993
994 /* Create simple strings that will be creating the paginator. */
995 $spc = '&nbsp;'; /* This will be used as a space. */
996 $sep = '|'; /* This will be used as a seperator. */
997
998 /* Get some paginator preference values. */
999 $pg_sel = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
1000 $pg_max = getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX);
1001
1002 /* Make sure that our start message number is not too big. */
1003 $start_msg = min($start_msg, $num_msgs);
1004
1005 /* Decide whether or not we will use the mailbox cache. */
1006 /* Not sure why $use_mailbox_cache is even passed in. */
1007 if ($sort == 6) {
1008 $use = 0;
1009 } else {
1010 $use = 1;
1011 }
1012
1013 /* Compute the starting message of the previous and next page group. */
1014 $next_grp = $start_msg + $show_num;
1015 $prev_grp = $start_msg - $show_num;
1016
1017 /* Compute the basic previous and next strings. */
1018 if (($next_grp <= $num_msgs) && ($prev_grp >= 0)) {
1019 $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
1020 $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
1021 } else if (($next_grp > $num_msgs) && ($prev_grp >= 0)) {
1022 $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
1023 $nxt_str = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
1024 } else if (($next_grp <= $num_msgs) && ($prev_grp < 0)) {
1025 $prv_str = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
1026 $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
1027 }
1028
1029 /* Page selector block. Following code computes page links. */
1030 if ($pg_sel && ($num_msgs > $show_num)) {
1031 /* Most importantly, what is the current page!!! */
1032 $cur_pg = intval($start_msg / $show_num) + 1;
1033
1034 /* Compute total # of pages and # of paginator page links. */
1035 $tot_pgs = ceil($num_msgs / $show_num); /* Total number of Pages */
1036 $vis_pgs = min($pg_max, $tot_pgs - 1); /* Visible Pages */
1037
1038 /* Compute the size of the four quarters of the page links. */
1039
1040 /* If we can, just show all the pages. */
1041 if (($tot_pgs - 1) <= $pg_max) {
1042 $q1_pgs = $cur_pg - 1;
1043 $q2_pgs = $q3_pgs = 0;
1044 $q4_pgs = $tot_pgs - $cur_pg;
1045
1046 /* Otherwise, compute some magic to choose the four quarters. */
1047 } else {
1048 /*
1049 * Compute the magic base values. Added together,
1050 * these values will always equal to the $pag_pgs.
1051 * NOTE: These are DEFAULT values and do not take
1052 * the current page into account. That is below.
1053 */
1054 $q1_pgs = floor($vis_pgs/4);
1055 $q2_pgs = round($vis_pgs/4, 0);
1056 $q3_pgs = ceil($vis_pgs/4);
1057 $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0);
1058
1059 /* Adjust if the first quarter contains the current page. */
1060 if (($cur_pg - $q1_pgs) < 1) {
1061 $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs;
1062 $q1_pgs = $cur_pg - 1;
1063 $q2_pgs = 0;
1064 $q3_pgs += ceil($extra_pgs / 2);
1065 $q4_pgs += floor($extra_pgs / 2);
1066
1067 /* Adjust if the first and second quarters intersect. */
1068 } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
1069 $extra_pgs = $q2_pgs;
1070 $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 0.75);
1071 $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 0.75);
1072 $q3_pgs += ceil($extra_pgs / 2);
1073 $q4_pgs += floor($extra_pgs / 2);
1074
1075 /* Adjust if the fourth quarter contains the current page. */
1076 } else if (($cur_pg + $q4_pgs) >= $tot_pgs) {
1077 $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs;
1078 $q3_pgs = 0;
1079 $q4_pgs = $tot_pgs - $cur_pg;
1080 $q1_pgs += floor($extra_pgs / 2);
1081 $q2_pgs += ceil($extra_pgs / 2);
1082
1083 /* Adjust if the third and fourth quarter intersect. */
1084 } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
1085 $extra_pgs = $q3_pgs;
1086 $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
1087 $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
1088 $q1_pgs += floor($extra_pgs / 2);
1089 $q2_pgs += ceil($extra_pgs / 2);
1090 }
1091 }
1092
1093 /*
1094 * I am leaving this debug code here, commented out, because
1095 * it is a really nice way to see what the above code is doing.
1096 * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
1097 * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br>';
1098 */
1099
1100 /* Print out the page links from the compute page quarters. */
1101
1102 /* Start with the first quarter. */
1103 if (($q1_pgs == 0) && ($cur_pg > 1)) {
1104 $pg_str .= "...$spc";
1105 } else {
1106 for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
1107 $start = (($pg-1) * $show_num) + 1;
1108 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1109 }
1110 if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
1111 $pg_str .= "...$spc";
1112 }
1113 }
1114
1115 /* Continue with the second quarter. */
1116 for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
1117 $start = (($pg-1) * $show_num) + 1;
1118 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1119 }
1120
1121 /* Now print the current page. */
1122 $pg_str .= $cur_pg . $spc;
1123
1124 /* Next comes the third quarter. */
1125 for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
1126 $start = (($pg-1) * $show_num) + 1;
1127 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1128 }
1129
1130 /* And last, print the forth quarter page links. */
1131 if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
1132 $pg_str .= "...$spc";
1133 } else {
1134 if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
1135 $pg_str .= "...$spc";
1136 }
1137 for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
1138 $start = (($pg-1) * $show_num) + 1;
1139 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1140 }
1141 }
1142 } else if ($PG_SHOWNUM == 999999) {
1143 $pg_str = "<A HREF=\"right_main.php?PG_SHOWALL=0"
1144 . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
1145 . "TARGET=\"right\">" ._("Paginate") . '</A>' . $spc;
1146 }
1147
1148 /* If necessary, compute the 'show all' string. */
1149 if (($prv_str != '') || ($nxt_str != '')) {
1150 $all_str = "<A HREF=\"right_main.php?PG_SHOWALL=1"
1151 . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
1152 . "TARGET=\"right\">" . _("Show All") . '</A>';
1153 }
1154
1155 /* Last but not least, get the value for the toggle all link. */
1156 $tgl_str = get_selectall_link($start_msg, $sort);
1157
1158 /* Put all the pieces of the paginator string together. */
1159 /**
1160 * Hairy code... But let's leave it like it is since I am not certain
1161 * a different approach would be any easier to read. ;)
1162 */
1163 $result = '';
1164 $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
1165 $result .= ($nxt_str != '' ? $nxt_str . $spc . $sep . $spc : '');
1166 $result .= ($pg_str != '' ? $pg_str : '');
1167 $result .= ($all_str != '' ? $sep . $spc . $all_str . $spc : '');
1168 $result .= ($result != '' ? $sep . $spc . $tgl_str: $tgl_str);
1169
1170 /* If the resulting string is blank, return a non-breaking space. */
1171 if ($result == '') {
1172 $result = '&nbsp;';
1173 }
1174
1175 /* Return our final magical paginator string. */
1176 return ($result);
1177 }
1178
1179 function processSubject($subject, $threadlevel = 0) {
1180 global $languages, $squirrelmail_language;
1181 /* Shouldn't ever happen -- caught too many times in the IMAP functions */
1182 if ($subject == '')
1183 return _("(no subject)");
1184
1185 $trim_at = 55;
1186
1187 /* if this is threaded, subtract two chars per indentlevel */
1188 if($threadlevel > 0 && $threadlevel <= 10)
1189 $trim_at -= (2*$threadlevel);
1190
1191 if (strlen($subject) <= $trim_at)
1192 return $subject;
1193
1194 $ent_strlen = $orig_len = strlen($subject);
1195 $trim_val = $trim_at - 5;
1196 $ent_offset = 0;
1197 /*
1198 * see if this is entities-encoded string
1199 * If so, Iterate through the whole string, find out
1200 * the real number of characters, and if more
1201 * than 55, substr with an updated trim value.
1202 */
1203 $step = $ent_loc = 0;
1204 while ( $ent_loc < $trim_val && (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
1205 (($ent_loc_end = strpos($subject, ';', $ent_loc+3)) !== false) ) {
1206 $trim_val += ($ent_loc_end-$ent_loc);
1207 $ent_offset = $ent_loc_end+1;
1208 ++$step;
1209 }
1210
1211 if (($trim_val > 50) && (strlen($subject) > ($trim_val))&& (strpos($subject,';',$trim_val) < ($trim_val +6))) {
1212 $i = strpos($subject,';',$trim_val);
1213 if ($i) {
1214 $trim_val = strpos($subject,';',$trim_val);
1215 }
1216 }
1217 if ($ent_strlen <= $trim_at){
1218 return $subject;
1219 }
1220
1221 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
1222 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
1223 return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val);
1224 }
1225 return substr($subject, 0, $trim_val) . '...';
1226 }
1227
1228 function getMbxList($imapConnection) {
1229 global $lastTargetMailbox;
1230 echo ' <small>&nbsp;<tt><select name="targetMailbox">';
1231 echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)) );
1232 echo ' </SELECT></TT>&nbsp;';
1233 }
1234
1235 function getButton($type, $name, $value) {
1236 return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '">';
1237 }
1238
1239 function getSmallStringCell($string, $align) {
1240 return html_tag('td',
1241 '<small>' . $string . ':&nbsp; </small>',
1242 $align,
1243 '',
1244 'nowrap' );
1245 }
1246
1247 function getEndMessage($start_msg, $show_num, $num_msgs) {
1248 if ($start_msg + ($show_num - 1) < $num_msgs){
1249 $end_msg = $start_msg + ($show_num - 1);
1250 } else {
1251 $end_msg = $num_msgs;
1252 }
1253
1254 if ($end_msg < $start_msg) {
1255 $start_msg = $start_msg - $show_num;
1256 if ($start_msg < 1) {
1257 $start_msg = 1;
1258 }
1259 }
1260 return (array($start_msg,$end_msg));
1261 }
1262
1263 function handleAsSent($mailbox) {
1264 global $handleAsSent_result;
1265
1266 /* First check if this is the sent or draft folder. */
1267 $handleAsSent_result = isSentMailbox($mailbox) || isDraftMailbox($mailbox);
1268
1269 /* Then check the result of the handleAsSent hook. */
1270 do_hook('check_handleAsSent_result', $mailbox);
1271
1272 /* And return the result. */
1273 return $handleAsSent_result;
1274 }
1275
1276 ?>