diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 59ef7bbc80..62ee5cc8de 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -145,7 +145,15 @@ if ($view && !$post_id) if (!$row) { - $user->setup('viewtopic'); + // Check for forum style + $sql = 'SELECT forum_style + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $forum_style = (int) $db->sql_fetchfield('forum_style'); + $db->sql_freeresult($result); + + $user->setup('viewtopic', $forum_style); trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); } else diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php new file mode 100644 index 0000000000..1f38c2d057 --- /dev/null +++ b/tests/functional/forum_style_test.php @@ -0,0 +1,53 @@ +request('GET', 'viewtopic.php?t=1&f=2'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/theme/print.css', $this->client->getResponse()->getContent()); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2&view=next'); + $this->assert_response_success(); + $this->assertContains('styles/prosilver/theme/print.css', $this->client->getResponse()->getContent()); + + // Insert new style and change forum style + $db = $this->get_db(); + $db->sql_multi_insert(STYLES_TABLE, array( + 'style_id' => 2, + 'style_name' => 'test_style', + 'style_copyright' => '', + 'style_active' => 1, + 'style_path' => 'test_style', + 'bbcode_bitfield' => 'kNg=', + 'style_parent_id' => 1, + 'style_parent_tree' => 'prosilver', + )); + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); + + // Test with custom style + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/theme/print.css', $this->client->getResponse()->getContent()); + + $crawler = $this->request('GET', 'viewtopic.php?t=1&f=2&view=next'); + $this->assert_response_success(); + $this->assertContains('styles/test_style/theme/print.css', $this->client->getResponse()->getContent()); + + // Undo changes + $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); + $db->sql_query('DELETE FROM ' . STYLES_TABLE . ' WHERE style_id = 2'); + } +}