5 * Copyright (c) 1999-2001 The Squirrelmail Development Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 * This contains functions that display mailbox information, such as the
9 * table row that has sender, date, subject, etc...
14 define('PG_SEL_MAX', 10); /* Default value for page_selector_max. */
16 function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $start_msg, $where, $what) {
18 global $color, $msgs, $msort;
19 global $sent_folder, $draft_folder;
20 global $default_use_priority;
21 global $message_highlight_list;
24 $color_string = $color[4];
25 if ($GLOBALS['alt_index_colors']) {
26 if (!isset($GLOBALS["row_count"])) {
27 $GLOBALS["row_count"] = 0;
29 $GLOBALS["row_count"]++
;
30 if ($GLOBALS["row_count"] %
2) {
31 if (!isset($color[12])) $color[12] = '#EAEAEA';
32 $color_string = $color[12];
37 $senderName = htmlspecialchars(sqimap_find_displayable_name($msg['FROM']));
38 if( $mailbox == 'None' ) {
39 // $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40 $boxes = sqimap_mailbox_list($imapConnection);
41 // sqimap_logout($imapConnection);
42 $mailbox = $boxes[0]['unformatted'];
45 $urlMailbox = urlencode($mailbox);
46 $subject = processSubject($msg['SUBJECT']);
49 if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
50 $flag = "<font color=$color[2]>";
51 $flag_end = '</font>';
56 if (!isset($msg['FLAG_SEEN']) ||
($msg['FLAG_SEEN'] == false)) {
64 if (($mailbox == $sent_folder) ||
($mailbox == $draft_folder)) {
72 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
73 $fontstr = "<font color=\"$color[9]\">";
74 $fontstr_end = '</font>';
80 for ($i=0; $i < count($message_highlight_list); $i++
) {
81 if (trim($message_highlight_list[$i]['value']) != '') {
82 if ($message_highlight_list[$i]['match_type'] == 'to_cc') {
83 if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) ||
strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) {
84 $hlt_color = $message_highlight_list[$i]['color'];
87 } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) {
88 $hlt_color = $message_highlight_list[$i]['color'];
94 if (!isset($hlt_color)) {
95 $hlt_color = $color_string;
98 if ($where && $what) {
99 $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
102 $checked = ($checkall == 1 ?
' checked' : '');
104 for ($i=1; $i <= count($index_order); $i++
) {
105 switch ($index_order[$i]) {
106 case 1: /* checkbox */
107 echo " <td bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
110 echo " <td bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
113 echo " <td nowrap bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
115 case 4: /* subject */
116 echo " <td bgcolor=$hlt_color>$bold";
117 if (! isset($search_stuff)) { $search_stuff = ''; }
118 echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$start_msg&show_more=0$search_stuff\"";
119 do_hook("subject_link");
121 if ($subject != $msg['SUBJECT']) {
122 $title = get_html_translation_table(HTML_SPECIALCHARS
);
123 $title = array_flip($title);
124 $title = strtr($msg['SUBJECT'], $title);
125 $title = str_replace('"', "''", $title);
126 echo " title=\"$title\"";
128 echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
132 echo " <td bgcolor=$hlt_color align=center nowrap><b><small>\n";
133 if (isset($msg['FLAG_ANSWERED']) &&
134 $msg['FLAG_ANSWERED'] == true) {
138 if ($msg['TYPE0'] == 'multipart') {
142 if ($default_use_priority) {
143 if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
144 echo "<font color=$color[1]>!</font>\n";
147 if (ereg('(5)',substr($msg['PRIORITY'],0,1))) {
148 echo "<font color=$color[8]>?</font>\n";
152 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
153 echo "<font color=\"$color[1]\">D</font>\n";
157 if (!$stuff) echo " \n";
158 echo "</small></b></td>\n";
161 echo " <td bgcolor=$hlt_color>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
169 * This function loops through a group of messages in the mailbox
170 * and shows them to the user.
172 function showMessagesForMailbox
173 ($imapConnection, $mailbox, $num_msgs, $start_msg,
174 $sort, $color,$show_num, $use_cache) {
175 global $msgs, $msort;
176 global $sent_folder, $draft_folder;
177 global $message_highlight_list;
178 global $auto_expunge;
180 /* If autoexpunge is turned on, then do it now. */
181 if ($auto_expunge == true) {
182 sqimap_mailbox_expunge($imapConnection, $mailbox, false);
184 sqimap_mailbox_select($imapConnection, $mailbox);
186 $issent = (($mailbox == $sent_folder) ||
($mailbox == $draft_folder));
188 /* If it is sorted... */
189 if ($num_msgs >= 1) {
191 $id = range(1, $num_msgs);
193 // if it's not sorted
194 if ($start_msg +
($show_num - 1) < $num_msgs) {
195 $end_msg = $start_msg +
($show_num-1);
197 $end_msg = $num_msgs;
200 if ($end_msg < $start_msg) {
201 $start_msg = $start_msg - $show_num;
202 if ($start_msg < 1) {
207 $real_startMessage = $num_msgs - $start_msg +
1;
208 $real_endMessage = $num_msgs - $start_msg - $show_num +
2;
209 if ($real_endMessage <= 0) {
210 $real_endMessage = 1;
212 $id = array_reverse(range($real_endMessage, $real_startMessage));
215 $msgs_list = sqimap_get_small_header_list($imapConnection, $id, $issent);
216 $flags = sqimap_get_flags_list($imapConnection, $id, $issent);
217 foreach ($msgs_list as $hdr) {
218 $from[] = $hdr->from
;
219 $date[] = $hdr->date
;
220 $subject[] = $hdr->subject
;
222 $priority[] = $hdr->priority
;
224 $size[] = $hdr->size
;
225 $type[] = $hdr->type0
;
231 $end = $start_msg +
$show_num - 1;
232 if ($num_msgs < $show_num) {
233 $end_loop = $num_msgs;
234 } else if ($end > $num_msgs) {
235 $end_loop = $num_msgs - $start_msg +
1;
237 $end_loop = $show_num;
244 while ($j < $end_loop) {
245 if (isset($date[$j])) {
246 $date[$j] = ereg_replace(' ', ' ', $date[$j]);
247 $tmpdate = explode(' ', trim($date[$j]));
249 $tmpdate = $date = array("","","","","","");
252 $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
253 $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']);
254 $messages[$j]['ID'] = $id[$j];
255 $messages[$j]['FROM'] = decodeHeader($from[$j]);
256 $messages[$j]['FROM-SORT'] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
257 $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
258 $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
259 $messages[$j]['TO'] = decodeHeader($to[$j]);
260 $messages[$j]['PRIORITY'] = $priority[$j];
261 $messages[$j]['CC'] = $cc[$j];
262 $messages[$j]['SIZE'] = $size[$j];
263 $messages[$j]['TYPE0'] = $type[$j];
265 # fix SUBJECT-SORT to remove Re:
266 $re_abbr = # Add more here!
267 'vedr|sv|' . # Danish
270 if (eregi( "^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
271 $messages[$j]['SUBJECT-SORT'] = $regs[2];
274 while ($num < count($flags[$j])) {
275 if ($flags[$j][$num] == 'Deleted') {
276 $messages[$j]['FLAG_DELETED'] = true;
277 } else if ($flags[$j][$num] == 'Answered') {
278 $messages[$j]['FLAG_ANSWERED'] = true;
279 } else if ($flags[$j][$num] == 'Seen') {
280 $messages[$j]['FLAG_SEEN'] = true;
281 } else if ($flags[$j][$num] == 'Flagged') {
282 $messages[$j]['FLAG_FLAGGED'] = true;
289 /* Only ignore messages flagged as deleted if we are using a
290 * trash folder or auto_expunge */
291 if (((isset($move_to_trash) && $move_to_trash)
292 ||
(isset($auto_expunge) && $auto_expunge)) && $sort != 6) {
294 /** Find and remove the ones that are deleted */
298 while ($j < $num_msgs) {
299 if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) {
303 $msgs[$i] = $messages[$j];
310 if (!isset($messages)) {
317 // There's gotta be messages in the array for it to sort them.
318 if ($num_msgs > 0 && ! $use_cache) {
319 /** 0 = Date (up) 4 = Subject (up)
320 ** 1 = Date (dn) 5 = Subject (dn)
324 session_unregister("msgs");
325 if (($sort == 0) ||
($sort == 1))
326 $msort = array_cleave ($msgs, 'TIME_STAMP');
327 elseif (($sort == 2) ||
($sort == 3))
328 $msort = array_cleave ($msgs, 'FROM-SORT');
329 elseif (($sort == 4) ||
($sort == 5))
330 $msort = array_cleave ($msgs, 'SUBJECT-SORT');
341 session_register('msort');
343 displayMessageArray($imapConnection, $num_msgs, $start_msg, $msgs, $msort, $mailbox, $sort, $color,$show_num);
344 session_register('msgs');
347 /******************************************************************/
348 /* Generic function to convert the msgs array into an HTML table. */
349 /******************************************************************/
350 function displayMessageArray($imapConnection, $num_msgs, $start_msg, &$msgs, $msort, $mailbox, $sort, $color, $show_num) {
351 global $folder_prefix, $sent_folder;
352 global $imapServerAddress, $data_dir, $username, $use_mailbox_cache;
353 global $index_order, $real_endMessage, $real_startMessage, $checkall;
355 /* If cache isn't already set, do it now. */
356 if (!session_is_registered('msgs')) { session_register('msgs'); }
357 if (!session_is_registered('msort')) { session_register('msort'); }
359 if ($start_msg +
($show_num - 1) < $num_msgs) {
360 $end_msg = $start_msg +
($show_num-1);
362 $end_msg = $num_msgs;
365 if ($end_msg < $start_msg) {
366 $start_msg = $start_msg - $show_num;
367 if ($start_msg < 1) { $start_msg = 1; }
370 $urlMailbox = urlencode($mailbox);
372 do_hook('mailbox_index_before');
374 $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
375 $paginator_str = get_paginator_str($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort);
381 mail_message_listing_beginning
383 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$start_msg",
384 $mailbox, $sort, $msg_cnt_str, $paginator_str, $start_msg);
386 $groupNum = $start_msg %
($show_num - 1);
387 $real_startMessage = $start_msg;
389 if ($end_msg - $start_msg < $show_num - 1) {
390 $end_msg = $end_msg - $start_msg +
1;
392 } else if ($start_msg > $show_num) {
393 $end_msg = $show_num;
397 $endVar = $end_msg +
1;
399 /* Loop through and display the info for each message. */
400 $t = 0; // $t is used for the checkbox number
401 if ($num_msgs == 0) { // if there's no messages in this folder
402 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order) . ">\n";
403 echo " <CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER>\n";
405 } else if ($start_msg == $end_msg) {
406 /* If there's only one message in the box, handle it differently. */
419 } while (isset ($key) && ($k < $i));
420 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
430 } while (isset ($key) && ($k < $i));
433 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
438 } while ($i && $i < $endVar);
442 echo "<table bgcolor=\"$color[9]\" width=100% border=0 cellpadding=1 cellspacing=1>" .
443 "<tr BGCOLOR=\"$color[4]\">" .
444 "<table width=100% BGCOLOR=\"$color[4]\" border=0 cellpadding=1 cellspacing=0><tr><td>$paginator_str</td>".
445 "<td align=right>$msg_cnt_str</td></tr></table>".
448 /** End of message-list table */
450 do_hook('mailbox_index_after');
451 echo "</TABLE></FORM>\n";
455 * Displays the standard message list header. To finish the table,
456 * you need to do a "</table></table>";
458 * $moveURL is the URL to submit the delete/move form to
459 * $mailbox is the current mailbox
460 * $sort is the current sorting method (-1 for no sorting available [searches])
461 * $Message is a message that is centered on top of the list
462 * $More is a second line that is left aligned
464 function mail_message_listing_beginning
465 ($imapConnection, $moveURL, $mailbox = '', $sort = -1,
466 $msg_cnt_str = '', $paginator = ' ', $start_msg = 1) {
467 global $color, $index_order, $auto_expunge, $move_to_trash;
468 global $checkall, $sent_folder, $draft_folder;
469 $urlMailbox = urlencode($mailbox);
471 /****************************************************
472 * This is the beginning of the message list table. *
473 * It wraps around all messages *
474 ****************************************************/
475 echo "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\">\n";
477 echo "<TR BGCOLOR=\"$color[0]\"><TD>";
478 echo " <TABLE BGCOLOR=\"$color[4]\" width=\"100%\" CELLPADDING=\"2\" CELLSPACING=\"0\" BORDER=\"0\"><TR>\n";
479 echo " <TD ALIGN=LEFT>$paginator</TD>\n";
480 echo ' <TD ALIGN=CENTER>' . get_selectall_link($start_msg, $sort) . "</TD>\n";
481 echo " <TD ALIGN=RIGHT>$msg_cnt_str</TD>\n";
482 echo " </TR></TABLE>\n";
485 /** The delete and move options */
486 echo "<TR><TD BGCOLOR=\"$color[0]\">";
488 echo "\n<FORM name=messageList method=post action=\"$moveURL\">\n";
489 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
492 " <TD ALIGN=LEFT VALIGN=CENTER NOWRAP>\n" .
493 ' <SMALL> ' . _("Move selected to:") . "</SMALL>\n" .
495 " <TD ALIGN=RIGHT NOWRAP>\n" .
496 ' <SMALL> ' . _("Transform Selected Messages") . ": </SMALL><BR>\n" .
500 " <TD ALIGN=LEFT VALIGN=CENTER NOWRAP>\n" .
501 ' <SMALL> <TT><SELECT NAME="targetMailbox">';
503 $boxes = sqimap_mailbox_list($imapConnection);
504 for ($i = 0; $i < count($boxes); $i++
) {
505 if (!in_array("noselect", $boxes[$i]['flags'])) {
506 $box = $boxes[$i]['unformatted'];
507 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
508 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
511 echo ' </SELECT></TT></SMALL>';
512 echo " <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"" . _("Move") . "\"></SMALL>\n";
514 echo " <TD ALIGN=RIGHT NOWRAP> \n";
515 if (!$auto_expunge) {
516 echo ' <INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'"> '. _("mailbox") ." \n";
518 echo " <INPUT TYPE=SUBMIT NAME=\"markRead\" VALUE=\"". _("Read")."\">\n";
519 echo " <INPUT TYPE=SUBMIT NAME=\"markUnread\" VALUE=\"". _("Unread")."\">\n";
520 echo " <INPUT TYPE=SUBMIT VALUE=\"". _("Delete") . "\"> \n";
524 do_hook('mailbox_form_before');
527 echo "<TR><TD BGCOLOR=\"$color[0]\">";
528 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=";
529 if ($GLOBALS['alt_index_colors']) {
534 echo " BGCOLOR=\"$color[0]\">";
535 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
537 /* Print the headers. */
538 for ($i=1; $i <= count($index_order); $i++
) {
539 switch ($index_order[$i]) {
540 case 1: /* checkbox */
542 echo ' <TD WIDTH="1%"><B> </B></TD>';
546 if (($mailbox == $sent_folder)
547 ||
($mailbox == $draft_folder)) {
548 echo ' <TD WIDTH="25%"><B>'. _("To") .'</B>';
550 echo ' <TD WIDTH="25%"><B>'. _("From") .'</B>';
553 ShowSortButton($sort, $mailbox, 2, 3);
558 echo ' <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
559 ShowSortButton($sort, $mailbox, 0, 1);
563 case 4: /* subject */
564 echo ' <TD><B>'. _("Subject") .'</B> ';
565 ShowSortButton($sort, $mailbox, 4, 5);
570 echo ' <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
577 /*******************************************************************/
578 /* This function shows the sort button. Isn't this a good comment? */
579 /*******************************************************************/
580 function ShowSortButton($sort, $mailbox, $Up, $Down) {
581 /* Figure out which image we want to use. */
582 if ($sort != $Up && $sort != $Down) {
583 $img = 'sort_none.gif';
585 } elseif ($sort == $Up) {
586 $img = 'up_pointer.gif';
589 $img = 'down_pointer.gif';
593 /* Now that we have everything figured out, show the actual button. */
594 echo ' <a href="right_main.php?newsort=' . $which .
595 '&startMessage=1&mailbox=' . urlencode($mailbox) .
596 '"><IMG SRC="../images/' . $img .
597 '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
600 function get_selectall_link($start_msg, $sort) {
601 global $checkall, $PHP_SELF, $what, $where, $mailbox;
604 ' <script language="JavaScript">' .
606 "function CheckAll() {\n" .
607 " for (var i = 0; i < document.messageList.elements.length; i++) {\n" .
608 " if( document.messageList.elements[i].type == 'checkbox' ) {\n" .
609 " document.messageList.elements[i].checked = !(document.messageList.elements[i].checked);\n".
613 'window.document.write(\'<a href=# onClick="CheckAll();">' . _("Toggle All") . "</a>');\n" .
615 "</script>\n<noscript>\n";
617 $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
618 . "&startMessage=$start_msg&sort=$sort&checkall=";
619 if (isset($checkall) && $checkall == '1') {
625 if (isset($where) && isset($what)) {
626 $result .= '&where=' . urlencode($where) . '&what=' . urlencode($what);
631 if (isset($checkall) && ($checkall == '1')) {
632 $result .= _("Unselect All");
634 $result .= _("Select All");
637 $result .= "</A>\n</noscript>\n";
639 /* Return our final result. */
644 * This function computes the "Viewing Messages..." string.
646 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
647 /* Compute the $msg_cnt_str. */
649 if ($start_msg < $end_msg) {
650 $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"), $start_msg, $end_msg, $num_msgs);
651 } else if ($start_msg == $end_msg) {
652 $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
657 /* Return our result string. */
662 * This function computes the paginator string.
664 function get_paginator_str
665 ($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort) {
666 global $username, $data_dir, $use_mailbox_cache, $color;
668 $nextGroup = $start_msg +
$show_num;
669 $prevGroup = $start_msg - $show_num;
678 if (($nextGroup <= $num_msgs) && ($prevGroup >= 0)) {
679 $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
680 $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
681 } else if (($nextGroup > $num_msgs) && ($prevGroup >= 0)) {
682 $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
683 $rMore = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
684 } else if (($nextGroup <= $num_msgs) && ($prevGroup < 0)) {
685 $lMore = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
686 $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
689 $lMore .= ' | ';
692 /* Page selector block. Following code computes page links. */
694 if (!getPref($data_dir, $username, 'page_selector')
695 && ($num_msgs > $show_num)) {
696 $j = intval( $num_msgs / $show_num ); // Max pages
697 $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX
) );
698 if ($num_msgs %
$show_num <> 0 ) {
701 $start_msg = min( $start_msg, $num_msgs );
702 $p = intval( $start_msg / $show_num ) +
1;
706 $start = ( ($pg-1) * $show_num ) +
1;
707 $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
708 "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
711 $mMore .= "<B>$p</B> ";
715 $start = ( ($pg-1) * $show_num ) +
1;
716 $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start"
717 . "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
720 $mMore .= ' | ';
723 /* Return the resulting string. */
724 if( $lMore . $mMore . $rMore == '' ) {
727 return ($lMore . $mMore . $rMore);
730 function processSubject($subject) {
731 // Shouldn't ever happen -- caught too many times in the IMAP functions
733 return _("(no subject)");
735 if (strlen($subject) <= 55)
738 $ent_strlen=strlen($subject);
741 // see if this is entities-encoded string
742 // If so, Iterate through the whole string, find out
743 // the real number of characters, and if more
744 // than 55, substr with an updated trim value.
745 while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
746 ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
748 $trim_val +
= ($ent_loc_end-$ent_loc)+
1;
749 $ent_strlen -= $ent_loc_end-$ent_loc;
750 $ent_offset = $ent_loc_end+
1;
753 if ($ent_strlen <= 55)
756 return substr($subject, 0, $trim_val) . '...';