Allow more precise description of the read/unread messages through a
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 10 May 2011 14:38:50 +0000 (16:38 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 10 May 2011 14:38:50 +0000 (16:38 +0200)
user-defined custom hook.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
banana/nntp.inc.php
banana/spool.inc.php

index 910075d..3ac4670 100644 (file)
@@ -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;
index b1fcfb7..0c8affd 100644 (file)
@@ -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)