Truncates subjects when they are too long (Closes #959).
[banana.git] / banana / spool.inc.php
index efb2a04..2a9ec6d 100644 (file)
@@ -164,7 +164,7 @@ class BananaSpool
         return $spool;
     }
 
-    private function compare(&$a, &$b)
+    private function compare($a, $b)
     {
         return ($b->date - $a->date);
     }
@@ -430,6 +430,7 @@ class BananaSpool
 
         // Remove from the message tree
         if (!is_null($parent)) {
+            $time = time();
             foreach ($parent->children as $key=>&$child) {
                 if ($child === $overview) {
                     unset($parent->children[$key]);
@@ -437,12 +438,12 @@ class BananaSpool
                 }
             }
             if (sizeof($overview->children)) {
-                $parent->children = array_merge($parent->children, $overview->children);
                 foreach ($overview->children as &$child) {
+                    $parent->children[] =& $child;
+                    $child->time   = $time;
                     $child->parent =& $parent;
                 }
             }
-            $time = time();
             while (!is_null($parent)) {
                 $parent->desc--;
                 $parent->time = $time;
@@ -467,7 +468,7 @@ class BananaSpool
         }
     }
 
-    public function formatDate(BananaSpoolHead &$head)
+    public function formatDate(BananaSpoolHead $head)
     {
         $stamp  = $head->date;
         $today  = intval(time() / (24*3600));
@@ -487,7 +488,7 @@ class BananaSpool
         return strftime($format, $stamp);
     }
 
-    public function formatSubject(BananaSpoolHead &$head)
+    public function formatSubject(BananaSpoolHead $head)
     {
         $subject = $popup = $head->subject;
         $popup = $subject;
@@ -500,6 +501,9 @@ class BananaSpool
         if (empty($subject)) {
             $subject = _b_('(pas de sujet)');
         }
+        if (strlen($subject) > 100) {
+            $subject = substr($subject, 0, 99) . '…';
+        }
         if ($head->id !== Banana::$artid) {
             $subject = Banana::$page->makeLink(Array('group' => $this->group, 'artid' => $head->id,
                                                      'text'  => $subject, 'popup' => $popup));
@@ -507,7 +511,7 @@ class BananaSpool
         return $subject . $link;
     }
 
-    public function formatFrom(BananaSpoolHead &$head)
+    public function formatFrom(BananaSpoolHead $head)
     {
         return BananaMessage::formatFrom($head->from);
     }
@@ -651,7 +655,7 @@ class BananaSpool
     /** Look for an unread message in the thread rooted by the message
      * @param id INTEGER message number
      */
-    private function _nextUnread(BananaSpoolHead &$cur)
+    private function _nextUnread(BananaSpoolHead $cur)
     {
         if (!$cur->isread) {
             return $cur->id;