From 1dce9576e99d114c482ea79f5c17fb0380e13eba Mon Sep 17 00:00:00 2001
From: Wolfsblvt <clemenshusung@gmx.de>
Date: Wed, 21 Jan 2015 12:38:15 +0100
Subject: [ticket/13532] Add core event to get_unread_topics() in functions.php

Adding core event core.get_unread_topics_modify_sql to to funtion
get_unread_topics() in functions.php, so that you now are able to modify
the sql query that retrieves the unread topics.

PHPBB3-13532
---
 phpBB/includes/functions.php | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'phpBB/includes')

diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 1a3560dbb1..5408f7e281 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1648,6 +1648,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
 function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0)
 {
 	global $config, $db, $user;
+	global $phpbb_dispatcher;
 
 	$user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id;
 
@@ -1691,6 +1692,24 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
 				$sql_sort",
 		);
 
+		/**
+		 * Change SQL query for fetching unread topics data
+		 *
+		 * @event core.get_unread_topics_modify_sql
+		 * @var array     sql_array    Fully assembled SQL query with keys SELECT, FROM, LEFT_JOIN, WHERE
+		 * @var int       last_mark    User's last_mark time
+		 * @var string    sql_extra    Extra WHERE SQL statement
+		 * @var string    sql_sort     ORDER BY SQL sorting statement
+		 * @since 3.1.4-RC1
+		 */
+		$vars = array(
+			'sql_array',
+			'last_mark',
+			'sql_extra',
+			'sql_sort',
+		);
+		extract($phpbb_dispatcher->trigger_event('core.get_unread_topics_modify_sql', compact($vars)));
+
 		$sql = $db->sql_build_query('SELECT', $sql_array);
 		$result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset);
 
-- 
cgit v1.2.1