From e5b43eabe1cd3bd19669c2810fe3df391974bf95 Mon Sep 17 00:00:00 2001 From: DSR! Date: Fri, 27 Aug 2021 11:58:55 -0300 Subject: [PATCH 1/2] [ticket/16828] Add hook event before find_users_for_notification() execute PHPBB3-16828 --- phpBB/phpbb/notification/manager.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index ace08e6cf6..fcae2ef9ff 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -255,6 +255,31 @@ class manager 'ignore_users' => array(), ), $options); + $break = false; + + /** + * Get notification data before find_users_for_notification() execute + * + * @event core.notification_manager_add_notifications_before + * @var bool break Flag indicating if the function return after hook + * @var array notification_type_name Type identifier or array of item types + * @var string data Data specific for this type that will be inserted + * @var string options Optional options to control what notifications are loaded + * @since 3.3.5-RC1 + */ + $vars = [ + 'break', + 'notification_type_name', + 'data', + 'options', + ]; + extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications_before', compact($vars))); + + if ($break) + { + return []; + } + if (is_array($notification_type_name)) { $notified_users = array(); From 3103e99dc7d5484f1a6882170c2ff297f4ff5c17 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 19 Jan 2022 20:30:25 +0100 Subject: [PATCH 2/2] [ticket/16828] Adjust event to allow modifying notified_users and early return PHPBB3-16828 --- phpBB/phpbb/notification/manager.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index fcae2ef9ff..8bc2c04baa 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -255,34 +255,36 @@ class manager 'ignore_users' => array(), ), $options); - $break = false; + $notified_users = []; + $add_notifications_override = false; /** * Get notification data before find_users_for_notification() execute * * @event core.notification_manager_add_notifications_before - * @var bool break Flag indicating if the function return after hook - * @var array notification_type_name Type identifier or array of item types - * @var string data Data specific for this type that will be inserted - * @var string options Optional options to control what notifications are loaded - * @since 3.3.5-RC1 + * @var bool add_notifications_override Flag indicating whether function should return after event + * @var array|string notification_type_name Type identifier or array of item types + * @var string data Data specific for this notification type that will be inserted + * @var array notified_users Array of notified users + * @var string options Optional options to control what notifications are loaded + * @since 3.3.6-RC1 */ $vars = [ - 'break', + 'add_notifications_override', 'notification_type_name', 'data', + 'notified_users', 'options', ]; extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications_before', compact($vars))); - if ($break) + if ($add_notifications_override) { - return []; + return $notified_users; } if (is_array($notification_type_name)) { - $notified_users = array(); $temp_options = $options; foreach ($notification_type_name as $type)