diff --git a/_sakura/components/Forum.php b/_sakura/components/Forum.php index 2163551..7546f8a 100644 --- a/_sakura/components/Forum.php +++ b/_sakura/components/Forum.php @@ -80,7 +80,12 @@ class Forum public function getThreads() { // Get all rows with the forum id for this forum - $threadRows = Database::fetch('topics', true, ['forum_id' => [$this->id, '=']], ['topic_last_reply', true]); + $announcements = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['2', '=']], ['topic_last_reply', true]); + $sticky = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['1', '=']], ['topic_last_reply', true]); + $regular = Database::fetch('topics', true, ['forum_id' => [$this->id, '='], 'topic_type' => ['0', '=']], ['topic_last_reply', true]); + + // Combine them into one array + $threadRows = array_merge($announcements, $sticky, $regular); // Create a storage array $threads = []; @@ -135,6 +140,18 @@ class Forum // Read status public function unread($user) { + // Return false if the user id is less than 1 + if ($user < 1) { + return false; + } + + // Check forums + foreach ($this->forums as $forum) { + if ($forum->unread($user)) { + return true; + } + } + // Check each thread foreach ($this->threads as $thread) { if ($thread->unread($user)) { @@ -145,4 +162,20 @@ class Forum // Return false if negative return false; } + + // Mark all threads as read + public function trackUpdateAll($user) + { + // Iterate over every forum + foreach ($this->forums as $forum) { + // Update every forum + $forum->trackUpdateAll($user); + } + + // Iterate over every thread + foreach ($this->threads as $thread) { + // Update every thread + $thread->trackUpdate($user); + } + } } diff --git a/_sakura/components/Urls.php b/_sakura/components/Urls.php index fc118e1..07be2c1 100755 --- a/_sakura/components/Urls.php +++ b/_sakura/components/Urls.php @@ -107,6 +107,10 @@ class Urls '/viewforum.php?f=%u', '/forum/%u', ], + 'FORUM_MARK_READ' => [ + '/viewforum.php?f=%u&read=true&session=%s', + '/forum/%u?read=true&session=%s', + ], 'FORUM_THREAD' => [ '/viewtopic.php?t=%u', '/forum/thread/%u', diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 355ae31..7eaf446 100755 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20151120'); +define('SAKURA_VERSION', '20151121'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); diff --git a/_sakura/templates/yuuno/elements/pagination.tpl b/_sakura/templates/yuuno/elements/pagination.tpl index 54a3ba8..54fbf66 100755 --- a/_sakura/templates/yuuno/elements/pagination.tpl +++ b/_sakura/templates/yuuno/elements/pagination.tpl @@ -4,17 +4,21 @@