off-by-one: when strlen == trim_at, we also don't want to print ...
[squirrelmail.git] / functions / mailbox_display.php
index e72c3c732893b1dcf97715267e3d4193d62905d4..ae678a786ed8912b45619f933019d1f4c3672e3c 100644 (file)
@@ -17,8 +17,12 @@ require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'class/html.class.php');
 require_once(SM_PATH . 'functions/imap_mailbox.php');
 
 require_once(SM_PATH . 'class/html.class.php');
 require_once(SM_PATH . 'functions/imap_mailbox.php');
 
-/* Default value for page_selector_max. */
+/* Constants:
+ *   PG_SEL_MAX:   default value for page_selector_max
+ *   SUBJ_TRIM_AT: the length at which we trim off subjects
+ */
 define('PG_SEL_MAX', 10);
 define('PG_SEL_MAX', 10);
+define('SUBJ_TRIM_AT', 55);
 
 function elapsed($start)
 {
 
 function elapsed($start)
 {
@@ -1178,17 +1182,20 @@ function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
 function processSubject($subject, $threadlevel = 0) {
     global $languages, $squirrelmail_language;
     /* Shouldn't ever happen -- caught too many times in the IMAP functions */
 function processSubject($subject, $threadlevel = 0) {
     global $languages, $squirrelmail_language;
     /* Shouldn't ever happen -- caught too many times in the IMAP functions */
-    if ($subject == '')
+    if ($subject == '') {
         return _("(no subject)");
         return _("(no subject)");
+    }
 
 
-    $trim_at = 55;
+    $trim_at = SUBJ_TRIM_AT;
 
     /* if this is threaded, subtract two chars per indentlevel */
 
     /* if this is threaded, subtract two chars per indentlevel */
-    if($threadlevel > 0 && $threadlevel <= 10)
+    if($threadlevel > 0 && $threadlevel <= 10) {
         $trim_at -= (2*$threadlevel);
         $trim_at -= (2*$threadlevel);
+    }
 
 
-    if (strlen($subject) <= $trim_at)
+    if (strlen($subject) <= $trim_at) {
         return $subject;
         return $subject;
+    }
 
     $ent_strlen = $orig_len = strlen($subject);
     $trim_val = $trim_at - 5;
 
     $ent_strlen = $orig_len = strlen($subject);
     $trim_val = $trim_at - 5;
@@ -1223,7 +1230,7 @@ function processSubject($subject, $threadlevel = 0) {
     }
 
     // only print '...' when we're actually dropping part of the subject
     }
 
     // only print '...' when we're actually dropping part of the subject
-    if(strlen($subject) < $trim_val) {
+    if(strlen($subject) <= $trim_val) {
         return $subject;
     } else {
         return substr($subject, 0, $trim_val) . '...';
         return $subject;
     } else {
         return substr($subject, 0, $trim_val) . '...';