From 5fbd4584be49e416642ca1593084bca15fc60d30 Mon Sep 17 00:00:00 2001 From: Toxyy Date: Mon, 9 Jul 2018 16:54:11 -0400 Subject: [PATCH] [ticket/15719] Add core events to viewtopic to edit the post_list sql query Event added in viewtopic.php so you can modify post_list sql The query, sql limit, sql start, sort keys and days are editable PHPBB3-15719 --- phpBB/viewtopic.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 3c25c3b037..20316afb32 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1148,6 +1148,29 @@ $sql = 'SELECT p.post_id " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; + +/** +* Event to modify the SQL query that gets post_list +* +* @event core.viewtopic_modify_post_list_sql +* @var string sql The SQL query to generate the post_list +* @var int sql_limit The number of posts the query fetches +* @var int sql_start The index the query starts to fetch from +* @var string sort_key Key the posts are sorted by +* @var string sort_days Display posts of previous x days +* @var int forum_id Forum ID +* @since 3.2.4-RC1 +*/ +$vars = array( + 'sql', + 'sql_limit', + 'sql_start', + 'sort_key', + 'sort_days', + 'forum_id', +); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_list_sql', compact($vars))); + $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $i = ($store_reverse) ? $sql_limit - 1 : 0;