X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fspool.inc.php;h=ace19f7277dde077404d0aba500faba7a184384c;hb=ade32c5593c555591eb5cf859ea64b8ef7fdaaf8;hp=6899532f8dd7a75a196e173eca4b9ab3580a72dd;hpb=8a30c7d63d9ef1e4dd91c7b16d1c1571f71e9b04;p=banana.git diff --git a/banana/spool.inc.php b/banana/spool.inc.php index 6899532..ace19f7 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -54,28 +54,19 @@ class BananaSpoolHead */ public function __construct($id, array &$message) { + list($name, $from) = BananaMessage::extractMail($message['from']); $this->id = $id; $this->msgid = @$message['message-id']; $this->date = $message['date']; $this->subject = @$message['subject']; $this->from = $message['from']; - $this->color = sprintf('#%06x', abs(crc32($this->from) % 0xffffff)); + $this->color = sprintf('#%06x', abs(crc32($from) % 0xffffff)); $this->desc = 1; $this->isread = true; $this->descunread = 0; - if (preg_match("/^([^ ]+@[^ ]+) \((.*)\)$/", $this->from, $regs)) { - $this->name = $regs[2]; - } - if (preg_match("/^\"?([^<>\"]+)\"? +<(.+@.+)>$/", $this->from, $regs)) { - $this->name = preg_replace("/^'(.*)'$/", '\1', $regs[1]); - $this->name = stripslashes($this->name); - } - if ($this->name) { - $this->name = preg_replace("/\\\(\(|\))/","\\1", $this->name); - } else if (preg_match("/([^< ]+)@([^> ]+)/", $this->from, $regs)) { - $this->name = $regs[1]; - } else { - $this->name = 'Anonymous'; + $this->name = $name; + if ($name === $from) { + $this->name = 'Anonymous'; } } } @@ -302,6 +293,22 @@ class BananaSpool } } $this->unreadnb += count($newpostsids); + + if (function_exists('hook_listReadMessages')) { + $msgs = hook_listReadMessages($this->group); + if (!is_array($msgs)) { + return; + } + foreach ($msgs as $msg) { + if (!is_numeric($msg)) { + if (!isset($this->ids[$msg])) { + continue; + } + $msg = $this->ids[$msg]->id; + } + $this->markAsRead($msg); + } + } } public function setMode($mode) @@ -501,6 +508,9 @@ class BananaSpool if (empty($subject)) { $subject = _b_('(pas de sujet)'); } + if (mb_strlen($subject) > 100) { + $subject = mb_substr($subject, 0, 99) . '…'; + } if ($head->id !== Banana::$artid) { $subject = Banana::$page->makeLink(Array('group' => $this->group, 'artid' => $head->id, 'text' => $subject, 'popup' => $popup));