Add shortkey browsing
[banana.git] / banana / spool.inc.php
index c4c2aba..de4e598 100644 (file)
@@ -397,17 +397,26 @@ class BananaSpool
     {
         $res  = '<table class="bicol banana_thread" cellpadding="0" cellspacing="0">';
        
-        $new  = '<div class="banana_action">'
-              . makeImgLink(Array('group'  => $this->group,
-                                  'action' => 'new'),
-                            'post.gif',
-                            _b_('Nouveau message'));
-        $new .= '</div>';
-        
         if (is_null($_ref)) {
-            $res .= '<tr><th>' . _b_('Date') . '</th>';
-            $res .= '<th>' . $new . _b_('Sujet') . '</th>';
-            $res .= '<th>' . _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),
@@ -571,7 +580,10 @@ class BananaSpool
             return $id;
         }
         foreach ($this->overview[$id]->children as $child) {
-            return $this->_nextUnread($child);
+            $unread = $this->_nextUnread($child);
+            if (!is_null($unread)) {
+                return $unread;
+            }    
         }
         return null;
     }
@@ -579,21 +591,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 {
@@ -611,7 +625,7 @@ class BananaSpool
                 }
             }
             $cur = $parent;
-        }
+        } while(!is_null($cur));
         return null;
     }    
 }