- if (count($newpostsids)) {
- switch ($mode) {
- case 1:
- foreach ($this->roots as $k=>$i) {
- if ($this->overview[$i]->descunread==0) {
- $this->killdesc($i);
- unset($this->roots[$k]);
- }
- }
- break;
+ /** Get the tree associated to a given id
+ */
+ public function &getTree($id)
+ {
+ return BananaTree::build($id)->show();
+ }
+
+ /** Mark the given id as read
+ * @param id MSGNUM of post
+ */
+ public function markAsRead($id)
+ {
+ $overview =& $this->overview[$id];
+ if (!$overview->isread) {
+ $overview->isread = true;
+ $this->unreadnb--;
+ while (!is_null($overview)) {
+ $overview->descunread--;
+ $overview =& $overview->parent;
+ }
+ }
+ }
+
+ /** Mark all unread messages as read
+ */
+ public function markAllAsRead(array &$array = null)
+ {
+ if (!$this->unreadnb) {
+ return;
+ }
+ if (is_null($array) && !empty($this->roots)) {
+ $array =& $this->roots;
+ } elseif (is_null($array)) {
+ return;
+ }
+ foreach ($array as &$msg) {
+ if (!$msg->isread) {
+ $this->markAsRead($msg->id);
+ if (!$this->unreadnb) {
+ return;