diff options
-rw-r--r-- | phpBB/language/en/acp/board.php | 2 | ||||
-rw-r--r-- | phpBB/language/en/common.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/content_visibility.php | 20 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/viewtopic_body.html | 2 | ||||
-rw-r--r-- | phpBB/styles/prosilver/theme/colours.css | 4 | ||||
-rw-r--r-- | phpBB/viewforum.php | 2 | ||||
-rw-r--r-- | tests/content_visibility/fixtures/get_visibility_sql.xml | 23 | ||||
-rw-r--r-- | tests/content_visibility/get_visibility_sql_test.php | 68 |
8 files changed, 105 insertions, 19 deletions
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 5fa170bdb5..31801537a9 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -52,7 +52,7 @@ $lang = array_merge($lang, array( 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.', 'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list', 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.', - 'DISPLAY_UNAPPROVED_POSTS' => 'Display unapproved posts to the poster', + 'DISPLAY_UNAPPROVED_POSTS' => 'Display unapproved posts to the poster', 'DISPLAY_UNAPPROVED_POSTS_EXPLAIN' => 'The poster will be able to see his unapproved posts while they are in the moderation queue. This does not restrict the visbility to Moderators', 'GUEST_STYLE' => 'Guest style', 'GUEST_STYLE_EXPLAIN' => 'The board style for guests.', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 04ed4de5b1..3b7230b93d 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -614,7 +614,8 @@ $lang = array_merge($lang, array( 'POST_TIME' => 'Post time', 'POST_TOPIC' => 'Post a new topic', 'POST_UNAPPROVED_ACTION' => 'Post awaiting approval:', - 'POST_UNAPPROVED' => 'This post is not visible to other users until it has been approved', + 'POST_UNAPPROVED' => 'This post has not been approved.', + 'POST_UNAPPROVED_EXPLAIN' => 'This post is not visible to other users until it has been approved by a moderator', 'POWERED_BY' => 'Powered by %s', 'PREVIEW' => 'Preview', 'PREVIOUS' => 'Previous', // Used in pagination diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 1ee3cfee8b..1c69691a2c 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -76,7 +76,7 @@ class content_visibility * @param string $topics_table Topics table name * @param string $users_table Users table name */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) { $this->auth = $auth; $this->config = $config; @@ -146,10 +146,12 @@ class content_visibility { $visibility = $data[$mode . '_visibility']; $poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id'; - $is_visible = $this->auth->acl_get('m_approve', $forum_id) || $visibility == ITEM_APPROVED; - $is_visible = $is_visible || ( - ($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) - && $this->user->data['user_id'] === $data[$poster_key] + $is_visible = $this->auth->acl_get('m_approve', $forum_id) || + ($visibility == ITEM_APPROVED) || + ($this->config['display_unapproved_posts'] && + ($this->user->data['user_id'] <> ANONYMOUS) && + ($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) && + ($this->user->data['user_id'] === $data[$poster_key]) ); /** @@ -198,8 +200,8 @@ class content_visibility * @var array forum_id The forum id in which the search is made. * @var string table_alias Table alias to prefix in SQL queries * @var mixed get_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event - * If false, get_visibility_sql continues normally - * It must be either boolean or string + * If false, get_visibility_sql continues normally + * It must be either boolean or string * @since 3.1.4-RC1 */ $vars = array( @@ -268,8 +270,8 @@ class content_visibility * @var string table_alias Table alias to prefix in SQL queries * @var array approve_forums Array of forums where the user has m_approve permissions * @var mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event - * If false, get_forums_visibility_sql continues normally - * It must be either boolean or string + * If false, get_forums_visibility_sql continues normally + * It must be either boolean or string * @since 3.1.3-RC1 */ $vars = array( diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index f627852969..6af33f2f87 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -308,7 +308,7 @@ <!-- ELSE --> <p class="post-notice unapproved"> <span><i class="icon fa-exclamation icon-red fa-fw" aria-hidden="true"></i></span> - <strong>{L_POST_UNAPPROVED}</strong> + <strong>{L_POST_UNAPPROVED_EXPLAIN}</strong> </p> <!-- ENDIF --> <!-- ELSEIF postrow.S_POST_DELETED --> diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index c44b5cd37d..ffaa71034f 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -1161,7 +1161,3 @@ li.notification-reported strong, li.notification-disapproved strong { background-color: #D31141; color: #ffffff; } - -.information { - background-color: #b8d3e0; -} diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index f6107b7c3b..6b98021e3c 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -902,7 +902,7 @@ if (count($topic_list)) //correct for case of unapproved topic visible to poster - a bit dirty but efficient if ($replies < 0) { - $replies++; + $replies = 0; } if ($row['topic_status'] == ITEM_MOVED) diff --git a/tests/content_visibility/fixtures/get_visibility_sql.xml b/tests/content_visibility/fixtures/get_visibility_sql.xml index 146244263e..2128064986 100644 --- a/tests/content_visibility/fixtures/get_visibility_sql.xml +++ b/tests/content_visibility/fixtures/get_visibility_sql.xml @@ -3,17 +3,20 @@ <table name="phpbb_topics"> <column>topic_id</column> <column>forum_id</column> + <column>topic_poster</column> <column>topic_visibility</column> <column>topic_title</column> <row> <value>1</value> <value>1</value> <value>0</value> + <value>0</value> <value>Unapproved</value> </row> <row> <value>2</value> <value>1</value> + <value>0</value> <value>1</value> <value>Approved</value> </row> @@ -21,13 +24,22 @@ <value>3</value> <value>1</value> <value>2</value> + <value>0</value> <value>Softdeleted</value> </row> + <row> + <value>4</value> + <value>1</value> + <value>1</value> + <value>0</value> + <value>Unapproved</value> + </row> </table> <table name="phpbb_posts"> <column>post_id</column> <column>topic_id</column> <column>forum_id</column> + <column>poster_id</column> <column>post_visibility</column> <column>post_text</column> <row> @@ -35,12 +47,14 @@ <value>1</value> <value>1</value> <value>0</value> + <value>0</value> <value>Unapproved</value> </row> <row> <value>2</value> <value>2</value> <value>1</value> + <value>0</value> <value>1</value> <value>Approved</value> </row> @@ -48,8 +62,17 @@ <value>3</value> <value>3</value> <value>1</value> + <value>0</value> <value>2</value> <value>Softdeleted</value> </row> + <row> + <value>4</value> + <value>4</value> + <value>1</value> + <value>1</value> + <value>0</value> + <value>Unapproved</value> + </row> </table> </dataset> diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 18802fadbc..def4ed3718 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -21,8 +21,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te public function get_visibility_sql_data() { return array( + // data set 0: display_unapproved_posts=false, moderator, can see all posts array( 'phpbb_posts', + 0, + false, 'post', 1, '', array( array('m_approve', 1, true), @@ -31,10 +34,14 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te array('post_id' => 1), array('post_id' => 2), array('post_id' => 3), + array('post_id' => 4), ), ), + // data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts array( 'phpbb_posts', + 0, + false, 'post', 1, '', array( ), @@ -42,8 +49,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te array('post_id' => 2), ), ), + // data set 2: display_unapproved_posts=false, moderator, can see all topics array( 'phpbb_topics', + 0, + false, 'topic', 1, '', array( array('m_approve', 1, true), @@ -52,23 +62,74 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te array('topic_id' => 1), array('topic_id' => 2), array('topic_id' => 3), + array('topic_id' => 4), ), ), + // data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic array( 'phpbb_topics', + 0, + false, 'topic', 1, '', array(), array( array('topic_id' => 2), ), ), + // data set 4: display_unapproved_posts=true, guest user, cannot see unapproved posts + array( + 'phpbb_posts', + 1, + true, + 'post', 1, '', + array( + ), + array( + array('post_id' => 2), + ), + ), + // data set 5: display_unapproved_posts=true, guest user, cannot see unapproved posts topic + array( + 'phpbb_topics', + 1, + true, + 'topic', 1, '', + array(), + array( + array('topic_id' => 2), + ), + ), + // data set 6: display_unapproved_posts=true, normal user, can see own unapproved posts + array( + 'phpbb_posts', + 0, + true, + 'post', 1, '', + array(), + array( + array('post_id' => 1), + array('post_id' => 2), + ), + ), + // data set 7: display_unapproved_posts=true, normal user, can see own unapproved posts topic + array( + 'phpbb_topics', + 0, + true, + 'topic', 1, '', + array(), + array( + array('topic_id' => 1), + array('topic_id' => 2), + ), + ), ); } /** * @dataProvider get_visibility_sql_data */ - public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected) + public function test_get_visibility_sql($table, $user_id, $display_unapproved, $mode, $forum_id, $table_alias, $permissions, $expected) { global $cache, $db, $auth, $phpbb_root_path, $phpEx; @@ -84,7 +145,10 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $config = new phpbb\config\config(array()); + $user->data['user_id'] = $user_id; + $config = $this->config = new \phpbb\config\config(array( + 'display_unapproved_posts' => $display_unapproved, + )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); |