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/phpbb/content_visibility.php | 11 +++++----- .../v330/add_display_unapproved_posts_config.php | 24 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php (limited to 'phpBB/phpbb') 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)), + ); + } +} -- cgit v1.2.1