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