* Specified image width and height (solves a weird display funkiness in IE
[squirrelmail.git] / functions / mailbox_display.php
1 <?php
2
3 /**
4 ** mailbox_display.php
5 **
6 ** This contains functions that display mailbox information, such as the
7 ** table row that has sender, date, subject, etc...
8 **
9 ** $Id$
10 **/
11
12 if (defined('mailbox_display_php'))
13 return;
14 define('mailbox_display_php', true);
15
16 function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
17 global $checkall;
18 global $color, $msgs, $msort;
19 global $sent_folder;
20 global $message_highlight_list;
21 global $index_order;
22
23 $color_string = $color[4];
24 if ($GLOBALS['alt_index_colors']) {
25 if (!isset($GLOBALS["row_count"])) {
26 $GLOBALS["row_count"] = 0;
27 }
28 $GLOBALS["row_count"]++;
29 if ($GLOBALS["row_count"] % 2) {
30 if (!isset($color[12])) $color[12] = "#EAEAEA";
31 $color_string = $color[12];
32 }
33 }
34
35 $msg = $msgs[$key];
36
37 $senderName = sqimap_find_displayable_name($msg['FROM']);
38 $urlMailbox = urlencode($mailbox);
39 $subject = processSubject($msg['SUBJECT']);
40
41 echo "<TR>\n";
42
43 if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true)
44 {
45 $flag = "<font color=$color[2]>";
46 $flag_end = '</font>';
47 }
48 else
49 {
50 $flag = '';
51 $flag_end = '';
52 }
53 if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false)
54 {
55 $bold = '<b>';
56 $bold_end = '</b>';
57 }
58 else
59 {
60 $bold = '';
61 $bold_end = '';
62 }
63 if ($mailbox == $sent_folder)
64 {
65 $italic = '<i>';
66 $italic_end = '</i>';
67 }
68 else
69 {
70 $italic = '';
71 $italic_end = '';
72 }
73 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'])
74 {
75 $fontstr = "<font color=\"$color[9]\">";
76 $fontstr_end = '</font>';
77 }
78 else
79 {
80 $fontstr = '';
81 $fontstr_end = '';
82 }
83
84 for ($i=0; $i < count($message_highlight_list); $i++) {
85 if (trim($message_highlight_list[$i]['value']) != '') {
86 if ($message_highlight_list[$i]['match_type'] == 'to_cc') {
87 if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) || strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) {
88 $hlt_color = $message_highlight_list[$i]['color'];
89 continue;
90 }
91 } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) {
92 $hlt_color = $message_highlight_list[$i]['color'];
93 continue;
94 }
95 }
96 }
97
98 if (!isset($hlt_color))
99 $hlt_color = $color_string;
100
101 if ($where && $what) {
102 $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
103 }
104
105 if ($checkall == 1)
106 $checked = ' checked';
107 else
108 $checked = '';
109
110 for ($i=1; $i <= count($index_order); $i++) {
111 switch ($index_order[$i]) {
112 case 1: # checkbox
113 echo " <td bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
114 break;
115 case 2: # from
116 echo " <td bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
117 break;
118 case 3: # date
119 echo " <td nowrap bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
120 break;
121 case 4: # subject
122 echo " <td bgcolor=$hlt_color>$bold";
123 if (! isset($search_stuff)) { $search_stuff = ''; }
124 echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
125 do_hook("subject_link");
126 echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
127 break;
128 case 5: # flags
129 $stuff = false;
130 echo " <td bgcolor=$hlt_color align=center nowrap><b><small>\n";
131 if (isset($msg['FLAG_ANSWERED']) &&
132 $msg['FLAG_ANSWERED'] == true) {
133 echo "A\n";
134 $stuff = true;
135 }
136 if ($msg['TYPE0'] == 'multipart') {
137 echo "+\n";
138 $stuff = true;
139 }
140 if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
141 echo "<font color=$color[1]>!</font>\n";
142 $stuff = true;
143 }
144 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
145 echo "<font color=\"$color[1]\">D</font>\n";
146 $stuff = true;
147 }
148
149 if (!$stuff) echo "&nbsp;\n";
150 echo "</small></b></td>\n";
151 break;
152 case 6: # size
153 echo " <td bgcolor=$hlt_color>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
154 break;
155 }
156 }
157
158
159 echo "</tr>\n";
160 }
161
162 /**
163 ** This function loops through a group of messages in the mailbox and shows them
164 **/
165 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
166 global $msgs, $msort;
167 global $sent_folder;
168 global $message_highlight_list;
169 global $auto_expunge;
170
171 if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false);
172 sqimap_mailbox_select($imapConnection, $mailbox);
173
174 if (!$use_cache) {
175 // if it's sorted
176 if ($numMessages >= 1) {
177 if ($sort < 6) {
178 for ($q = 0; $q < $numMessages; $q++) {
179 if($mailbox == $sent_folder)
180 $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
181 else
182 $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
183
184 $from[$q] = $hdr->from;
185 $date[$q] = $hdr->date;
186 $subject[$q] = $hdr->subject;
187 $to[$q] = $hdr->to;
188 $priority[$q] = $hdr->priority;
189 $cc[$q] = $hdr->cc;
190 $size[$q] = $hdr->size;
191 $type[$q] = $hdr->type0;
192 $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
193 $id[$q] = $q + 1;
194 }
195 } else {
196 // if it's not sorted
197 if ($startMessage + ($show_num - 1) < $numMessages) {
198 $endMessage = $startMessage + ($show_num-1);
199 } else {
200 $endMessage = $numMessages;
201 }
202
203 if ($endMessage < $startMessage) {
204 $startMessage = $startMessage - $show_num;
205 if ($startMessage < 1)
206 $startMessage = 1;
207 }
208
209
210 $real_startMessage = $numMessages - $startMessage + 1;
211 $real_endMessage = $numMessages - $startMessage - $show_num;
212 if ($real_endMessage <= 0)
213 $real_endMessage = 1;
214
215 $j = 0;
216 for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
217 if($mailbox == $sent_folder)
218 $hdr = sqimap_get_small_header ($imapConnection, $q, true);
219 else
220 $hdr = sqimap_get_small_header ($imapConnection, $q, false);
221
222 $from[$j] = $hdr->from;
223 $date[$j] = $hdr->date;
224 $subject[$j] = $hdr->subject;
225 $to[$j] = $hdr->to;
226 $priority[$j] = $hdr->priority;
227 $cc[$j] = $hdr->cc;
228 $size[$j] = $hdr->size;
229 $type[$j] = $hdr->type0;
230 $flags[$j] = sqimap_get_flags ($imapConnection, $q);
231 $id[$j] = $q;
232 $j++;
233 }
234 }
235 }
236
237 $j = 0;
238 if ($sort == 6) {
239 $end = $startMessage + $show_num - 1;
240 if ($numMessages < $show_num)
241 $end_loop = $numMessages;
242 elseif ($end > $numMessages)
243 $end_loop = $numMessages - $startMessage + 1;
244 else
245 $end_loop = $show_num;
246 } else {
247 $end = $numMessages;
248 $end_loop = $end;
249 }
250 while ($j < $end_loop) {
251 if (isset($date[$j])) {
252 $date[$j] = ereg_replace(' ', ' ', $date[$j]);
253 $tmpdate = explode(' ', trim($date[$j]));
254 } else {
255 $tmpdate = $date = array("","","","","","");
256 }
257
258 $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
259 $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']);
260 $messages[$j]['ID'] = $id[$j];
261 $messages[$j]['FROM'] = decodeHeader($from[$j]);
262 $messages[$j]['FROM-SORT'] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
263 $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
264 $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
265 $messages[$j]['TO'] = decodeHeader($to[$j]);
266 $messages[$j]['PRIORITY'] = $priority[$j];
267 $messages[$j]['CC'] = $cc[$j];
268 $messages[$j]['SIZE'] = $size[$j];
269 $messages[$j]['TYPE0'] = $type[$j];
270
271 # fix SUBJECT-SORT to remove Re:
272 $re_abbr = # Add more here!
273 'vedr|sv|' . # Danish
274 're|aw'; # English
275 if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
276 $messages[$j]['SUBJECT-SORT'] = $regs[2];
277
278 $num = 0;
279 while ($num < count($flags[$j])) {
280 if ($flags[$j][$num] == 'Deleted') {
281 $messages[$j]['FLAG_DELETED'] = true;
282 }
283 elseif ($flags[$j][$num] == 'Answered') {
284 $messages[$j]['FLAG_ANSWERED'] = true;
285 }
286 elseif ($flags[$j][$num] == 'Seen') {
287 $messages[$j]['FLAG_SEEN'] = true;
288 }
289 elseif ($flags[$j][$num] == 'Flagged') {
290 $messages[$j]['FLAG_FLAGGED'] = true;
291 }
292 $num++;
293 }
294 $j++;
295 }
296
297 /* Only ignore messages flagged as deleted if we are using a
298 * trash folder or auto_expunge */
299 if (((isset($move_to_trash) && $move_to_trash)
300 || (isset($auto_expunge) && $auto_expunge)) && $sort != 6)
301 {
302 /** Find and remove the ones that are deleted */
303 $i = 0;
304 $j = 0;
305 while ($j < $numMessages) {
306 if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) {
307 $j++;
308 continue;
309 }
310 $msgs[$i] = $messages[$j];
311
312 $i++;
313 $j++;
314 }
315 $numMessages = $i;
316 } else {
317 if (! isset($messages))
318 $messages = array();
319 $msgs = $messages;
320 }
321 }
322
323 // There's gotta be messages in the array for it to sort them.
324 if ($numMessages > 0 && ! $use_cache) {
325 /** 0 = Date (up) 4 = Subject (up)
326 ** 1 = Date (dn) 5 = Subject (dn)
327 ** 2 = Name (up)
328 ** 3 = Name (dn)
329 **/
330 session_unregister("msgs");
331 if (($sort == 0) || ($sort == 1))
332 $msort = array_cleave ($msgs, 'TIME_STAMP');
333 elseif (($sort == 2) || ($sort == 3))
334 $msort = array_cleave ($msgs, 'FROM-SORT');
335 elseif (($sort == 4) || ($sort == 5))
336 $msort = array_cleave ($msgs, 'SUBJECT-SORT');
337 else // ($sort == 6)
338 $msort = $msgs;
339
340 if ($sort < 6) {
341 if ($sort % 2) {
342 asort($msort);
343 } else {
344 arsort($msort);
345 }
346 }
347 session_register('msort');
348 }
349 displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
350 session_register('msgs');
351 }
352
353 // generic function to convert the msgs array into an HTML table
354 function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
355 global $folder_prefix, $sent_folder;
356 global $imapServerAddress;
357 global $index_order, $real_endMessage, $real_startMessage, $checkall;
358
359 // if cache isn't already set, do it now
360 if (!session_is_registered('msgs'))
361 session_register('msgs');
362 if (!session_is_registered('msort'))
363 session_register('msort');
364
365 if ($startMessage + ($show_num - 1) < $numMessages) {
366 $endMessage = $startMessage + ($show_num-1);
367 } else {
368 $endMessage = $numMessages;
369 }
370
371 if ($endMessage < $startMessage) {
372 $startMessage = $startMessage - $show_num;
373 if ($startMessage < 1)
374 $startMessage = 1;
375 }
376
377 $nextGroup = $startMessage + $show_num;
378 $prevGroup = $startMessage - $show_num;
379 $urlMailbox = urlencode($mailbox);
380
381 do_hook('mailbox_index_before');
382
383 $Message = '';
384 if ($startMessage < $endMessage) {
385 $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
386 } elseif ($startMessage == $endMessage) {
387 $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
388 }
389
390 $More = '';
391 if ($sort == 6) {
392 $use = 0;
393 } else {
394 $use = 1;
395 }
396 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
397 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
398 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
399 }
400 elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
401 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
402 $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
403 }
404 elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
405 $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
406 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
407 }
408
409 if (! isset($msg))
410 $msg = "";
411 mail_message_listing_beginning($imapConnection,
412 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
413 $mailbox, $sort, $Message, $More, $startMessage);
414
415 $groupNum = $startMessage % ($show_num - 1);
416 $real_startMessage = $startMessage;
417 if ($sort == 6) {
418 if ($endMessage - $startMessage < $show_num - 1) {
419 $endMessage = $endMessage - $startMessage + 1;
420 $startMessage = 1;
421 } else if ($startMessage > $show_num) {
422 $endMessage = $show_num;
423 $startMessage = 1;
424 }
425 }
426
427 $endVar = $endMessage + 1;
428
429 // loop through and display the info for each message.
430 $t = 0; // $t is used for the checkbox number
431 if ($numMessages == 0) { // if there's no messages in this folder
432 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
433 echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
434 } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
435 if ($sort != 6)
436 $i = $startMessage;
437 else
438 $i = 1;
439 reset($msort);
440 $k = 0;
441 do {
442 $key = key($msort);
443 next($msort);
444 $k++;
445 } while (isset ($key) && ($k < $i));
446 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
447 } else {
448 $i = $startMessage;
449
450 reset($msort);
451 $k = 0;
452 do {
453 $key = key($msort);
454 next($msort);
455 $k++;
456 } while (isset ($key) && ($k < $i));
457
458 do {
459 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
460 $key = key($msort);
461 $t++;
462 $i++;
463 next($msort);
464 } while ($i && $i < $endVar);
465 }
466 echo '</TABLE>';
467
468 echo "</td></tr>\n";
469
470 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
471 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
472 echo "$More</td><td align=right>\n";
473 if (!$startMessage) $startMessage=1;
474 ShowSelectAllLink($startMessage, $sort);
475
476 echo '</td></tr></table>';
477 echo '</td></tr>';
478 echo '</table>'; /** End of message-list table */
479
480 do_hook('mailbox_index_after');
481 }
482
483 /* Displays the standard message list header.
484 * To finish the table, you need to do a "</table></table>";
485 * $moveURL is the URL to submit the delete/move form to
486 * $mailbox is the current mailbox
487 * $sort is the current sorting method (-1 for no sorting available [searches])
488 * $Message is a message that is centered on top of the list
489 * $More is a second line that is left aligned
490 */
491 function mail_message_listing_beginning($imapConnection, $moveURL,
492 $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
493 {
494 global $color, $index_order, $auto_expunge, $move_to_trash;
495 global $checkall, $sent_folder;
496 $urlMailbox = urlencode($mailbox);
497 /** This is the beginning of the message list table. It wraps around all messages */
498 echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">';
499
500 if ($Message)
501 {
502 echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
503 }
504
505 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
506 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
507 echo "$More</td><td align=right>\n";
508 ShowSelectAllLink($startMessage, $sort);
509
510 echo '</td></tr></table>';
511 echo '</td></tr>';
512
513 /** The delete and move options */
514 echo "<TR><TD BGCOLOR=\"$color[0]\">";
515
516 echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n";
517 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
518 echo " <TR>\n";
519 echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
520
521
522 echo ' <NOBR><SMALL>'. _("Move selected to:") .'</SMALL>';
523 echo ' <TT><SMALL><SELECT NAME="targetMailbox">';
524
525 $boxes = sqimap_mailbox_list($imapConnection);
526 for ($i = 0; $i < count($boxes); $i++) {
527 if (!in_array("noselect", $boxes[$i]['flags'])) {
528 $box = $boxes[$i]['unformatted'];
529 $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
530 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
531 }
532 }
533 echo ' </SELECT></SMALL></TT>';
534 echo ' <SMALL><INPUT TYPE=SUBMIT NAME="moveButton" VALUE="'. _("Move") ."\"></SMALL></NOBR>\n";
535 echo " </TD>\n";
536 echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
537 if (! $auto_expunge) {
538 echo ' <NOBR><SMALL><INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'">&nbsp;'. _("mailbox") ."</SMALL></NOBR>&nbsp;&nbsp;\n";
539 }
540 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\">&nbsp;". _("checked messages") ."</SMALL></NOBR>\n";
541 echo " </TD>\n";
542 echo " </TR>\n";
543
544 echo "</TABLE>\n";
545 do_hook('mailbox_form_before');
546 echo '</TD></TR>';
547
548 echo "<TR><TD BGCOLOR=\"$color[0]\">";
549 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=";
550 if ($GLOBALS['alt_index_colors']) {
551 echo "0";
552 } else {
553 echo "1";
554 }
555 echo " BGCOLOR=\"$color[0]\">";
556 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
557
558 $urlMailbox=urlencode($mailbox);
559
560 $upPointer = '<IMG SRC="../images/up_pointer.gif" HEIGHT=10 WIDTH=12 BORDER=0>';
561 $downPointer = '<IMG SRC="../images/down_pointer.gif" HEIGHT=10 WIDTH=12 BORDER=0>';
562 $noPointer = '<IMG SRC="../images/sort_none" WIDTH=12 HEIGHT=10 BORDER=0>';
563
564 // Print the headers
565 for ($i=1; $i <= count($index_order); $i++) {
566 switch ($index_order[$i]) {
567 case 1: # checkbox
568 case 5: # flags
569 echo ' <TD WIDTH="1%"><B>&nbsp;</B></TD>';
570 break;
571
572 case 2: # from
573 if ($mailbox == $sent_folder)
574 echo ' <TD WIDTH="25%"><B>'. _("To") .'</B>';
575 else
576 echo ' <TD WIDTH="25%"><B>'. _("From") .'</B>';
577 ShowSortButton($sort, $urlMailbox, 2, 3);
578 echo "</TD>\n";
579 break;
580
581 case 3: # date
582 echo ' <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
583 ShowSortButton($sort, $urlMailbox, 0, 1);
584 echo "</TD>\n";
585 break;
586
587 case 4: # subject
588 echo ' <TD><B>'. _("Subject") .'</B> ';
589 ShowSortButton($sort, $urlMailbox, 4, 5);
590 echo "</TD>\n";
591 break;
592
593 case 6: # size
594 echo ' <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
595 break;
596 }
597 }
598 echo "</TR>\n";
599 }
600
601 function ShowSortButton($sort, $mailbox, $Up, $Down) {
602 if ($sort != $Up && $sort != $Down) {
603 $img = 'sort_none.gif';
604 $which = $Up;
605 } elseif ($sort == $Up) {
606 $img = 'up_pointer.gif';
607 $which = $Down;
608 } else {
609 $img = 'down_pointer.gif';
610 $which = 6;
611 }
612 echo ' <a href="right_main.php?newsort=' . $which .
613 '&startMessage=1&mailbox=' . $mailbox . '"><IMG SRC="../images/' .
614 $img . '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
615 }
616
617 function ShowSelectAllLink($startMessage, $sort)
618 {
619 global $checkall, $PHP_SELF, $what, $where, $mailbox;
620
621 echo "\n<A HREF=\"$PHP_SELF?mailbox=" . urlencode($mailbox) .
622 "&startMessage=$startMessage&sort=$sort&";
623 if ( isset($checkall) && $checkall == '1')
624 echo "checkall=0";
625 else
626 echo "checkall=1";
627 if (isset($where) && isset($what))
628 echo "&where=" . urlencode($where) . "&what=" . urlencode($what);
629 echo "\">";
630 if (isset($checkall) && $checkall == '1')
631 echo _("Unselect All");
632 else
633 echo _("Select All");
634 echo "</A>\n";
635 }
636
637 function processSubject($subject)
638 {
639 // Shouldn't ever happen -- caught too many times in the IMAP functions
640 if ($subject == '')
641 return _("(no subject)");
642
643 if (strlen($subject) <= 55)
644 return $subject;
645
646 $ent_strlen=strlen($subject);
647 $trim_val=50;
648 $ent_offset=0;
649 // see if this is entities-encoded string
650 // If so, Iterate through the whole string, find out
651 // the real number of characters, and if more
652 // than 55, substr with an updated trim value.
653 while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
654 ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
655 {
656 $trim_val += ($ent_loc_end-$ent_loc)+1;
657 $ent_strlen -= $ent_loc_end-$ent_loc;
658 $ent_offset = $ent_loc_end+1;
659 }
660
661 if ($ent_strlen <= 55)
662 return $subject;
663
664 return substr($subject, 0, $trim_val) . '...';
665 }
666
667 ?>