From: x2003bruneau Date: Thu, 10 Aug 2006 12:41:10 +0000 (+0000) Subject: Add a 'next unread message' button in spool view X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=27db62ebb3df78e475e8c11688c914fa224d6835;p=banana.git Add a 'next unread message' button in spool view git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@134 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/spool.inc.php b/banana/spool.inc.php index 220924f..9b634a0 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -405,9 +405,25 @@ class BananaSpool $new .= ''; if (is_null($_ref)) { - $res .= '' . _b_('Date') . ''; - $res .= '' . $new . _b_('Sujet') . ''; - $res .= '' . _b_('Auteur') . ''; + $next = $this->nextUnread(); + if (!is_null($next)) { + $next = '
' + . makeImgLink(Array('group' => $this->group, + 'artid' => $next), + 'next_unread.gif', + _b_('Message non-lu suivant')) + . '
'; + } + $new = '
' + . makeImgLink(Array('group' => $this->group, + 'action' => 'new'), + 'post.gif', + _b_('Nouveau message')) + . '
'; + + $res .= '' . $next . _b_('Date') . ''; + $res .= '' . _b_('Sujet') . ''; + $res .= '' . $new . _b_('Auteur') . ''; } else { $res .= '' . _b_('Aperçu de ') . makeHREF(Array('group' => $this->group), @@ -582,21 +598,23 @@ class BananaSpool /** Find next unread message * @param id INTEGER message number */ - function nextUnread($id) + function nextUnread($id = null) { - // Look in message children - foreach ($this->overview[$id]->children as $child) { - $next = $this->_nextUnread($child); - if (!is_null($next)) { - return $next; + if (!is_null($id)) { + // Look in message children + foreach ($this->overview[$id]->children as $child) { + $next = $this->_nextUnread($child); + if (!is_null($next)) { + return $next; + } } } // Look in current thread $cur = $id; - while (!is_null($cur)) { - $parent = $this->overview[$cur]->parent; - $ok = false; + do { + $parent = is_null($cur) ? null : $this->overview[$cur]->parent; + $ok = is_null($cur) ? true : false; if (!is_null($parent)) { $array = &$this->overview[$parent]->children; } else { @@ -614,7 +632,7 @@ class BananaSpool } } $cur = $parent; - } + } while(!is_null($cur)); return null; } }