From fa474c4378dc22e586f46f7a0e32df83d6a5c801 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 5 Mar 2015 16:19:36 +0000 Subject: [PATCH 1/4] [ticket/13668] Convert the mcp report_details query to a built query PHPBB3-13668 --- phpBB/includes/mcp/mcp_reports.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 804d48ea97..856c8794e2 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -73,14 +73,23 @@ class mcp_reports // closed reports are accessed by report id $report_id = request_var('r', 0); + $sql_ary = array( + 'SELECT' => 'r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour', - $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour - FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u - WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' + 'FROM' => array( + REPORTS_TABLE => 'r', + REPORTS_REASONS_TABLE => 'rr', + USERS_TABLE => 'u', + ), + + 'WHERE' => '' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id - AND r.pm_id = 0 - ORDER BY report_closed ASC'; + AND r.pm_id = 0', + + 'ORDER_BY' => 'report_closed ASC', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); From 8a6d55520d5165e2abdd3a48ef70be2a2b4e8308 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 5 Mar 2015 16:21:23 +0000 Subject: [PATCH 2/4] [ticket/13668] Allow changing the query to obtain the user-submitted report. PHPBB3-13668 --- phpBB/includes/mcp/mcp_reports.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 856c8794e2..5d3732e12c 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -89,6 +89,25 @@ class mcp_reports 'ORDER_BY' => 'report_closed ASC', ); + + /** + * Allow changing the query to obtain the user-submitted report. + * + * @event core.mcp_reports_report_details_query_before + * @var array sql_ary The array in the format of the query builder with the query + * @var mixed forum_id The forum_id, the number in the f GET parameter + * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) + * @var int report_id The report_id of the report being viewed + * @since 3.1.4-RC1 + */ + $vars = array( + 'sql_ary', + 'forum_id', + 'post_id', + 'report_id', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_before', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); From 9e06beb48d2bb49108550e61369f31ae6c11eae0 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 6 May 2015 22:56:22 +0100 Subject: [PATCH 3/4] [ticket/13668] BUMP version to 3.1.5-dev PHPBB3-13668 --- phpBB/includes/mcp/mcp_reports.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 5d3732e12c..d973d9c14d 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -98,7 +98,7 @@ class mcp_reports * @var mixed forum_id The forum_id, the number in the f GET parameter * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) * @var int report_id The report_id of the report being viewed - * @since 3.1.4-RC1 + * @since 3.1.5-RC1 */ $vars = array( 'sql_ary', From d4fb3996d3a7fc14021136211d9f70610c7aeba0 Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 8 May 2015 10:41:42 +0100 Subject: [PATCH 4/4] [ticket/13668] Removed bogus sting concatenation PHPBB3-13668 --- phpBB/includes/mcp/mcp_reports.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index d973d9c14d..56a1bb4df2 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -82,7 +82,7 @@ class mcp_reports USERS_TABLE => 'u', ), - 'WHERE' => '' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' + 'WHERE' => (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id AND r.pm_id = 0',