From: Florent Bruneau Date: Tue, 10 May 2011 14:38:50 +0000 (+0200) Subject: Allow more precise description of the read/unread messages through a X-Git-Url: http://git.polytechnique.org/?p=banana.git;a=commitdiff_plain;h=2b974d09ad89f90c04fe281ef653a34bf6d2c47f Allow more precise description of the read/unread messages through a user-defined custom hook. Signed-off-by: Florent Bruneau --- diff --git a/banana/nntp.inc.php b/banana/nntp.inc.php index 910075d..3ac4670 100644 --- a/banana/nntp.inc.php +++ b/banana/nntp.inc.php @@ -93,7 +93,20 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface if (!is_array($new)) { $new = 0; } else { - $new = count($new); + $c = count($new); + if ($c > 0 && function_exists('hook_listReadMessages')) { + $msgs = hook_listReadMessages($group); + if (is_array($msgs)) { + foreach ($msgs as $msg) { + if (is_numeric($msg)) { + $c--; + } else if (in_array($msg, $new)) { + $c--; + } + } + } + } + $new = $c; } $desc['msgnum'] = $msgnum; $desc['unread'] = $new; diff --git a/banana/spool.inc.php b/banana/spool.inc.php index b1fcfb7..0c8affd 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -302,6 +302,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]; + } + $this->markAsRead($msg); + } + } } public function setMode($mode)