$msgids = $banana->nntp->xhdr('Message-ID', $arg);
$refs = $banana->nntp->xhdr('References', $arg);
- if (is_array($this->ids)) {
+ if (is_array(@$this->ids)) {
$this->ids = array_merge($this->ids, array_flip($msgids));
} else {
$this->ids = array_flip($msgids);
foreach ($msgids as $id=>$msgid) {
$msg = new BananaSpoolHead($dates[$id], $subjects[$id], $froms[$id]);
- $refs[$id] = str_replace('><', '> <', $refs[$id]);
+ $refs[$id] = str_replace('><', '> <', @$refs[$id]);
$msgrefs = preg_split("/[ \t]/", strtr($refs[$id], $this->ids));
$parents = preg_grep('/^\d+$/', $msgrefs);
$msg->parent = array_pop($parents);
{
$res = '<table class="bicol banana_thread" cellpadding="0" cellspacing="0">';
- $new = '<div class="banana_action">'
- . makeImgLink(Array('group' => $this->group,
- 'action' => 'new'),
- 'post.gif',
- 'Nouveau message');
- $new .= '</div>';
-
if (is_null($_ref)) {
- $res .= '<tr><th>'._b_('Date').'</th>';
- $res .= '<th>'._b_('Sujet').'</th>';
- $res .= '<th>'. $new . _b_('Auteur').'</th></tr>';
+ $next = $this->nextUnread();
+ if (!is_null($next)) {
+ $next = '<div class="banana_menu">'
+ . makeImgLink(Array('group' => $this->group,
+ 'artid' => $next),
+ 'next_unread.gif',
+ _b_('Message non-lu suivant'), null, null, null, 'u')
+ . '</div>';
+ }
+ $new = '<div class="banana_action">'
+ . makeImgLink(Array('group' => $this->group,
+ 'action' => 'new'),
+ 'post.gif',
+ _b_('Nouveau message'), null, null, null, 'p')
+ . '</div>';
+
+ $res .= '<tr><th>' . $next . _b_('Date') . '</th>';
+ $res .= '<th>' . _b_('Sujet') . '</th>';
+ $res .= '<th>' . $new . _b_('Auteur') . '</th></tr>';
} else {
$res .= '<tr><th colspan="3">' . _b_('Aperçu de ')
. makeHREF(Array('group' => $this->group),
}
return null;
}
+
+ /** Look for an unread message in the thread rooted by the message
+ * @param id INTEGER message number
+ */
+ function _nextUnread($id)
+ {
+ if (!$this->overview[$id]->isread) {
+ return $id;
+ }
+ foreach ($this->overview[$id]->children as $child) {
+ $unread = $this->_nextUnread($child);
+ if (!is_null($unread)) {
+ return $unread;
+ }
+ }
+ return null;
+ }
+
+ /** Find next unread message
+ * @param id INTEGER message number
+ */
+ function nextUnread($id = null)
+ {
+ 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;
+ 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 {
+ $array = &$this->roots;
+ }
+ foreach ($array as $child) {
+ if ($ok) {
+ $next = $this->_nextUnread($child);
+ if (!is_null($next)) {
+ return $next;
+ }
+ }
+ if ($child == $cur) {
+ $ok = true;
+ }
+ }
+ $cur = $parent;
+ } while(!is_null($cur));
+ return null;
+ }
}
// vim:set et sw=4 sts=4 ts=4