Some fixes in "unread" state handling
[banana.git] / banana / spool.inc.php
index 8bb5537..73641e6 100644 (file)
@@ -85,10 +85,10 @@ class BananaSpool
         $this->group      = $group;
     }
 
-    public static function getSpool($group, $since = 0)
+    public static function getSpool($group, $since = 0, $clean = false)
     {
         if (!is_null(Banana::$spool) && Banana::$spool->group == $group) {
-            $spool = Banana::$spool;
+            $spool =& Banana::$spool;
         } else {
             $spool = BananaSpool::readFromFile($group);
         }        
@@ -97,6 +97,9 @@ class BananaSpool
         }
         Banana::$spool =& $spool;
         $spool->build();
+        if ($clean) {
+            $spool->markAllAsRead();
+        }
         $spool->updateUnread($since);
         return $spool;
     }
@@ -243,7 +246,7 @@ class BananaSpool
         }
 
         $newpostsids = Banana::$protocole->getNewIndexes($since);
-        
+
         if (empty($newpostsids)) {
             return;
         }
@@ -518,7 +521,7 @@ class BananaSpool
             for ($i = 0; $i < $pos ; $i++) {
                 $ndx += $this->overview[$this->overview[$id_parent]->children[$i]]->desc;
             }
-            $ndx++; //noeud père
+            $ndx++; //noeud père
 
             $id_cur = $id_parent;
         }
@@ -687,5 +690,5 @@ class BananaSpool
     }    
 }
 
-// vim:set et sw=4 sts=4 ts=4
+// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
 ?>