X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=ddbb61298993fa2fd523b8449f0325b4419712ee;hb=f0621c2dd59dfa99a8787b94fa019b6d7407a217;hp=2151cf3ee79edbd3c8758eccd76c6ea7fa133e65;hpb=90bc0b93cb30d88fa4199370b902ca8671895f7d;p=squirrelmail.git diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 2151cf3e..ddbb6129 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -31,42 +31,42 @@ if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) { $flag = ""; - $flag_end = ''; + $flag_end = ''; } else { $flag = ''; - $flag_end = ''; + $flag_end = ''; } - if (!isset($msg['FLAG_SEEN']) && $msg['FLAG_SEEN'] == false) + if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) { $bold = ''; - $bold_end = ''; + $bold_end = ''; } else { $bold = ''; - $bold_end = ''; + $bold_end = ''; } if ($mailbox == $sent_folder) { $italic = ''; - $italic_end = ''; + $italic_end = ''; } else { $italic = ''; - $italic_end = ''; + $italic_end = ''; } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { $fontstr = ""; - $fontstr_end = ''; + $fontstr_end = ''; } else { $fontstr = ''; - $fontstr_end = ''; + $fontstr_end = ''; } for ($i=0; $i < count($message_highlight_list); $i++) { @@ -108,22 +108,42 @@ break; case 4: # subject echo " $bold"; - if (! isset($search_stuff)) - $search_stuff = ''; - echo "$flag"; - if (strlen($subject) > 55) - echo substr($subject, 0, 50) . '...'; - else - echo $subject; + if (! isset($search_stuff)) { $search_stuff = ''; } + echo "$flag"; + if (strlen($subject) > 55){ + $ent_strlen=strlen($subject); + $trim_val=50; + // see if this is entities-encoded string + if (is_int(strpos($subject, "&#"))){ + // Yes. Iterate through the whole string, find out + // the real number of characters, and if more + // than 55, substr with an updated trim value. + $ent_offset=0; + $ent_count=0; + do { + $ent_loc = strpos($subject, "&#", $ent_offset); + $ent_loc_end = strpos($subject, ";", $ent_offset); + if ($ent_loc_end){ + $trim_val += ($ent_loc_end-$ent_loc)+1; + $ent_strlen -= $ent_loc_end-$ent_loc; + $ent_offset = $ent_loc_end+1; + $ent_count++; + } else $ent_loc=false; + } while (is_int($ent_loc)); + } + if ($ent_strlen>55) echo substr($subject, 0, $trim_val) . '...'; + else echo $subject; + } else echo $subject; + echo "$flag_end$bold_end\n"; break; case 5: # flags $stuff = false; echo " \n"; if (isset($msg['FLAG_ANSWERED']) && - $msg['FLAG_ANSWERED'] == true) { + $msg['FLAG_ANSWERED'] == true) { echo "A\n"; $stuff = true; } @@ -231,13 +251,22 @@ $j = 0; if ($sort == 6) { $end = $startMessage + $show_num - 1; + if ($numMessages < $show_num) + $end_loop = $numMessages; + else + $end_loop = $show_num; } else { $end = $numMessages; + $end_loop = $end; } - if ($end > $numMessages) $end = $numMessages; - while ($j < $end) { - $date[$j] = ereg_replace(' ', ' ', $date[$j]); - $tmpdate = explode(' ', trim($date[$j])); + if ($end > $numMessages) $end = $numMessages; + while ($j < $end_loop) { + if (isset($date[$j])) { + $date[$j] = ereg_replace(' ', ' ', $date[$j]); + $tmpdate = explode(' ', trim($date[$j])); + } else { + $tmpdate = $date = array("","","","","",""); + } $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate); $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']); @@ -281,13 +310,13 @@ /* Only ignore messages flagged as deleted if we are using a * trash folder or auto_expunge */ if (((isset($move_to_trash) && $move_to_trash) - || (isset($auto_expunge) && $auto_expunge)) && $sort != 6) + || (isset($auto_expunge) && $auto_expunge)) && $sort != 6) { /** Find and remove the ones that are deleted */ $i = 0; $j = 0; while ($j < $numMessages) { - if ($messages[$j]['FLAG_DELETED'] == true) { + if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) { $j++; continue; } @@ -298,8 +327,8 @@ } $numMessages = $i; } else { - if (! isset($messages)) - $messages = array(); + if (! isset($messages)) + $messages = array(); $msgs = $messages; } } @@ -421,7 +450,7 @@ else $i = 1; reset($msort); - $k = 0; + $k = 0; do { $key = key($msort); next($msort); @@ -432,7 +461,7 @@ $i = $startMessage; reset($msort); - $k = 0; + $k = 0; do { $key = key($msort); next($msort); @@ -455,10 +484,7 @@ echo '
'; echo "$More\n"; if (!$startMessage) $startMessage=1; - if ( $checkall == '1') - echo "\n" . _("Unselect All") . "\n"; - else - echo "\n" . _("Select All") . "\n"; + ShowSelectAllLink($startMessage, $sort); echo '
'; echo ''; @@ -493,10 +519,7 @@ echo ""; echo '
'; echo "$More\n"; - if ( $checkall == '1') - echo "\n" . _("Unselect All") . "\n"; - else - echo "\n" . _("Select All") . "\n"; + ShowSelectAllLink($startMessage, $sort); echo '
'; echo ''; @@ -515,13 +538,11 @@ $boxes = sqimap_mailbox_list($imapConnection); for ($i = 0; $i < count($boxes); $i++) { - if ($boxes[$i]['flags'][0] != 'noselect' && - $boxes[$i]['flags'][1] != 'noselect' && - $boxes[$i]['flags'][2] != 'noselect') { + if (!in_array("noselect", $boxes[$i]['flags'])) { $box = $boxes[$i]['unformatted']; $box2 = replace_spaces($boxes[$i]['unformatted-disp']); echo " \n"; - } + } } echo '
'; echo ' \n"; @@ -598,4 +619,25 @@ } echo "\n"; } + + function ShowSelectAllLink($startMessage, $sort) + { + global $checkall, $PHP_SELF, $what, $where, $mailbox; + + echo "\n"; + if (isset($checkall) && $checkall == '1') + echo _("Unselect All"); + else + echo _("Select All"); + echo "\n"; + } + ?>