From c5917dec7a11bb0cfdad37de43ac3ca3c597b236 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: [PATCH 1/2] [ticket/9837] Display unapproved posts to their authors Basic functionality mock up. PHPBB3-9837 --- phpBB/phpbb/content_visibility.php | 15 +++++++++++++-- .../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 704ec6badba..4633ec24c2b 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -144,7 +144,12 @@ public function get_count($mode, $data, $forum_id) */ 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 @@ public function get_visibility_sql($mode, $forum_id, $table_alias = '') } 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 b2d317764d9..b68ce3eb0e1 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -294,6 +294,7 @@

class="first"> +

@@ -304,6 +305,11 @@

class="first"> +

+ {L_POST_UNAPPROVED} +

+

diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 2788295b680..909a9fe4dbf 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -1151,3 +1151,7 @@ input.disabled { background-color: #d41142; color: #ffffff; } + +p.information { + background-color: #b8d3e0; +} diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 3c25c3b0372..553b2b79b48 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1993,6 +1993,7 @@ 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && count($attachments[$row['post_id']]) > 1, 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) ? true : false, + 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, 'L_POST_DELETED_MESSAGE' => $l_deleted_message, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, From 35caaa0da5fe2edb00943623b6e673674388ce4d 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: [PATCH 2/2] [ticket/9837] Small fixes PHPBB3-9837 --- phpBB/phpbb/content_visibility.php | 7 ++++--- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/prosilver/theme/colours.css | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 4633ec24c2b..8249e9c36d4 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -146,9 +146,10 @@ public function is_visible($mode, $forum_id, $data) { $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] + $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] ); /** diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index b68ce3eb0e1..ee4bb088c70 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -306,7 +306,7 @@

class="first"> -

+

{L_POST_UNAPPROVED}

diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 909a9fe4dbf..ec27e1736ad 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -1152,6 +1152,6 @@ input.disabled { color: #ffffff; } -p.information { +.information { background-color: #b8d3e0; }