1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 15:01:33 +02:00

[ticket/9837] Make unapproved posts visible to posters

Add tests
Tidy up code
Improve user message formatting

PHPBB3-9837
This commit is contained in:
v12mike
2019-09-11 04:52:07 -04:00
committed by Marc Alexander
parent 78a913581c
commit 92362441bd
8 changed files with 105 additions and 19 deletions

View File

@@ -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 doesnt 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.',

View File

@@ -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

View File

@@ -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(

View File

@@ -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 -->

View File

@@ -1161,7 +1161,3 @@ li.notification-reported strong, li.notification-disapproved strong {
background-color: #D31141;
color: #ffffff;
}
.information {
background-color: #b8d3e0;
}

View File

@@ -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)