617754b980320cedecc63ae3e1f66ffd242ddc42
[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[0].'" HEIGHT="1"></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 echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
455 echo '<tr><td>';
456
457 mail_message_listing_beginning($imapConnection, $mailbox, $sort,
458 $msg_cnt_str, $paginator_str, $start_msg);
459 echo '</td></tr>';
460 echo '<tr><td HEIGHT="3" BGCOLOR="'.$color[4].'"></td></tr>';
461 echo '<tr><td>';
462 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
463 echo ' <tr><td>';
464 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
465 echo '<tr><td>';
466 printHeader($mailbox, $srt, $color, !$thread_sort_messages);
467
468 displayMessageArray($imapConnection, $num_msgs, $start_msg,
469 $msort, $mailbox, $sort, $color, $show_num,0,0);
470 echo '</td></tr></table></td></tr></table>';
471
472 mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color);
473 echo '</td></tr></table>';
474 }
475
476 function calc_msort($msgs, $sort) {
477
478 /*
479 * 0 = Date (up)
480 * 1 = Date (dn)
481 * 2 = Name (up)
482 * 3 = Name (dn)
483 * 4 = Subject (up)
484 * 5 = Subject (dn)
485 */
486 if (($sort == 0) || ($sort == 1)) {
487 $msort = array_cleave ($msgs, 'TIME_STAMP');
488 } elseif (($sort == 2) || ($sort == 3)) {
489 $msort = array_cleave ($msgs, 'FROM-SORT');
490 } elseif (($sort == 4) || ($sort == 5)) {
491 $msort = array_cleave ($msgs, 'SUBJECT-SORT');
492 } else {
493 $msort = $msgs;
494 }
495 if ($sort < 6) {
496 if ($sort % 2) {
497 asort($msort);
498 } else {
499 arsort($msort);
500 }
501 }
502 return $msort;
503 }
504
505 function fillMessageArray($imapConnection,$id,$count) {
506 $msgs_list = sqimap_get_small_header_list($imapConnection, $id);
507 $messages = array();
508 if (sizeof($msgs_list)){
509 foreach ($msgs_list as $hdr) {
510 $unique_id[] = $hdr->uid;
511 $from[] = $hdr->from;
512 $date[] = $hdr->date;
513 $subject[] = $hdr->subject;
514 $to[] = $hdr->to;
515 $priority[] = $hdr->priority;
516 $cc[] = $hdr->cc;
517 $size[] = $hdr->size;
518 $type[] = $hdr->type0;
519 $flag_deleted[] = $hdr->flag_deleted;
520 $flag_answered[] = $hdr->flag_answered;
521 $flag_seen[] = $hdr->flag_seen;
522 $flag_flagged[] = $hdr->flag_flagged;
523 }
524 }
525
526 $j = 0;
527 while ($j < $count) {
528
529 if (isset($date[$j])) {
530 $date[$j] = str_replace(' ', ' ', $date[$j]);
531 $tmpdate = explode(' ', trim($date[$j]));
532 } else {
533 $tmpdate = $date = array('', '', '', '', '', '');
534 }
535 $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
536 $messages[$j]['DATE_STRING'] =
537 getDateString($messages[$j]['TIME_STAMP']);
538 $messages[$j]['ID'] = $unique_id[$j];
539 $messages[$j]['FROM'] = decodeHeader($from[$j]);
540 $messages[$j]['FROM-SORT'] =
541 strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
542 $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
543 $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
544 $messages[$j]['TO'] = decodeHeader($to[$j]);
545 $messages[$j]['PRIORITY'] = $priority[$j];
546 $messages[$j]['CC'] = $cc[$j];
547 $messages[$j]['SIZE'] = $size[$j];
548 $messages[$j]['TYPE0'] = $type[$j];
549 $messages[$j]['FLAG_DELETED'] = $flag_deleted[$j];
550 $messages[$j]['FLAG_ANSWERED'] = $flag_answered[$j];
551 $messages[$j]['FLAG_SEEN'] = $flag_seen[$j];
552 $messages[$j]['FLAG_FLAGGED'] = $flag_flagged[$j];
553
554
555 /*
556 * fix SUBJECT-SORT to remove Re:
557 * vedr|sv (Danish)
558 * re|aw (English)
559 *
560 * TODO: i18n should be incorporated here. E.g. we catch the ones
561 * we know about, but also define in i18n what the localized
562 * "Re: " is for this or that locale.
563 */
564 if (preg_match("/^(vedr|sv|re|aw):\s*(.*)$/si",
565 $messages[$j]['SUBJECT-SORT'], $matches)){
566 $messages[$j]['SUBJECT-SORT'] = $matches[2];
567 }
568 $j++;
569 }
570 return $messages;
571 }
572
573
574 /* Generic function to convert the msgs array into an HTML table. */
575 function displayMessageArray($imapConnection, $num_msgs, $start_msg,
576 $msort, $mailbox, $sort, $color,
577 $show_num, $where=0, $what=0) {
578 global $imapServerAddress, $use_mailbox_cache,
579 $index_order, $checkall,
580 $indent_array, $thread_sort_messages, $allow_server_sort,
581 $server_sort_order, $PHP_SELF;
582
583 $res = getEndMessage($start_msg, $show_num, $num_msgs);
584 $start_msg = $res[0];
585 $end_msg = $res[1];
586
587 $urlMailbox = urlencode($mailbox);
588
589 /* get indent level for subject display */
590 if ($thread_sort_messages == 1 ) {
591 $indent_array = get_parent_level($imapConnection);
592 }
593
594
595 $real_startMessage = $start_msg;
596 if ($sort == 6) {
597 if ($end_msg - $start_msg < $show_num - 1) {
598 $end_msg = $end_msg - $start_msg + 1;
599 $start_msg = 1;
600 } else if ($start_msg > $show_num) {
601 $end_msg = $show_num;
602 $start_msg = 1;
603 }
604 }
605 $endVar = $end_msg + 1;
606
607 /*
608 * Loop through and display the info for each message.
609 * ($t is used for the checkbox number)
610 */
611 $t = 0;
612
613 /* messages display */
614
615 if ($num_msgs == 0) {
616 /* if there's no messages in this folder */
617 echo html_tag( 'tr',
618 html_tag( 'td',
619 "<BR><b>" . _("THIS FOLDER IS EMPTY") . "</b><BR>&nbsp;",
620 'center',
621 $color[4],
622 'COLSPAN="' . count($index_order) . '"'
623 )
624 );
625 } elseif ($start_msg == $end_msg) {
626 /* if there's only one message in the box, handle it differently. */
627 if ($sort != 6){
628 $i = $start_msg;
629 } else {
630 $i = 1;
631 }
632 reset($msort);
633 $k = 0;
634 do {
635 $key = key($msort);
636 next($msort);
637 $k++;
638 } while (isset ($key) && ($k < $i));
639 printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
640 $real_startMessage, $where, $what);
641 } else {
642 $i = $start_msg;
643 reset($msort);
644 $k = 0;
645 do {
646 $key = key($msort);
647 next($msort);
648 $k++;
649 } while (isset ($key) && ($k < $i));
650 do {
651 printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
652 $real_startMessage, $where, $what);
653 $key = key($msort);
654 $t++;
655 $i++;
656 next($msort);
657 } while ($i && $i < $endVar);
658 }
659 }
660
661 /*
662 * Displays the standard message list header. To finish the table,
663 * you need to do a "</table></table>";
664 *
665 * $moveURL is the URL to submit the delete/move form to
666 * $mailbox is the current mailbox
667 * $sort is the current sorting method (-1 for no sorting available [searches])
668 * $Message is a message that is centered on top of the list
669 * $More is a second line that is left aligned
670 */
671
672 function mail_message_listing_beginning ($imapConnection,
673 $mailbox = '', $sort = -1,
674 $msg_cnt_str = '',
675 $paginator = '&nbsp;',
676 $start_msg = 1) {
677 global $color, $auto_expunge, $base_uri, $thread_sort_messages,
678 $allow_thread_sort, $allow_server_sort, $server_sort_order,
679 $PHP_SELF;
680
681 $php_self = $PHP_SELF;
682 /* fix for incorrect $PHP_SELF */
683 if (strpos($php_self, 'move_messages.php')) {
684 $php_self = str_replace('move_messages.php', 'right_main.php', $php_self);
685 }
686 $urlMailbox = urlencode($mailbox);
687
688 if (preg_match('/^(.+)\?.+$/',$php_self,$regs)) {
689 $source_url = $regs[1];
690 } else {
691 $source_url = $php_self;
692 }
693
694 if (!isset($msg)) {
695 $msg = '';
696 }
697 $moveURL = "move_messages.php?msg=$msg&amp;mailbox=$urlMailbox"
698 . "&amp;startMessage=$start_msg";
699 /*
700 * This is the beginning of the message list table.
701 * It wraps around all messages
702 */
703 echo "<FORM name=\"messageList\" method=post action=\"$moveURL\">\n"
704 . html_tag( 'table' ,
705 html_tag( 'tr',
706 html_tag( 'td' ,
707 html_tag( 'table' ,
708 html_tag( 'tr',
709 html_tag( 'td', $paginator, 'left' ) .
710 html_tag( 'td', $msg_cnt_str, 'right' )
711 )
712 , '', $color[4], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
713 , 'left', '', '' )
714 , '', $color[0] )
715 , '', '', 'border="0" width="100%" cellpadding="1" cellspacing="0"' );
716 echo '<tr><td HEIGHT="3" BGCOLOR="'.$color[4].'"></td></tr>';
717 echo '<tr><td>';
718
719 echo html_tag( 'tr' ) . "\n"
720 . html_tag( 'td' ,'' , 'left', '', '' )
721 . html_tag( 'table' ,'' , '', $color[9], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
722 . '<tr><td>'
723 . html_tag( 'table' ,'' , '', $color[0], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
724 . html_tag( 'tr',
725 getSmallStringCell(_("Move Selected To"), 'left') .
726 getSmallStringCell(_("Transform Selected Messages"), 'right')
727 )
728 . html_tag( 'tr' ) ."\n"
729 . html_tag( 'td', '', 'left', '', 'valign="middle" nowrap' );
730 getMbxList($imapConnection);
731 echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n";
732 echo getButton('SUBMIT', 'attache',_("Forward")) . "\n";
733
734 echo " </TD>\n"
735 . html_tag( 'td', '', 'right', '', 'nowrap' );
736
737 if (!$auto_expunge) {
738 echo getButton('SUBMIT', 'expungeButton',_("Expunge"))
739 .'&nbsp;' . _("mailbox") . "\n";
740 }
741
742 echo getButton('SUBMIT', 'markRead',_("Read"));
743 echo getButton('SUBMIT', 'markUnread',_("Unread"));
744 echo getButton('SUBMIT', 'delete',_("Delete")) ."&nbsp\n";
745 if (!strpos($php_self,'mailbox')) {
746 $location = $php_self.'?mailbox=INBOX&amp;startMessage=1';
747 } else {
748 $location = $php_self;
749 }
750 echo '<INPUT TYPE="HIDDEN" NAME="location" VALUE="'.$location.'">';
751 echo "</TD>\n"
752 . " </TR>\n";
753
754 /* draws thread sorting links */
755 if ($allow_thread_sort == TRUE) {
756 if ($thread_sort_messages == 1 ) {
757 $set_thread = 2;
758 $thread_name = _("Unthread View");
759 }
760 elseif ($thread_sort_messages == 0) {
761 $set_thread = 1;
762 $thread_name = _("Thread View");
763 }
764 echo html_tag( 'tr' ,
765 html_tag( 'td' ,
766 '&nbsp;<a href=' . $source_url . '?sort='
767 . "$sort" . '&start_messages=1&set_thread=' . "$set_thread"
768 . '&mailbox=' . urlencode($mailbox) . '><small>' . $thread_name
769 . '</a></small>&nbsp;'
770 , '', '', '' )
771 , '', '', '' );
772 }
773
774 echo "</TABLE></td></tr></table></td></tr>\n";
775
776 do_hook('mailbox_form_before');
777
778
779
780 /* if using server sort we highjack the
781 * the $sort var and use $server_sort_order
782 * instead. but here we reset sort for a bit
783 * since its easy
784 */
785 if ($allow_server_sort == TRUE) {
786 $sort = $server_sort_order;
787 }
788 }
789
790 function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color) {
791 if ($num_msgs) {
792 echo '<tr><td HEIGHT="3" BGCOLOR="'.$color[4].'" COLSPAN="1">';
793 echo '</td></tr><tr><td>';
794 echo html_tag( 'table',
795 html_tag( 'tr',
796 html_tag( 'td',
797 html_tag( 'table',
798 html_tag( 'tr',
799 html_tag( 'td', $paginator_str ) .
800 html_tag( 'td', $msg_cnt_str, 'right' )
801 )
802 , '', $color[4], 'width="100%" border="0" cellpadding="1" cellspacing="0"' )
803 )
804 )
805 , '', $color[9], 'width="100%" border="0" cellpadding="1" cellspacing="0"' );
806 echo '</td></tr>';
807 }
808 /* End of message-list table */
809
810 do_hook('mailbox_index_after');
811 echo "</FORM>\n";
812
813 }
814
815 function printHeader($mailbox, $sort, $color, $showsort=true) {
816 global $index_order;
817 $cols = 0;
818 $line = '';
819 $line .= html_tag( 'tr' ,'' , 'center', $color[5] );
820 for ($i=1; $i <= count($index_order); $i++) {
821 switch ($index_order[$i]) {
822 case 1: /* checkbox */
823 // ++$cols;
824 case 5: /* flags */
825 $line .= html_tag( 'td' ,'&nbsp;' , '', '', 'width="1%"' );
826 ++$cols;
827 break;
828 case 2: /* from */
829 if (handleAsSent($mailbox)) {
830 $line .= html_tag( 'td' ,'' , 'left', '', 'width="25%"' )
831 . '<b>' . _("To") . '</b>';
832 } else {
833 $line .= html_tag( 'td' ,'' , 'left', '', 'width="25%"' )
834 . '<b>' . _("From") . '</b>';
835 }
836 if ($showsort) {
837 $line .= ShowSortButton($sort, $mailbox, 2, 3);
838 }
839 $line .= "</td>\n";
840 ++$cols;
841 break;
842 case 3: /* date */
843 $line .= html_tag( 'td' ,'' , 'left', '', 'width="5%" nowrap' )
844 . '<b>' . _("Date") . '</b>';
845 if ($showsort) {
846 $line .= ShowSortButton($sort, $mailbox, 0, 1);
847 }
848 $line .= "</td>\n";
849 ++$cols;
850 break;
851 case 4: /* subject */
852 $line .= html_tag( 'td' ,'' , 'left', '', '' )
853 . '<b>' . _("Subject") . '</b>';
854 if ($showsort) {
855 $line .= ShowSortButton($sort, $mailbox, 4, 5);
856 }
857 $line .= "</td>\n";
858 ++$cols;
859 break;
860 case 6: /* size */
861 $line .= html_tag( 'td', '<b>' . _("Size") . '</b>', 'center', '', 'width="5%"' );
862 ++$cols;
863 break;
864 }
865 }
866 $line .= "</tr>\n";
867 echo $line;
868 }
869
870
871 /*
872 * This function shows the sort button. Isn't this a good comment?
873 */
874 function ShowSortButton($sort, $mailbox, $Up, $Down ) {
875 global $PHP_SELF;
876 /* Figure out which image we want to use. */
877 if ($sort != $Up && $sort != $Down) {
878 $img = 'sort_none.png';
879 $which = $Up;
880 } elseif ($sort == $Up) {
881 $img = 'up_pointer.png';
882 $which = $Down;
883 } else {
884 $img = 'down_pointer.png';
885 $which = 6;
886 }
887
888 if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
889 $source_url = $regs[1];
890 } else {
891 $source_url = $PHP_SELF;
892 }
893
894 /* Now that we have everything figured out, show the actual button. */
895 return ' <a href="' . $source_url .'?newsort=' . $which
896 . '&amp;startMessage=1&amp;mailbox=' . urlencode($mailbox)
897 . '"><IMG SRC="../images/' . $img
898 . '" BORDER=0 WIDTH=12 HEIGHT=10 ALT="sort"></a>';
899 }
900
901 function get_selectall_link($start_msg, $sort) {
902 global $checkall, $what, $where, $mailbox, $javascript_on;
903 global $PHP_SELF, $PG_SHOWNUM;
904
905 $result = '';
906 if ($javascript_on) {
907 $result =
908 '<script language="JavaScript" type="text/javascript">'
909 . "\n<!-- \n"
910 . "function CheckAll() {\n"
911 . " for (var i = 0; i < document.messageList.elements.length; i++) {\n"
912 . " if(document.messageList.elements[i].type == 'checkbox'){\n"
913 . " document.messageList.elements[i].checked = "
914 . " !(document.messageList.elements[i].checked);\n"
915 . " }\n"
916 . " }\n"
917 . "}\n"
918 . "//-->\n"
919 . '</script><a href="#" onClick="CheckAll();">' . _("Toggle All")
920 . "</a>\n";
921 } else {
922 if (strpos($PHP_SELF, "?")) {
923 $result .= "<a href=\"$PHP_SELF&amp;mailbox=" . urlencode($mailbox)
924 . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
925 } else {
926 $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
927 . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
928 }
929 if (isset($checkall) && $checkall == '1') {
930 $result .= '0';
931 } else {
932 $result .= '1';
933 }
934
935 if (isset($where) && isset($what)) {
936 $result .= '&amp;where=' . urlencode($where)
937 . '&amp;what=' . urlencode($what);
938 }
939
940 $result .= "\">";
941
942 if (isset($checkall) && ($checkall == '1')) {
943 $result .= _("Unselect All");
944 } else {
945 $result .= _("Select All");
946 }
947
948 $result .= "</A>\n";
949 }
950
951 /* Return our final result. */
952 return ($result);
953 }
954
955 /*
956 * This function computes the "Viewing Messages..." string.
957 */
958 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
959 /* Compute the $msg_cnt_str. */
960 $result = '';
961 if ($start_msg < $end_msg) {
962 $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"),
963 $start_msg, $end_msg, $num_msgs);
964 } else if ($start_msg == $end_msg) {
965 $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
966 } else {
967 $result = '<br>';
968 }
969 /* Return our result string. */
970 return ($result);
971 }
972
973 /*
974 * Generate a paginator link.
975 */
976 function get_paginator_link($box, $start_msg, $use, $text) {
977 global $PHP_SELF;
978
979 $result = "<A HREF=\"right_main.php?use_mailbox_cache=$use"
980 . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
981 . "TARGET=\"right\">$text</A>";
982 return ($result);
983 /*
984 if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
985 $source_url = $regs[1];
986 } else {
987 $source_url = $PHP_SELF;
988 }
989
990 $result = '<A HREF="'. $source_url . "?use_mailbox_cache=$use"
991 . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
992 . "TARGET=\"right\">$text</A>";
993 return ($result);
994 */
995 }
996
997 /*
998 * This function computes the paginator string.
999 */
1000 function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
1001 $show_num, $sort) {
1002 global $username, $data_dir, $use_mailbox_cache, $color, $PG_SHOWNUM;
1003
1004 /* Initialize paginator string chunks. */
1005 $prv_str = '';
1006 $nxt_str = '';
1007 $pg_str = '';
1008 $all_str = '';
1009 $tgl_str = '';
1010
1011 $box = urlencode($box);
1012
1013 /* Create simple strings that will be creating the paginator. */
1014 $spc = '&nbsp;'; /* This will be used as a space. */
1015 $sep = '|'; /* This will be used as a seperator. */
1016
1017 /* Get some paginator preference values. */
1018 $pg_sel = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
1019 $pg_max = getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX);
1020
1021 /* Make sure that our start message number is not too big. */
1022 $start_msg = min($start_msg, $num_msgs);
1023
1024 /* Decide whether or not we will use the mailbox cache. */
1025 /* Not sure why $use_mailbox_cache is even passed in. */
1026 if ($sort == 6) {
1027 $use = 0;
1028 } else {
1029 $use = 1;
1030 }
1031
1032 /* Compute the starting message of the previous and next page group. */
1033 $next_grp = $start_msg + $show_num;
1034 $prev_grp = $start_msg - $show_num;
1035
1036 /* Compute the basic previous and next strings. */
1037 if (($next_grp <= $num_msgs) && ($prev_grp >= 0)) {
1038 $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
1039 $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
1040 } else if (($next_grp > $num_msgs) && ($prev_grp >= 0)) {
1041 $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
1042 $nxt_str = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
1043 } else if (($next_grp <= $num_msgs) && ($prev_grp < 0)) {
1044 $prv_str = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
1045 $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
1046 }
1047
1048 /* Page selector block. Following code computes page links. */
1049 if ($pg_sel && ($num_msgs > $show_num)) {
1050 /* Most importantly, what is the current page!!! */
1051 $cur_pg = intval($start_msg / $show_num) + 1;
1052
1053 /* Compute total # of pages and # of paginator page links. */
1054 $tot_pgs = ceil($num_msgs / $show_num); /* Total number of Pages */
1055 $vis_pgs = min($pg_max, $tot_pgs - 1); /* Visible Pages */
1056
1057 /* Compute the size of the four quarters of the page links. */
1058
1059 /* If we can, just show all the pages. */
1060 if (($tot_pgs - 1) <= $pg_max) {
1061 $q1_pgs = $cur_pg - 1;
1062 $q2_pgs = $q3_pgs = 0;
1063 $q4_pgs = $tot_pgs - $cur_pg;
1064
1065 /* Otherwise, compute some magic to choose the four quarters. */
1066 } else {
1067 /*
1068 * Compute the magic base values. Added together,
1069 * these values will always equal to the $pag_pgs.
1070 * NOTE: These are DEFAULT values and do not take
1071 * the current page into account. That is below.
1072 */
1073 $q1_pgs = floor($vis_pgs/4);
1074 $q2_pgs = round($vis_pgs/4, 0);
1075 $q3_pgs = ceil($vis_pgs/4);
1076 $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0);
1077
1078 /* Adjust if the first quarter contains the current page. */
1079 if (($cur_pg - $q1_pgs) < 1) {
1080 $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs;
1081 $q1_pgs = $cur_pg - 1;
1082 $q2_pgs = 0;
1083 $q3_pgs += ceil($extra_pgs / 2);
1084 $q4_pgs += floor($extra_pgs / 2);
1085
1086 /* Adjust if the first and second quarters intersect. */
1087 } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
1088 $extra_pgs = $q2_pgs;
1089 $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 0.75);
1090 $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 0.75);
1091 $q3_pgs += ceil($extra_pgs / 2);
1092 $q4_pgs += floor($extra_pgs / 2);
1093
1094 /* Adjust if the fourth quarter contains the current page. */
1095 } else if (($cur_pg + $q4_pgs) >= $tot_pgs) {
1096 $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs;
1097 $q3_pgs = 0;
1098 $q4_pgs = $tot_pgs - $cur_pg;
1099 $q1_pgs += floor($extra_pgs / 2);
1100 $q2_pgs += ceil($extra_pgs / 2);
1101
1102 /* Adjust if the third and fourth quarter intersect. */
1103 } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
1104 $extra_pgs = $q3_pgs;
1105 $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
1106 $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
1107 $q1_pgs += floor($extra_pgs / 2);
1108 $q2_pgs += ceil($extra_pgs / 2);
1109 }
1110 }
1111
1112 /*
1113 * I am leaving this debug code here, commented out, because
1114 * it is a really nice way to see what the above code is doing.
1115 * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
1116 * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br>';
1117 */
1118
1119 /* Print out the page links from the compute page quarters. */
1120
1121 /* Start with the first quarter. */
1122 if (($q1_pgs == 0) && ($cur_pg > 1)) {
1123 $pg_str .= "...$spc";
1124 } else {
1125 for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
1126 $start = (($pg-1) * $show_num) + 1;
1127 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1128 }
1129 if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
1130 $pg_str .= "...$spc";
1131 }
1132 }
1133
1134 /* Continue with the second quarter. */
1135 for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
1136 $start = (($pg-1) * $show_num) + 1;
1137 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1138 }
1139
1140 /* Now print the current page. */
1141 $pg_str .= $cur_pg . $spc;
1142
1143 /* Next comes the third quarter. */
1144 for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
1145 $start = (($pg-1) * $show_num) + 1;
1146 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1147 }
1148
1149 /* And last, print the forth quarter page links. */
1150 if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
1151 $pg_str .= "...$spc";
1152 } else {
1153 if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
1154 $pg_str .= "...$spc";
1155 }
1156 for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
1157 $start = (($pg-1) * $show_num) + 1;
1158 $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
1159 }
1160 }
1161 } else if ($PG_SHOWNUM == 999999) {
1162 $pg_str = "<A HREF=\"right_main.php?PG_SHOWALL=0"
1163 . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
1164 . "TARGET=\"right\">" ._("Paginate") . '</A>' . $spc;
1165 }
1166
1167 /* If necessary, compute the 'show all' string. */
1168 if (($prv_str != '') || ($nxt_str != '')) {
1169 $all_str = "<A HREF=\"right_main.php?PG_SHOWALL=1"
1170 . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
1171 . "TARGET=\"right\">" . _("Show All") . '</A>';
1172 }
1173
1174 /* Last but not least, get the value for the toggle all link. */
1175 $tgl_str = get_selectall_link($start_msg, $sort);
1176
1177 /* Put all the pieces of the paginator string together. */
1178 /**
1179 * Hairy code... But let's leave it like it is since I am not certain
1180 * a different approach would be any easier to read. ;)
1181 */
1182 $result = '';
1183 $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
1184 $result .= ($nxt_str != '' ? $nxt_str . $spc . $sep . $spc : '');
1185 $result .= ($pg_str != '' ? $pg_str : '');
1186 $result .= ($all_str != '' ? $sep . $spc . $all_str . $spc : '');
1187 $result .= ($result != '' ? $sep . $spc . $tgl_str: $tgl_str);
1188
1189 /* If the resulting string is blank, return a non-breaking space. */
1190 if ($result == '') {
1191 $result = '&nbsp;';
1192 }
1193
1194 /* Return our final magical paginator string. */
1195 return ($result);
1196 }
1197
1198 function processSubject($subject) {
1199 global $languages, $squirrelmail_language;
1200 /* Shouldn't ever happen -- caught too many times in the IMAP functions */
1201 if ($subject == '')
1202 return _("(no subject)");
1203
1204 if (strlen($subject) <= 55)
1205 return $subject;
1206
1207 $ent_strlen=strlen($subject);
1208 $trim_val=50;
1209 $ent_offset=0;
1210 /*
1211 * see if this is entities-encoded string
1212 * If so, Iterate through the whole string, find out
1213 * the real number of characters, and if more
1214 * than 55, substr with an updated trim value.
1215 */
1216 while ( (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
1217 (($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false) ) {
1218 $trim_val += ($ent_loc_end-$ent_loc)+1;
1219 $ent_strlen -= $ent_loc_end-$ent_loc;
1220 $ent_offset = $ent_loc_end+1;
1221 }
1222
1223 if ($ent_strlen <= 55){
1224 return $subject;
1225 }
1226
1227 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
1228 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
1229 return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val);
1230 }
1231
1232 return substr($subject, 0, $trim_val) . '...';
1233 }
1234
1235 function getMbxList($imapConnection) {
1236 global $lastTargetMailbox;
1237 echo ' <small>&nbsp;<tt><select name="targetMailbox">';
1238 $boxes = sqimap_mailbox_list($imapConnection);
1239 foreach ($boxes as $boxes_part) {
1240 if (!in_array('noselect', $boxes_part['flags'])) {
1241 $box = $boxes_part['unformatted'];
1242 $box2 = str_replace(' ', '&nbsp;', imap_utf7_decode_local($boxes_part['unformatted-disp']));
1243 if( $box2 == 'INBOX' ) {
1244 $box2 = _("INBOX");
1245 }
1246 if ($lastTargetMailbox == $box) {
1247 echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
1248 }
1249 else {
1250 echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
1251 }
1252 }
1253 }
1254 echo ' </SELECT></TT>&nbsp;';
1255 }
1256
1257 function getButton($type, $name, $value) {
1258 global $color;
1259 $style = ' STYLE="background:'.$color[4].';font-size:80%;font-weight:bold;'.
1260 'color:'.$color[8].';margin:0.05em;border:0.2em outset '.
1261 $color[9].';"';
1262 $javascript = " onmouseover=\"this.style.color='$color[4]'".
1263 ";this.style.borderStyle='inset'" .
1264 ";this.style.background='$color[3]';\";" .
1265 " onmouseout=\"this.style.color='$color[8]'".
1266 ";this.style.borderStyle='outset'" .
1267 ";this.style.background='$color[4]';\";";
1268
1269 return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '"'.$style.$javascript.'>';
1270 }
1271
1272 function getSmallStringCell($string, $align) {
1273 return html_tag( 'td',
1274 '<small>' . $string . ':&nbsp; </small>',
1275 $align,
1276 '',
1277 'nowrap' );
1278 }
1279
1280 function getEndMessage($start_msg, $show_num, $num_msgs) {
1281 if ($start_msg + ($show_num - 1) < $num_msgs){
1282 $end_msg = $start_msg + ($show_num - 1);
1283 } else {
1284 $end_msg = $num_msgs;
1285 }
1286
1287 if ($end_msg < $start_msg) {
1288 $start_msg = $start_msg - $show_num;
1289 if ($start_msg < 1) {
1290 $start_msg = 1;
1291 }
1292 }
1293 return (array($start_msg,$end_msg));
1294 }
1295
1296 function handleAsSent($mailbox) {
1297 global $sent_folder, $draft_folder, $handleAsSent_result;
1298
1299 /* First check if this is the sent or draft folder. */
1300 $handleAsSent_result = (($mailbox == $sent_folder)
1301 || ($mailbox == $draft_folder));
1302
1303 /* Then check the result of the handleAsSent hook. */
1304 do_hook('check_handleAsSent_result', $mailbox);
1305
1306 /* And return the result. */
1307 return ($handleAsSent_result);
1308 }
1309
1310 ?>