mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-16 08:18:53 +00: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:
parent
78a913581c
commit
92362441bd
8 changed files with 105 additions and 19 deletions
|
@ -614,7 +614,8 @@ $lang = array_merge($lang, array(
|
||||||
'POST_TIME' => 'Post time',
|
'POST_TIME' => 'Post time',
|
||||||
'POST_TOPIC' => 'Post a new topic',
|
'POST_TOPIC' => 'Post a new topic',
|
||||||
'POST_UNAPPROVED_ACTION' => 'Post awaiting approval:',
|
'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',
|
'POWERED_BY' => 'Powered by %s',
|
||||||
'PREVIEW' => 'Preview',
|
'PREVIEW' => 'Preview',
|
||||||
'PREVIOUS' => 'Previous', // Used in pagination
|
'PREVIOUS' => 'Previous', // Used in pagination
|
||||||
|
|
|
@ -146,10 +146,12 @@ class content_visibility
|
||||||
{
|
{
|
||||||
$visibility = $data[$mode . '_visibility'];
|
$visibility = $data[$mode . '_visibility'];
|
||||||
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
|
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
|
||||||
$is_visible = $this->auth->acl_get('m_approve', $forum_id) || $visibility == ITEM_APPROVED;
|
$is_visible = $this->auth->acl_get('m_approve', $forum_id) ||
|
||||||
$is_visible = $is_visible || (
|
($visibility == ITEM_APPROVED) ||
|
||||||
($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE)
|
($this->config['display_unapproved_posts'] &&
|
||||||
&& $this->user->data['user_id'] === $data[$poster_key]
|
($this->user->data['user_id'] <> ANONYMOUS) &&
|
||||||
|
($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) &&
|
||||||
|
($this->user->data['user_id'] === $data[$poster_key])
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -308,7 +308,7 @@
|
||||||
<!-- ELSE -->
|
<!-- ELSE -->
|
||||||
<p class="post-notice unapproved">
|
<p class="post-notice unapproved">
|
||||||
<span><i class="icon fa-exclamation icon-red fa-fw" aria-hidden="true"></i></span>
|
<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>
|
</p>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
<!-- ELSEIF postrow.S_POST_DELETED -->
|
<!-- ELSEIF postrow.S_POST_DELETED -->
|
||||||
|
|
|
@ -1161,7 +1161,3 @@ li.notification-reported strong, li.notification-disapproved strong {
|
||||||
background-color: #D31141;
|
background-color: #D31141;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.information {
|
|
||||||
background-color: #b8d3e0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -902,7 +902,7 @@ if (count($topic_list))
|
||||||
//correct for case of unapproved topic visible to poster - a bit dirty but efficient
|
//correct for case of unapproved topic visible to poster - a bit dirty but efficient
|
||||||
if ($replies < 0)
|
if ($replies < 0)
|
||||||
{
|
{
|
||||||
$replies++;
|
$replies = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row['topic_status'] == ITEM_MOVED)
|
if ($row['topic_status'] == ITEM_MOVED)
|
||||||
|
|
|
@ -3,17 +3,20 @@
|
||||||
<table name="phpbb_topics">
|
<table name="phpbb_topics">
|
||||||
<column>topic_id</column>
|
<column>topic_id</column>
|
||||||
<column>forum_id</column>
|
<column>forum_id</column>
|
||||||
|
<column>topic_poster</column>
|
||||||
<column>topic_visibility</column>
|
<column>topic_visibility</column>
|
||||||
<column>topic_title</column>
|
<column>topic_title</column>
|
||||||
<row>
|
<row>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
|
<value>0</value>
|
||||||
<value>Unapproved</value>
|
<value>Unapproved</value>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
|
<value>0</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>Approved</value>
|
<value>Approved</value>
|
||||||
</row>
|
</row>
|
||||||
|
@ -21,13 +24,22 @@
|
||||||
<value>3</value>
|
<value>3</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
|
<value>0</value>
|
||||||
<value>Softdeleted</value>
|
<value>Softdeleted</value>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>4</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>0</value>
|
||||||
|
<value>Unapproved</value>
|
||||||
|
</row>
|
||||||
</table>
|
</table>
|
||||||
<table name="phpbb_posts">
|
<table name="phpbb_posts">
|
||||||
<column>post_id</column>
|
<column>post_id</column>
|
||||||
<column>topic_id</column>
|
<column>topic_id</column>
|
||||||
<column>forum_id</column>
|
<column>forum_id</column>
|
||||||
|
<column>poster_id</column>
|
||||||
<column>post_visibility</column>
|
<column>post_visibility</column>
|
||||||
<column>post_text</column>
|
<column>post_text</column>
|
||||||
<row>
|
<row>
|
||||||
|
@ -35,12 +47,14 @@
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
|
<value>0</value>
|
||||||
<value>Unapproved</value>
|
<value>Unapproved</value>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
|
<value>0</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>Approved</value>
|
<value>Approved</value>
|
||||||
</row>
|
</row>
|
||||||
|
@ -48,8 +62,17 @@
|
||||||
<value>3</value>
|
<value>3</value>
|
||||||
<value>3</value>
|
<value>3</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
|
<value>0</value>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>Softdeleted</value>
|
<value>Softdeleted</value>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>4</value>
|
||||||
|
<value>4</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>0</value>
|
||||||
|
<value>Unapproved</value>
|
||||||
|
</row>
|
||||||
</table>
|
</table>
|
||||||
</dataset>
|
</dataset>
|
||||||
|
|
|
@ -21,8 +21,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
|
||||||
public function get_visibility_sql_data()
|
public function get_visibility_sql_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
// data set 0: display_unapproved_posts=false, moderator, can see all posts
|
||||||
array(
|
array(
|
||||||
'phpbb_posts',
|
'phpbb_posts',
|
||||||
|
0,
|
||||||
|
false,
|
||||||
'post', 1, '',
|
'post', 1, '',
|
||||||
array(
|
array(
|
||||||
array('m_approve', 1, true),
|
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' => 1),
|
||||||
array('post_id' => 2),
|
array('post_id' => 2),
|
||||||
array('post_id' => 3),
|
array('post_id' => 3),
|
||||||
|
array('post_id' => 4),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts
|
||||||
array(
|
array(
|
||||||
'phpbb_posts',
|
'phpbb_posts',
|
||||||
|
0,
|
||||||
|
false,
|
||||||
'post', 1, '',
|
'post', 1, '',
|
||||||
array(
|
array(
|
||||||
),
|
),
|
||||||
|
@ -42,8 +49,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
|
||||||
array('post_id' => 2),
|
array('post_id' => 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// data set 2: display_unapproved_posts=false, moderator, can see all topics
|
||||||
array(
|
array(
|
||||||
'phpbb_topics',
|
'phpbb_topics',
|
||||||
|
0,
|
||||||
|
false,
|
||||||
'topic', 1, '',
|
'topic', 1, '',
|
||||||
array(
|
array(
|
||||||
array('m_approve', 1, true),
|
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' => 1),
|
||||||
array('topic_id' => 2),
|
array('topic_id' => 2),
|
||||||
array('topic_id' => 3),
|
array('topic_id' => 3),
|
||||||
|
array('topic_id' => 4),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic
|
||||||
array(
|
array(
|
||||||
'phpbb_topics',
|
'phpbb_topics',
|
||||||
|
0,
|
||||||
|
false,
|
||||||
'topic', 1, '',
|
'topic', 1, '',
|
||||||
array(),
|
array(),
|
||||||
array(
|
array(
|
||||||
array('topic_id' => 2),
|
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
|
* @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;
|
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_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||||
$lang = new \phpbb\language\language($lang_loader);
|
$lang = new \phpbb\language\language($lang_loader);
|
||||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
$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();
|
$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);
|
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue