From 3e451cbe7584221567b7eb9240384e8fa51e7460 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 26 Feb 2015 10:05:12 +0000 Subject: [ticket/13142] Delete event in order to move it. PHPBB3-13142 --- phpBB/includes/functions_mcp.php | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'phpBB/includes/functions_mcp.php') diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php index 4a03ea8f13..811d49f1de 100644 --- a/phpBB/includes/functions_mcp.php +++ b/phpBB/includes/functions_mcp.php @@ -423,28 +423,6 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by AND t.topic_id = p.topic_id AND t.topic_visibility <> p.post_visibility'; - /** - * This event allows you to control the SQL query to retrieve the list of unapproved and deleted posts - * - * @event core.mcp_sorting_unapproved_deleted_posts_query_before - * @var string sql The current SQL search string - * @var int forum_id The forum id of the posts the user is trying to access - * @var int topic_id The topic id of the posts the user is trying to access - * @var int min_time Integer with the minimum post time that the user is searching for - * @var int visibility_const Integer with one of the possible ITEM_* constant values - * @var string where_sql Extra information included in the WHERE clause. It must end with "WHERE" or "AND" or "OR" - * @since 3.1.4-RC1 - */ - $vars = array( - 'sql', - 'forum_id', - 'topic_id', - 'min_time', - 'visibility_const', - 'where_sql', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_sorting_unapproved_deleted_posts_query_before', compact($vars))); - if ($min_time) { $sql .= ' AND post_time >= ' . $min_time; -- cgit v1.2.1 From ec855f1817826604d215f0d5a913a87d6c268df1 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 26 Feb 2015 13:07:35 +0000 Subject: [ticket/13142] Place the event in the most meaningful place The event now has nearly all variables and it is in the place where it can most influence this method's outcome without requiring the extension to re-process phpBB's code. PHPBB3-13142 --- phpBB/includes/functions_mcp.php | 50 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_mcp.php') diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php index 811d49f1de..ad72a37d3a 100644 --- a/phpBB/includes/functions_mcp.php +++ b/phpBB/includes/functions_mcp.php @@ -553,6 +553,54 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by break; } + + /** + * This event allows you to control the SQL query used to get the total number + * of reports the user can access. + * + * This total is used for the pagination and for displaying the total number + * of reports to the user + * + * + * @event core.mcp_sorting_query_before + * @var string sql The current SQL search string + * @var string mode An id related to the module(s) the user is viewing + * @var string type Which kind of information is this being used for displaying. Posts, topics, etc... + * @var int forum_id The forum id of the posts the user is trying to access, if not 0 + * @var int topic_id The topic id of the posts the user is trying to access, if not 0 + * @var int sort_days The max age of the oldest report to be shown, in days + * @var string sort_key The way the user has decided to sort the data. + * The valid values must be in the keys of the sort_by_* variables + * @var string sort_dir Either 'd' for "DESC" or 'a' for 'ASC' in the SQL query + * @var int limit_days The possible max ages of the oldest report for the user to choose, in days. + * @var array sort_by_sql SQL text (values) for the possible names of the ways of sorting data (keys). + * @var array sort_by_text Language text (values) for the possible names of the ways of sorting data (keys). + * @var int min_time Integer with the minimum post time that the user is searching for + * @var int limit_time_sql Time limiting options used in the SQL query. + * @var int total The total number of reports that exist. Only set if you want to override the result + * @var string where_sql Extra information included in the WHERE clause. It must end with "WHERE" or "AND" or "OR". + * Set to "WHERE" and set total above -1 to override the total value + * @since 3.1.4-RC1 + */ + $vars = array( + 'sql', + 'mode', + 'type', + 'forum_id', + 'topic_id', + 'sort_days', + 'sort_key', + 'sort_dir', + 'limit_days', + 'sort_by_sql', + 'sort_by_text', + 'min_time', + 'limit_time_sql', + 'total', + 'where_sql', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_sorting_query_before', compact($vars))); + if (!isset($sort_by_sql[$sort_key])) { $sort_key = $default_key; @@ -584,7 +632,7 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); } - else + else if ( $total < -1) { $total = -1; } -- cgit v1.2.1 From 1e73f8d5eafda476192d95bc5ff8ec8b48d75381 Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 27 Feb 2015 08:34:28 +0000 Subject: [ticket/13142] Removed surperfulous new line PHPBB3-13142 --- phpBB/includes/functions_mcp.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions_mcp.php') diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php index ad72a37d3a..1883cb2d87 100644 --- a/phpBB/includes/functions_mcp.php +++ b/phpBB/includes/functions_mcp.php @@ -553,7 +553,6 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by break; } - /** * This event allows you to control the SQL query used to get the total number * of reports the user can access. -- cgit v1.2.1 From df9331084bc84fd84ef8bc582db17f85ddc0a282 Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 27 Feb 2015 10:42:27 +0000 Subject: [ticket/13142] Removed surperfulous space PHPBB3-13142 --- phpBB/includes/functions_mcp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_mcp.php') diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php index 1883cb2d87..13c1299928 100644 --- a/phpBB/includes/functions_mcp.php +++ b/phpBB/includes/functions_mcp.php @@ -631,7 +631,7 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); } - else if ( $total < -1) + else if ($total < -1) { $total = -1; } -- cgit v1.2.1 From c37d5f9b7c3c03a8f1dd4c130054caa922f8b34b Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 27 Feb 2015 22:51:32 +0000 Subject: [ticket/13142] Default $total to -1 before the event for more flexibility PHPBB3-13142 --- phpBB/includes/functions_mcp.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/functions_mcp.php') diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php index 13c1299928..2780faa7fa 100644 --- a/phpBB/includes/functions_mcp.php +++ b/phpBB/includes/functions_mcp.php @@ -553,6 +553,9 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by break; } + // Default total to -1 to allow editing by the event + $total = -1; + /** * This event allows you to control the SQL query used to get the total number * of reports the user can access. -- cgit v1.2.1