From 3d79ce28031b4c85ee34bd4d43f0c64b18b1a80b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 12 Oct 2012 16:54:42 -0500 Subject: [ticket/11103] Ability to query data before running create_insert_array() Mark post/topic in queue notifications read when visiting mcp Change post/topic in queue notification url to use MCP. Fix the bug: Approving a topic marks the topic as read, but before the notification is created for the user approving the topic (if they would get a notification that the topic has been made). This causes it to be stuck "unread". PHPBB3-11103 --- phpBB/includes/notification/manager.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/notification/manager.php') diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index c5fd41c901..6c74fa965e 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -324,8 +324,6 @@ class phpbb_notification_manager // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item - // todo Users should not receive notifications from multiple events from the same item (ex: for a topic reply with a quote including your username) - // Probably should be handled within each type? $sql = 'SELECT user_id FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . $this->db->sql_escape($item_type) . "' @@ -342,6 +340,11 @@ class phpbb_notification_manager return; } + // Allow notifications to perform actions before creating the insert array (such as run a query to cache some data needed for all notifications) + $notification = $this->get_item_type_class($item_type_class_name); + $pre_create_data = $notification->pre_create_insert_array($data, $notify_users); + unset($notification); + // Go through each user so we can insert a row in the DB and then notify them by their desired means foreach ($notify_users as $user => $methods) { @@ -350,7 +353,7 @@ class phpbb_notification_manager $notification->user_id = (int) $user; // Store the creation array in our new rows that will be inserted later - $new_rows[] = $notification->create_insert_array($data); + $new_rows[] = $notification->create_insert_array($data, $pre_create_data); // Users are needed to send notifications $user_ids = array_merge($user_ids, $notification->users_to_query()); -- cgit v1.2.1