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