$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]);
- if (isset($ref[$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);
- $msg->parent_direct = preg_match('/^\d+$/', array_pop($msgrefs));
- } else {
- $msg->parent = null;
- $msg->parent_direct = null;
- }
+ $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);
+ $msg->parent_direct = preg_match('/^\d+$/', array_pop($msgrefs));
if (isset($this->overview[$id])) {
$msg->desc = $this->overview[$id]->desc;
}
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) {
+ return $this->_nextUnread($child);
+ }
+ return null;
+ }
+
+ /** Find next unread message
+ * @param id INTEGER message number
+ */
+ function nextUnread($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;
+ 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;
+ }
+ return null;
+ }
}
// vim:set et sw=4 sts=4 ts=4