From eb94fe973bbf7b56e61b0287cf9a765197bed27c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?=
Date: Fri, 11 May 2018 17:29:49 +0200
Subject: [ticket/9837] Display unapproved posts to their authors
Basic functionality mock up.
PHPBB3-9837
---
phpBB/phpbb/content_visibility.php | 15 +++++++++++++--
phpBB/styles/prosilver/template/viewtopic_body.html | 6 ++++++
phpBB/styles/prosilver/theme/colours.css | 4 ++++
phpBB/viewtopic.php | 1 +
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 704ec6badb..4633ec24c2 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -144,7 +144,12 @@ class content_visibility
*/
public function is_visible($mode, $forum_id, $data)
{
- $is_visible = $this->auth->acl_get('m_approve', $forum_id) || $data[$mode . '_visibility'] == ITEM_APPROVED;
+ $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 || (
+ ($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) &&
+ $this->user->data['user_id'] === $data[$poster_key]
+ );
/**
* Allow changing the result of calling is_visible
@@ -216,7 +221,13 @@ class content_visibility
}
else
{
- $where_sql .= $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
+ $field_name = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
+ $visibility_query = $table_alias . $mode . '_visibility = ';
+
+ $where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')';
+ $where_sql .= ' OR (';
+ $where_sql .= '(' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE . ')';
+ $where_sql .= ' AND ' . $table_alias . $field_name . ' = ' . ((int) $this->user->data['user_id']) . ')';
}
return '(' . $where_sql . ')';
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html
index 9bfa07e52b..5a469b8d85 100644
--- a/phpBB/styles/prosilver/template/viewtopic_body.html
+++ b/phpBB/styles/prosilver/template/viewtopic_body.html
@@ -294,6 +294,7 @@
+
+
+
+ {L_POST_UNAPPROVED}
+
+
-
+
{L_POST_UNAPPROVED}
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index d8ee4f73a7..c44b5cd37d 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -1162,6 +1162,6 @@ li.notification-reported strong, li.notification-disapproved strong {
color: #ffffff;
}
-p.information {
+.information {
background-color: #b8d3e0;
}
--
cgit v1.2.1
From 63b7518a0f8b09d23a0d45c50d98aa3ff607f613 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Tue, 10 Sep 2019 08:33:01 -0400
Subject: [ticket/9837] Make unapproved posts visible to posters
Improvements for feature following review
PHPBB3-9837
---
phpBB/includes/acp/acp_board.php | 1 +
phpBB/language/en/acp/board.php | 2 ++
phpBB/phpbb/content_visibility.php | 11 +++++-----
.../v330/add_display_unapproved_posts_config.php | 24 ++++++++++++++++++++++
phpBB/viewforum.php | 5 +++++
5 files changed, 38 insertions(+), 5 deletions(-)
create mode 100644 phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 05871e4157..2441a37edc 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -101,6 +101,7 @@ class acp_board
'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_birthdays' => array('lang' => 'ALLOW_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'display_last_subject' => array('lang' => 'DISPLAY_LAST_SUBJECT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'display_unapproved_posts' => array('lang' => 'DISPLAY_UNAPPROVED_POSTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),
'legend2' => 'ACP_SUBMIT_CHANGES',
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index fdc02d9ae8..5fa170bdb5 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -52,6 +52,8 @@ $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_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.',
'OVERRIDE_STYLE' => 'Override user style',
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 8249e9c36d..699bfa167e 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -222,15 +222,16 @@ class content_visibility
}
else
{
- $field_name = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
$visibility_query = $table_alias . $mode . '_visibility = ';
$where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')';
- $where_sql .= ' OR (';
- $where_sql .= '(' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE . ')';
- $where_sql .= ' AND ' . $table_alias . $field_name . ' = ' . ((int) $this->user->data['user_id']) . ')';
+ if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] <> ANONYMOUS))
+ {
+ $poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
+ $where_sql .= ' OR (' . $visibility_query . ITEM_UNAPPROVED;
+ $where_sql .= ' AND ' . $table_alias . $poster_key . ' = ' . ((int) $this->user->data['user_id']) . ')';
+ }
}
-
return '(' . $where_sql . ')';
}
diff --git a/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php b/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
new file mode 100644
index 0000000000..e3d2bddb0b
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
@@ -0,0 +1,24 @@
+
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v330;
+
+class add_display_unapproved_posts_config extends \phpbb\db\migration\migration
+{
+ public function update_data()
+ {
+ return array(
+ array('config.add', array('display_unapproved_posts', 1)),
+ );
+ }
+}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 4691512cbd..f6107b7c3b 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -899,6 +899,11 @@ if (count($topic_list))
// Replies
$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1;
+ //correct for case of unapproved topic visible to poster - a bit dirty but efficient
+ if ($replies < 0)
+ {
+ $replies++;
+ }
if ($row['topic_status'] == ITEM_MOVED)
{
--
cgit v1.2.1
From 78a913581c727801240758c0a8c3bfae86d124ca Mon Sep 17 00:00:00 2001
From: v12mike
Date: Tue, 10 Sep 2019 16:32:13 -0400
Subject: [ticket/9837] Display unapproved posts to posters
Add tests and improve style template
PHPBB3-9837
---
phpBB/language/en/common.php | 2 +-
phpBB/phpbb/content_visibility.php | 14 +-
.../styles/prosilver/template/viewtopic_body.html | 5 +-
.../visibility_unapproved_posts_test.php | 360 +++++++++++++++++++++
4 files changed, 371 insertions(+), 10 deletions(-)
create mode 100644 tests/functional/visibility_unapproved_posts_test.php
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index d050c1b109..04ed4de5b1 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -614,7 +614,7 @@ $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 has not been approved.',
+ 'POST_UNAPPROVED' => 'This post is not visible to other users until it has been approved',
'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 699bfa167e..1ee3cfee8b 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;
@@ -198,8 +198,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(
@@ -225,10 +225,10 @@ class content_visibility
$visibility_query = $table_alias . $mode . '_visibility = ';
$where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')';
- if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] <> ANONYMOUS))
+ if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] <> ANONYMOUS))
{
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
- $where_sql .= ' OR (' . $visibility_query . ITEM_UNAPPROVED;
+ $where_sql .= ' OR ((' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE .')';
$where_sql .= ' AND ' . $table_alias . $poster_key . ' = ' . ((int) $this->user->data['user_id']) . ')';
}
}
@@ -268,8 +268,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 16e28651bf..f627852969 100644
--- a/phpBB/styles/prosilver/template/viewtopic_body.html
+++ b/phpBB/styles/prosilver/template/viewtopic_body.html
@@ -306,8 +306,9 @@
-
- {L_POST_UNAPPROVED}
+
+
+ {L_POST_UNAPPROVED}
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
new file mode 100644
index 0000000000..4e220ddda2
--- /dev/null
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -0,0 +1,360 @@
+
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_case
+{
+ protected $data = array();
+
+ public function test_setup_forums()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
+ $form = $crawler->selectButton('addforum')->form(array(
+ 'forum_name' => 'Unapproved Posts Test #1',
+ ));
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form(array(
+ 'forum_perm_from' => 2,
+ ));
+ $crawler = self::submit($form);
+
+ // Set flood interval to 0
+ $this->set_flood_interval(0);
+ }
+
+ public function test_create_posts()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Unapproved Posts Test #1',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ 'forum_posts_approved' => 0,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 0,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => 0,
+ ), 'initial comparison');
+
+ // Test creating topic #1
+ $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #1', 'This is a test topic posted by the testing framework.');
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+
+ $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->data['topics']['Unapproved Posts Test Topic #1'] = (int) $post['topic_id'];
+ $this->data['posts']['Unapproved Posts Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ), 'after creating topic #1');
+
+ $this->logout();
+ $this->create_user('unapproved_posts_test_user#1');
+ $this->add_user_group('NEWLY_REGISTERED', array('unapproved_posts_test_user#1'));
+ $this->login('unapproved_posts_test_user#1');
+
+ // Test creating a reply
+ $post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
+ $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 1,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ), 'after replying');
+
+ // Test creating topic #2
+ $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
+
+ $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ), 'after creating topic #2');
+
+ $this->logout();
+ }
+
+ public function test_view_unapproved_post_disabled()
+ {
+ // user who created post
+ $this->login('unapproved_posts_test_user#1');
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Unapproved Posts Test #1',
+ ),
+ 'topics' => array(
+ 'Unapproved Posts Test Topic #1',
+ 'Unapproved Posts Test Topic #2',
+ ),
+ 'posts' => array(
+ 'Unapproved Posts Test Topic #1',
+ 'Re: Unapproved Posts Test Topic #1-#2',
+ 'Unapproved Posts Test Topic #2',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ), 'before approving post');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ //should be able to see topic 1 but not unapproved post
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+
+ //should not be able to see topic 2
+ $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
+ $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->logout();
+
+ // another user
+ $this->create_user('unapproved_posts_test_user#2');
+ $this->login('unapproved_posts_test_user#2');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ //should be able to see topic 1 but not unapproved post
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+
+ //should not be able to see topic 2
+ $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
+ $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ }
+
+ public function test_view_unapproved_post_enabled()
+ {
+ $this->config_display_unapproved_posts_state(true);
+
+ // user who created post
+ $this->login('unapproved_posts_test_user#1');
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Unapproved Posts Test #1',
+ ),
+ 'topics' => array(
+ 'Unapproved Posts Test Topic #1',
+ 'Unapproved Posts Test Topic #2',
+ ),
+ 'posts' => array(
+ 'Unapproved Posts Test Topic #1',
+ 'Re: Unapproved Posts Test Topic #1-#2',
+ 'Unapproved Posts Test Topic #2',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ), 'before approving post');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ //should be able to see topic 1 and unapproved post
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+
+ //should be able to see topic 2
+ $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
+ $this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ //should be able to see post in topic 2
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #2']}&sid={$this->sid}");
+ $this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text());
+ $this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+ $this->logout();
+
+ // another user
+ $this->login('unapproved_posts_test_user#2');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ //should be able to see topic 1 but not unapproved post
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
+ $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
+ $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
+
+ //should not be able to see topic 2
+ $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
+ $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
+ $this->logout();
+
+ // revert the configuration
+ $this->config_display_unapproved_posts_state(false);
+ }
+
+ public function test_reset_flood_interval()
+ {
+ $this->login();
+ $this->admin_login();
+
+ // Set flood interval back to 15
+ $this->set_flood_interval(15);
+ }
+
+ protected function assert_forum_details($forum_id, $details, $additional_error_message = '')
+ {
+ $this->db = $this->get_db();
+
+ $sql = 'SELECT ' . implode(', ', array_keys($details)) . '
+ FROM phpbb_forums
+ WHERE forum_id = ' . (int) $forum_id;
+ $result = $this->db->sql_query($sql);
+ $data = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}");
+ }
+
+ protected function set_flood_interval($flood_interval)
+ {
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ $values["config[flood_interval]"] = $flood_interval;
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
+ }
+
+ protected function load_ids($data)
+ {
+ $this->db = $this->get_db();
+
+ if (!empty($data['forums']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_forums
+ WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['forum_name'], $data['forums']))
+ {
+ $this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['topics']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_topics
+ WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['topic_title'], $data['topics']))
+ {
+ $this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['posts']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_posts
+ WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['post_subject'], $data['posts']))
+ {
+ $this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+ }
+
+ protected function config_display_unapproved_posts_state($state)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=features");
+
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ // Enable display of unapproved posts to posters
+ $values['config[display_unapproved_posts]'] = $state;
+
+ $form->setValues($values);
+
+ $crawler = self::submit($form);
+ self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());
+ $this->logout();
+ }
+}
--
cgit v1.2.1
From 92362441bd17dd18fb006a7b9f7a05c65ed2b432 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Wed, 11 Sep 2019 04:52:07 -0400
Subject: [ticket/9837] Make unapproved posts visible to posters
Add tests
Tidy up code
Improve user message formatting
PHPBB3-9837
---
phpBB/language/en/acp/board.php | 2 +-
phpBB/language/en/common.php | 3 +-
phpBB/phpbb/content_visibility.php | 20 ++++---
.../styles/prosilver/template/viewtopic_body.html | 2 +-
phpBB/styles/prosilver/theme/colours.css | 4 --
phpBB/viewforum.php | 2 +-
.../fixtures/get_visibility_sql.xml | 23 ++++++++
.../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 @@
- {L_POST_UNAPPROVED}
+ {L_POST_UNAPPROVED_EXPLAIN}
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 @@
topic_id
forum_id
+ topic_poster
topic_visibility
topic_title
1
1
0
+ 0
Unapproved
2
1
+ 0
1
Approved
@@ -21,13 +24,22 @@
3
1
2
+ 0
Softdeleted
+
+ 4
+ 1
+ 1
+ 0
+ Unapproved
+
post_id
topic_id
forum_id
+ poster_id
post_visibility
post_text
@@ -35,12 +47,14 @@
1
1
0
+ 0
Unapproved
2
2
1
+ 0
1
Approved
@@ -48,8 +62,17 @@
3
3
1
+ 0
2
Softdeleted
+
+ 4
+ 4
+ 1
+ 1
+ 0
+ Unapproved
+
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);
--
cgit v1.2.1
From e102a9a3cb81534731495f3c4d2ceed815f6dec2 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Wed, 11 Sep 2019 05:17:13 -0400
Subject: [ticket/9837] Make unapproved posts visible to poster
Improve acp explanation string
PHPBB3-9837
---
phpBB/language/en/acp/board.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 31801537a9..57f7e5738d 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -53,7 +53,7 @@ $lang = array_merge($lang, array(
'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_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',
+ 'DISPLAY_UNAPPROVED_POSTS_EXPLAIN' => 'Unapproved posts in the moderation queue can be viewed by the poster. Does not apply to Guest posts',
'GUEST_STYLE' => 'Guest style',
'GUEST_STYLE_EXPLAIN' => 'The board style for guests.',
'OVERRIDE_STYLE' => 'Override user style',
--
cgit v1.2.1
From 46a189fa4c5ed099eddca5b03f6fd17e057a37c6 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Wed, 11 Sep 2019 08:23:21 -0400
Subject: [ticket/9837] Display unapproved posts to originator
Fix whitespace issues
PHPBB3-9837
---
phpBB/phpbb/content_visibility.php | 10 +++++-----
phpBB/viewforum.php | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 1c69691a2c..276a9d9d23 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -146,11 +146,11 @@ 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) ||
- ($this->config['display_unapproved_posts'] &&
- ($this->user->data['user_id'] <> ANONYMOUS) &&
- ($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) &&
+ $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])
);
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 6b98021e3c..787667fcd7 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -899,8 +899,8 @@ if (count($topic_list))
// Replies
$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1;
- //correct for case of unapproved topic visible to poster - a bit dirty but efficient
- if ($replies < 0)
+ //correct for case of unapproved topic visible to poster - a bit dirty but efficient
+ if ($replies < 0)
{
$replies = 0;
}
--
cgit v1.2.1
From 3149b45ebafb42f347cb2b537c8fef2a51bd4783 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?=
Date: Fri, 11 May 2018 17:29:49 +0200
Subject: [ticket/9837] Display unapproved posts to their authors
Basic functionality mock up.
PHPBB3-9837
---
phpBB/styles/prosilver/theme/colours.css | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index ffaa71034f..d8ee4f73a7 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -1161,3 +1161,7 @@ li.notification-reported strong, li.notification-disapproved strong {
background-color: #D31141;
color: #ffffff;
}
+
+p.information {
+ background-color: #b8d3e0;
+}
--
cgit v1.2.1
From e39753083ddf702696747206abbf0916b9b0c904 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?=
Date: Sun, 13 May 2018 13:13:38 +0200
Subject: [ticket/9837] Small fixes
PHPBB3-9837
---
phpBB/styles/prosilver/theme/colours.css | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index d8ee4f73a7..c44b5cd37d 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -1162,6 +1162,6 @@ li.notification-reported strong, li.notification-disapproved strong {
color: #ffffff;
}
-p.information {
+.information {
background-color: #b8d3e0;
}
--
cgit v1.2.1
From 1f10cd51ffaa8015bf29a3ca3173528f319f8e78 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Tue, 10 Sep 2019 16:32:13 -0400
Subject: [ticket/9837] Display unapproved posts to posters
Add tests and improve style template
PHPBB3-9837
---
phpBB/phpbb/content_visibility.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 276a9d9d23..57f47ccb82 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;
@@ -200,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(
@@ -270,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(
--
cgit v1.2.1
From 9fff4cf2536821ef75e4908cc22be2122dcc67a9 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Wed, 11 Sep 2019 04:52:07 -0400
Subject: [ticket/9837] Make unapproved posts visible to posters
Add tests
Tidy up code
Improve user message formatting
PHPBB3-9837
---
phpBB/phpbb/content_visibility.php | 10 +++++-----
phpBB/styles/prosilver/theme/colours.css | 4 ----
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 57f47ccb82..276a9d9d23 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;
@@ -200,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(
@@ -270,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/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;
-}
--
cgit v1.2.1
From 63ebd658a947143788f83014c6e90b4eb3baa985 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Fri, 13 Sep 2019 03:47:12 -0400
Subject: [ticket/9837] Display unapproved posts to their authors
Improve ACP language strings
PHPBB3-9837
---
phpBB/language/en/acp/board.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 57f7e5738d..0b601d2821 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -52,8 +52,8 @@ $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_EXPLAIN' => 'Unapproved posts in the moderation queue can be viewed by the poster. Does not apply to Guest posts',
+ 'DISPLAY_UNAPPROVED_POSTS' => 'Display unapproved posts to the author',
+ 'DISPLAY_UNAPPROVED_POSTS_EXPLAIN' => 'Unapproved posts in the moderation queue can be viewed by the author. Does not apply to Guest posts',
'GUEST_STYLE' => 'Guest style',
'GUEST_STYLE_EXPLAIN' => 'The board style for guests.',
'OVERRIDE_STYLE' => 'Override user style',
--
cgit v1.2.1
From 15da5b108e6b93fd0059b1b523b68eccec1cce5c Mon Sep 17 00:00:00 2001
From: v12mike
Date: Sun, 6 Oct 2019 09:43:45 -0400
Subject: [ticket/9837] Display unapproved posts to their authors
Re-order code for efficiency
PHPBB3-9837
---
phpBB/phpbb/content_visibility.php | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 276a9d9d23..bea49c0be1 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -146,13 +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) ||
- ($this->config['display_unapproved_posts'] &&
+ $is_visible = ($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])
- );
+ ($this->user->data['user_id'] === $data[$poster_key])) ||
+ $this->auth->acl_get('m_approve', $forum_id);
/**
* Allow changing the result of calling is_visible
--
cgit v1.2.1
From 8726baea9fd0b0ba9a09a00f24c4bb616ccec8cd Mon Sep 17 00:00:00 2001
From: v12mike
Date: Sun, 6 Oct 2019 09:51:45 -0400
Subject: [ticket/9837] Display unapproved posts to their authors
Change code order to improve efficiency.
PHPBB3-9837
---
phpBB/phpbb/content_visibility.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index bea49c0be1..457b53653d 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -147,7 +147,7 @@ class content_visibility
$visibility = $data[$mode . '_visibility'];
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
$is_visible = ($visibility == ITEM_APPROVED) ||
- ($this->config['display_unapproved_posts'] &&
+ ($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])) ||
--
cgit v1.2.1
From 4d156837332707542bed6899cbf872c441f7bd96 Mon Sep 17 00:00:00 2001
From: v12mike
Date: Sun, 3 Nov 2019 14:17:47 +0100
Subject: [ticket/9837] Display unapproved posts to their authors
Clarification of comment
PHPBB3-9837
---
phpBB/viewforum.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 787667fcd7..eb6b37ada8 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -899,7 +899,7 @@ if (count($topic_list))
// Replies
$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1;
- //correct for case of unapproved topic visible to poster - a bit dirty but efficient
+ // Correction for case of unapproved topic visible to poster
if ($replies < 0)
{
$replies = 0;
--
cgit v1.2.1
From 0f57f3d90d1983c49bde1d56b6018a761f92264b Mon Sep 17 00:00:00 2001
From: v12mike
Date: Mon, 4 Nov 2019 09:21:27 -0500
Subject: [ticket/9837] Display unapproved posts to their authors
Coding guidelines fixes
PHPBB3-9837
---
.../v330/add_display_unapproved_posts_config.php | 6 +-
.../content_visibility/get_visibility_sql_test.php | 38 +++----
.../visibility_unapproved_posts_test.php | 113 ++++++++++-----------
3 files changed, 79 insertions(+), 78 deletions(-)
diff --git a/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php b/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
index e3d2bddb0b..d45f557a8b 100644
--- a/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
+++ b/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
@@ -17,8 +17,8 @@ class add_display_unapproved_posts_config extends \phpbb\db\migration\migration
{
public function update_data()
{
- return array(
- array('config.add', array('display_unapproved_posts', 1)),
- );
+ return [
+ ['config.add', ['display_unapproved_posts', 1]],
+ ];
}
}
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php
index def4ed3718..6026778487 100644
--- a/tests/content_visibility/get_visibility_sql_test.php
+++ b/tests/content_visibility/get_visibility_sql_test.php
@@ -24,8 +24,8 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
// data set 0: display_unapproved_posts=false, moderator, can see all posts
array(
'phpbb_posts',
- 0,
- false,
+ 0,
+ false,
'post', 1, '',
array(
array('m_approve', 1, true),
@@ -37,11 +37,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 4),
),
),
- // data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts
+ // data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts
array(
'phpbb_posts',
0,
- false,
+ false,
'post', 1, '',
array(
),
@@ -53,7 +53,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array(
'phpbb_topics',
0,
- false,
+ false,
'topic', 1, '',
array(
array('m_approve', 1, true),
@@ -65,22 +65,22 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('topic_id' => 4),
),
),
- // data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic
+ // data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic
array(
'phpbb_topics',
0,
- false,
+ false,
'topic', 1, '',
array(),
array(
array('topic_id' => 2),
),
),
- // data set 4: display_unapproved_posts=true, guest user, cannot see unapproved posts
+ // data set 4: display_unapproved_posts=true, guest user, cannot see unapproved posts
array(
'phpbb_posts',
1,
- true,
+ true,
'post', 1, '',
array(
),
@@ -88,22 +88,22 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 2),
),
),
- // data set 5: display_unapproved_posts=true, guest user, cannot see unapproved posts topic
+ // data set 5: display_unapproved_posts=true, guest user, cannot see unapproved posts topic
array(
'phpbb_topics',
1,
- true,
+ true,
'topic', 1, '',
array(),
array(
array('topic_id' => 2),
),
),
- // data set 6: display_unapproved_posts=true, normal user, can see own unapproved posts
+ // data set 6: display_unapproved_posts=true, normal user, can see own unapproved posts
array(
'phpbb_posts',
- 0,
- true,
+ 0,
+ true,
'post', 1, '',
array(),
array(
@@ -111,11 +111,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 2),
),
),
- // data set 7: display_unapproved_posts=true, normal user, can see own unapproved posts topic
+ // data set 7: display_unapproved_posts=true, normal user, can see own unapproved posts topic
array(
'phpbb_topics',
0,
- true,
+ true,
'topic', 1, '',
array(),
array(
@@ -152,11 +152,13 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
$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);
- $result = $db->sql_query('SELECT ' . $mode . '_id
+ $sql = 'SELECT ' . $mode . '_id
FROM ' . $table . '
WHERE ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . '
- ORDER BY ' . $mode . '_id ASC');
+ ORDER BY ' . $mode . '_id ASC';
+ $result = $db->sql_query($sql);
$this->assertEquals($expected, $db->sql_fetchrowset($result));
+ $db->sql_freeresult($result);
}
}
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
index 4e220ddda2..f29e081977 100644
--- a/tests/functional/visibility_unapproved_posts_test.php
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -16,7 +16,7 @@
*/
class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_case
{
- protected $data = array();
+ protected $data = [];
public function test_setup_forums()
{
@@ -24,13 +24,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->admin_login();
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
- $form = $crawler->selectButton('addforum')->form(array(
+ $form = $crawler->selectButton('addforum')->form([
'forum_name' => 'Unapproved Posts Test #1',
- ));
+ ]);
$crawler = self::submit($form);
- $form = $crawler->selectButton('update')->form(array(
+ $form = $crawler->selectButton('update')->form([
'forum_perm_from' => 2,
- ));
+ ]);
$crawler = self::submit($form);
// Set flood interval to 0
@@ -40,13 +40,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
public function test_create_posts()
{
$this->login();
- $this->load_ids(array(
- 'forums' => array(
+ $this->load_ids([
+ 'forums' => [
'Unapproved Posts Test #1',
- ),
- ));
+ ],
+ ]);
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
@@ -54,7 +54,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => 0,
- ), 'initial comparison');
+ ], 'initial comparison');
// Test creating topic #1
$post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #1', 'This is a test topic posted by the testing framework.');
@@ -64,7 +64,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->data['topics']['Unapproved Posts Test Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Unapproved Posts Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
@@ -72,20 +72,20 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'after creating topic #1');
+ ], 'after creating topic #1');
$this->logout();
$this->create_user('unapproved_posts_test_user#1');
- $this->add_user_group('NEWLY_REGISTERED', array('unapproved_posts_test_user#1'));
+ $this->add_user_group('NEWLY_REGISTERED', ['unapproved_posts_test_user#1']);
$this->login('unapproved_posts_test_user#1');
// Test creating a reply
- $post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', [], 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 1,
'forum_posts_softdeleted' => 0,
@@ -93,15 +93,15 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'after replying');
+ ], 'after replying');
// Test creating topic #2
- $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', [], 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
@@ -109,31 +109,31 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'after creating topic #2');
+ ], 'after creating topic #2');
$this->logout();
}
public function test_view_unapproved_post_disabled()
{
- // user who created post
+ // user who created post
$this->login('unapproved_posts_test_user#1');
- $this->load_ids(array(
- 'forums' => array(
+ $this->load_ids([
+ 'forums' => [
'Unapproved Posts Test #1',
- ),
- 'topics' => array(
+ ],
+ 'topics' => [
'Unapproved Posts Test Topic #1',
'Unapproved Posts Test Topic #2',
- ),
- 'posts' => array(
+ ],
+ 'posts' => [
'Unapproved Posts Test Topic #1',
'Re: Unapproved Posts Test Topic #1-#2',
'Unapproved Posts Test Topic #2',
- ),
- ));
+ ],
+ ]);
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
@@ -141,19 +141,19 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'before approving post');
+ ], 'before approving post');
$this->add_lang('posting');
$this->add_lang('viewtopic');
$this->add_lang('mcp');
- //should be able to see topic 1 but not unapproved post
+ // should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should not be able to see topic 2
+ // should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
@@ -162,17 +162,15 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->create_user('unapproved_posts_test_user#2');
$this->login('unapproved_posts_test_user#2');
- $this->add_lang('posting');
- $this->add_lang('viewtopic');
- $this->add_lang('mcp');
+ $this->add_lang('posting', 'viewtopic', 'mcp');
- //should be able to see topic 1 but not unapproved post
+ // should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should not be able to see topic 2
+ // should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
}
@@ -181,24 +179,24 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
{
$this->config_display_unapproved_posts_state(true);
- // user who created post
+ // user who created post
$this->login('unapproved_posts_test_user#1');
- $this->load_ids(array(
- 'forums' => array(
+ $this->load_ids([
+ 'forums' => [
'Unapproved Posts Test #1',
- ),
- 'topics' => array(
+ ],
+ 'topics' => [
'Unapproved Posts Test Topic #1',
'Unapproved Posts Test Topic #2',
- ),
- 'posts' => array(
+ ],
+ 'posts' => [
'Unapproved Posts Test Topic #1',
'Re: Unapproved Posts Test Topic #1-#2',
'Unapproved Posts Test Topic #2',
- ),
- ));
+ ],
+ ]);
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
@@ -206,22 +204,23 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'before approving post');
+ ], 'before approving post');
$this->add_lang('posting');
$this->add_lang('viewtopic');
$this->add_lang('mcp');
- //should be able to see topic 1 and unapproved post
+ // should be able to see topic 1 and unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should be able to see topic 2
+ // should be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
- //should be able to see post in topic 2
+
+ // should be able to see post in topic 2
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #2']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text());
$this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
@@ -234,13 +233,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->add_lang('viewtopic');
$this->add_lang('mcp');
- //should be able to see topic 1 but not unapproved post
+ // should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should not be able to see topic 2
+ // should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
@@ -274,12 +273,12 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
protected function set_flood_interval($flood_interval)
{
- $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+ $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=post");
$form = $crawler->selectButton('Submit')->form();
$values = $form->getValues();
- $values["config[flood_interval]"] = $flood_interval;
+ $values['config[flood_interval]'] = $flood_interval;
$form->setValues($values);
$crawler = self::submit($form);
$this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
@@ -291,7 +290,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
if (!empty($data['forums']))
{
- $sql = 'SELECT *
+ $sql = 'SELECT forum_id, forum_name
FROM phpbb_forums
WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
$result = $this->db->sql_query($sql);
--
cgit v1.2.1
From 29be971fad6ba90c147d0fd8b2d07d69e5efddec Mon Sep 17 00:00:00 2001
From: v12mike
Date: Tue, 19 Nov 2019 07:20:44 -0500
Subject: [ticket/9837] Make unapproved posts visible to author
review comments
PHPBB3-9837
---
phpBB/language/en/acp/board.php | 2 +-
.../db/migration/data/v330/add_display_unapproved_posts_config.php | 2 +-
tests/functional/visibility_unapproved_posts_test.php | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 0b601d2821..cb9013805d 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -53,7 +53,7 @@ $lang = array_merge($lang, array(
'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 author',
- 'DISPLAY_UNAPPROVED_POSTS_EXPLAIN' => 'Unapproved posts in the moderation queue can be viewed by the author. Does not apply to Guest posts',
+ 'DISPLAY_UNAPPROVED_POSTS_EXPLAIN' => 'Unapproved posts can be viewed by the author. Does not apply to Guest posts.',
'GUEST_STYLE' => 'Guest style',
'GUEST_STYLE_EXPLAIN' => 'The board style for guests.',
'OVERRIDE_STYLE' => 'Override user style',
diff --git a/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php b/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
index d45f557a8b..b429270827 100644
--- a/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
+++ b/phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php
@@ -19,6 +19,6 @@ class add_display_unapproved_posts_config extends \phpbb\db\migration\migration
{
return [
['config.add', ['display_unapproved_posts', 1]],
- ];
+ ];
}
}
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
index f29e081977..2fb2ef3403 100644
--- a/tests/functional/visibility_unapproved_posts_test.php
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -244,8 +244,8 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
- // revert the configuration
- $this->config_display_unapproved_posts_state(false);
+ // revert the configuration (if necessary)
+ //$this->config_display_unapproved_posts_state(false);
}
public function test_reset_flood_interval()
--
cgit v1.2.1
From 4a10062933d9e221e4efd813058adae4c87f3fc2 Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Thu, 21 Nov 2019 13:40:05 +0100
Subject: [ticket/9837] Remove not needed lines in test
PHPBB3-9837
---
tests/functional/visibility_unapproved_posts_test.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
index 2fb2ef3403..9f6491d1d8 100644
--- a/tests/functional/visibility_unapproved_posts_test.php
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -243,9 +243,6 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
-
- // revert the configuration (if necessary)
- //$this->config_display_unapproved_posts_state(false);
}
public function test_reset_flood_interval()
--
cgit v1.2.1
From 0a4cc5d2018dde19754f90b30ad49ff2718efc76 Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Fri, 22 Nov 2019 09:20:18 +0100
Subject: [ticket/9837] Apply suggested changes by CHItA
PHPBB3-9837
---
phpBB/language/en/common.php | 2 +-
phpBB/phpbb/content_visibility.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 3b7230b93d..b0c6f7fd1c 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -615,7 +615,7 @@ $lang = array_merge($lang, array(
'POST_TOPIC' => 'Post a new topic',
'POST_UNAPPROVED_ACTION' => 'Post awaiting approval:',
'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',
+ '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 457b53653d..fbc56f3db2 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -148,9 +148,9 @@ class content_visibility
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
$is_visible = ($visibility == ITEM_APPROVED) ||
($this->config['display_unapproved_posts'] &&
- ($this->user->data['user_id'] <> ANONYMOUS) &&
+ ($this->user->data['user_id'] != ANONYMOUS) &&
($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) &&
- ($this->user->data['user_id'] === $data[$poster_key])) ||
+ ($this->user->data['user_id'] == $data[$poster_key])) ||
$this->auth->acl_get('m_approve', $forum_id);
/**
@@ -226,7 +226,7 @@ class content_visibility
$visibility_query = $table_alias . $mode . '_visibility = ';
$where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')';
- if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] <> ANONYMOUS))
+ if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] != ANONYMOUS))
{
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
$where_sql .= ' OR ((' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE .')';
--
cgit v1.2.1