[ticket/16828] Adjust event to allow modifying notified_users and early return

PHPBB3-16828
This commit is contained in:
Marc Alexander 2022-01-19 20:30:25 +01:00
parent e5b43eabe1
commit 3103e99dc7
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -255,34 +255,36 @@ class manager
'ignore_users' => array(), 'ignore_users' => array(),
), $options); ), $options);
$break = false; $notified_users = [];
$add_notifications_override = false;
/** /**
* Get notification data before find_users_for_notification() execute * Get notification data before find_users_for_notification() execute
* *
* @event core.notification_manager_add_notifications_before * @event core.notification_manager_add_notifications_before
* @var bool break Flag indicating if the function return after hook * @var bool add_notifications_override Flag indicating whether function should return after event
* @var array notification_type_name Type identifier or array of item types * @var array|string notification_type_name Type identifier or array of item types
* @var string data Data specific for this type that will be inserted * @var string data Data specific for this notification type that will be inserted
* @var string options Optional options to control what notifications are loaded * @var array notified_users Array of notified users
* @since 3.3.5-RC1 * @var string options Optional options to control what notifications are loaded
* @since 3.3.6-RC1
*/ */
$vars = [ $vars = [
'break', 'add_notifications_override',
'notification_type_name', 'notification_type_name',
'data', 'data',
'notified_users',
'options', 'options',
]; ];
extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications_before', compact($vars))); 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)) if (is_array($notification_type_name))
{ {
$notified_users = array();
$temp_options = $options; $temp_options = $options;
foreach ($notification_type_name as $type) foreach ($notification_type_name as $type)