From: x2003bruneau Date: Tue, 14 Aug 2007 22:31:45 +0000 (+0000) Subject: Close #707: Show all messages of the forum if all of them are X-Git-Tag: 1.8~39 X-Git-Url: http://git.polytechnique.org/?p=banana.git;a=commitdiff_plain;h=64f89fae2e2ce5f37a966f3a95e94c4e35a72e35 Close #707: Show all messages of the forum if all of them are marked as read. Changelog | 4 ++++ banana/banana.inc.php.in | 26 +++++++++++++------------- banana/spool.inc.php | 32 ++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 27 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@271 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/Changelog b/Changelog index 5fb7d49..2ee3c7f 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +Wed, 15 Aug 2007 Florent Bruneau + + * Bugfix: don't show an empty forum when it contains no unread post + Sat, 23 Jun 2007 Florent Bruneau * Add the year of the post in the spool for post older than 90 days diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index 2e5c633..3ca5da6 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -47,7 +47,7 @@ class Banana ### Message display ### static public $msgshow_headers = array('from', 'newsgroups', 'followup-to', 'to', 'cc', 'reply-to', 'organization', 'date', 'references', 'in-reply-to'); - static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', + static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', 'text/html', 'text/plain', 'text/enriched', 'text', 'message'); static public $msgshow_xface = true; static public $msgshow_wrap = 80; @@ -109,7 +109,7 @@ class Banana ####### # Constants -####### +####### // Actions const ACTION_BOX_NEEDED = 1; // mask @@ -173,7 +173,7 @@ class Banana $classname = 'Banana' . $protocole; if (!class_exists($classname)) { Banana::load($protocole); - } + } Banana::$protocole = new $classname(Banana::$group); // build the page @@ -216,7 +216,7 @@ class Banana Banana::$action = Banana::ACTION_BOX_FEED; return; } - + // Look for the action to execute if (is_null(Banana::$group)) { if ($action == 'subscribe') { @@ -226,7 +226,7 @@ class Banana } return; } - + if (is_null(Banana::$artid)) { if ($action == 'new') { Banana::$action = Banana::ACTION_MSG_NEW; @@ -257,7 +257,7 @@ class Banana { // Configure locales setlocale(LC_ALL, Banana::$profile['locale']); - + // Check if the state is valid if (Banana::$protocole->lastErrNo()) { return Banana::$page->kill(_b_('Une erreur a été rencontrée lors de la connexion au serveur') . '
' @@ -268,7 +268,7 @@ class Banana } if (Banana::$action & Banana::ACTION_BOX_NEEDED) { if(Banana::$boxpattern && !preg_match('/' . Banana::$boxpattern . '/i', Banana::$group)) { - Banana::$page->setPage('group'); + Banana::$page->setPage('group'); return Banana::$page->kill(_b_("Ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder")); } } @@ -319,7 +319,7 @@ class Banana $headers[$hdrs['dest']] = $dest; if ($reply) { $headers[$hdrs['reply']] = $reply; - } + } $headers['Subject'] = $subject; $msg = BananaMessage::newMessage($headers, $body); if (Banana::$protocole->send($msg)) { @@ -394,9 +394,9 @@ class Banana { Banana::load('feed'); if (Banana::$group) { - if (Banana::$feed_updateOnDemand) { - $this->loadSpool(Banana::$group); - } + if (Banana::$feed_updateOnDemand) { + $this->loadSpool(Banana::$group); + } $feed =& BananaFeed::getFeed(); $feed->toXML(); } @@ -475,7 +475,7 @@ class Banana if (Banana::$spool_boxlist) { $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); Banana::$page->assign('groups', $groups); - } + } Banana::$page->assign_by_ref('message', $msg); Banana::$page->assign('extimages', Banana::$msgshow_hasextimages); Banana::$page->assign('headers', Banana::$msgshow_headers); @@ -668,7 +668,7 @@ class Banana print "\n"; } } - + /**************************************************************************/ /* Private functions */ /**************************************************************************/ diff --git a/banana/spool.inc.php b/banana/spool.inc.php index 19cc647..4213e5b 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -94,7 +94,7 @@ class BananaSpool $spool =& Banana::$spool; } else { $spool =& BananaSpool::readFromFile($group); - } + } if (is_null($spool)) { $spool = new BananaSpool($group); } @@ -151,7 +151,7 @@ class BananaSpool if ($this->mode == Banana::SPOOL_ALL) { file_put_contents($file, serialize($this)); - } + } } private function build() @@ -173,12 +173,12 @@ class BananaSpool } $clean = $this->clean($first, $last, $msgnum); $update = $this->update($first, $last, $msgnum); - + if ($clean || $update) { $this->saveToFile(); } } - + private function clean(&$first, &$last, $msgnum) { $do_save = false; @@ -200,7 +200,7 @@ class BananaSpool private function update(&$first, &$last, $msgnum) { - if ($first > $last || !$msgnum) { + if ($first > $last || !$msgnum) { return false; } @@ -239,7 +239,7 @@ class BananaSpool $p = $this->overview[$p]->parent; } else { $p = null; - } + } } } } @@ -281,6 +281,10 @@ class BananaSpool $this->mode = $mode; switch ($mode) { case Banana::SPOOL_UNREAD: + $num = max(array_keys($this->overview)); + if ($this->overview[$num]->isread) { + break; + } foreach ($this->roots as $k=>$i) { if ($this->overview[$i]->descunread == 0) { $this->killdesc($i); @@ -387,7 +391,7 @@ class BananaSpool if ($msgid !== false) { unset($this->roots[$msgid]); } - + if ($write) { $this->saveToFile(); } @@ -418,7 +422,7 @@ class BananaSpool * @param $_index INTEGER linear number of post in the tree * @param $_first INTEGER linear number of first post displayed * @param $_last INTEGER linear number of last post displayed - * @param $_ref STRING MSGNUM of current post + * @param $_ref STRING MSGNUM of current post * @param $_pfx_node STRING prefix used for current node * @param $_pfx_end STRING prefix used for children of current node * @param $_head BOOLEAN true if first post in thread @@ -429,7 +433,7 @@ class BananaSpool { static $spfx_f, $spfx_n, $spfx_Tnd, $spfx_Lnd, $spfx_snd, $spfx_T, $spfx_L, $spfx_s, $spfx_e, $spfx_I; if (!isset($spfx_f)) { - $spfx_f = Banana::$page->makeImg(Array('img' => 'k1', 'alt' => 'o', 'height' => 21, 'width' => 9)); + $spfx_f = Banana::$page->makeImg(Array('img' => 'k1', 'alt' => 'o', 'height' => 21, 'width' => 9)); $spfx_n = Banana::$page->makeImg(Array('img' => 'k2', 'alt' => '*', 'height' => 21, 'width' => 9)); $spfx_Tnd = Banana::$page->makeImg(Array('img' => 'T-direct', 'alt' => '+', 'height' => 21, 'width' => 12)); $spfx_Lnd = Banana::$page->makeImg(Array('img' => 'L-direct', 'alt' => '`', 'height' => 21, 'width' => 12)); @@ -475,7 +479,7 @@ class BananaSpool if ($hc) { return $res; } - } + } $_index ++; $children = $overview->children; @@ -546,7 +550,7 @@ class BananaSpool $id_parent = $this->overview[$id_cur]->parent; if (is_null($id_parent)) break; $pos = array_search($id_cur, $this->overview[$id_parent]->children); - + for ($i = 0; $i < $pos ; $i++) { $ndx += $this->overview[$this->overview[$id_parent]->children[$i]]->desc; } @@ -665,7 +669,7 @@ class BananaSpool if (count($this->overview[$id]->children) != 0) { return $this->overview[$id]->children[0]; } - + $cur = $id; while (true) { $parent = $this->overview[$cur]->parent; @@ -698,7 +702,7 @@ class BananaSpool $unread = $this->_nextUnread($child); if (!is_null($unread)) { return $unread; - } + } } return null; } @@ -746,7 +750,7 @@ class BananaSpool $cur = $parent; } while(!is_null($cur)); return null; - } + } } // vim:set et sw=4 sts=4 ts=4 enc=utf-8: