mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 20:38:52 +00:00
Merge pull request #3234 from brunoais/ticket/13154
[ticket/13154] Event to edit user list for notification in notifications
This commit is contained in:
commit
e3e16a0166
4 changed files with 31 additions and 2 deletions
|
@ -7,6 +7,7 @@ services:
|
||||||
- @service_container
|
- @service_container
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @config
|
- @config
|
||||||
|
- @dispatcher
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
|
|
|
@ -38,6 +38,9 @@ class manager
|
||||||
/** @var \phpbb\config\config */
|
/** @var \phpbb\config\config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** @var \phpbb\event\dispatcher */
|
||||||
|
protected $phpbb_dispatcher;
|
||||||
|
|
||||||
/** @var \phpbb\db\driver\driver_interface */
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
|
@ -70,6 +73,7 @@ class manager
|
||||||
* @param ContainerInterface $phpbb_container
|
* @param ContainerInterface $phpbb_container
|
||||||
* @param \phpbb\user_loader $user_loader
|
* @param \phpbb\user_loader $user_loader
|
||||||
* @param \phpbb\config\config $config
|
* @param \phpbb\config\config $config
|
||||||
|
* @param \phpbb\event\dispatcher $phpbb_dispatcher
|
||||||
* @param \phpbb\db\driver\driver_interface $db
|
* @param \phpbb\db\driver\driver_interface $db
|
||||||
* @param \phpbb\cache\service $cache
|
* @param \phpbb\cache\service $cache
|
||||||
* @param \phpbb\user $user
|
* @param \phpbb\user $user
|
||||||
|
@ -81,7 +85,7 @@ class manager
|
||||||
*
|
*
|
||||||
* @return \phpbb\notification\manager
|
* @return \phpbb\notification\manager
|
||||||
*/
|
*/
|
||||||
public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
|
public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\event\dispatcher $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
|
||||||
{
|
{
|
||||||
$this->notification_types = $notification_types;
|
$this->notification_types = $notification_types;
|
||||||
$this->notification_methods = $notification_methods;
|
$this->notification_methods = $notification_methods;
|
||||||
|
@ -89,6 +93,7 @@ class manager
|
||||||
|
|
||||||
$this->user_loader = $user_loader;
|
$this->user_loader = $user_loader;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->phpbb_dispatcher = $phpbb_dispatcher;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
@ -350,6 +355,26 @@ class manager
|
||||||
// find out which users want to receive this type of notification
|
// find out which users want to receive this type of notification
|
||||||
$notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options);
|
$notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow filtering the notify_users array for a notification that is about to be sent.
|
||||||
|
* Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
|
||||||
|
*
|
||||||
|
* @event core.notification_manager_add_notifications
|
||||||
|
* @var string notification_type_name The forum id from where the topic belongs
|
||||||
|
* @var array data Data specific for the notification_type_name used will be inserted
|
||||||
|
* @var array notify_users The array of userid that are going to be notified for this notification. Set to array() to cancel.
|
||||||
|
* @var array options The options that were used when this method was called (read only)
|
||||||
|
*
|
||||||
|
* @since 3.1.3-RC1
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'notification_type_name',
|
||||||
|
'data',
|
||||||
|
'notify_users',
|
||||||
|
'options',
|
||||||
|
);
|
||||||
|
extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars)));
|
||||||
|
|
||||||
$this->add_notifications_for_users($notification_type_name, $data, $notify_users);
|
$this->add_notifications_for_users($notification_type_name, $data, $notify_users);
|
||||||
|
|
||||||
return $notify_users;
|
return $notify_users;
|
||||||
|
|
|
@ -67,6 +67,8 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
|
||||||
$phpEx
|
$phpEx
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||||
|
|
||||||
$phpbb_container = $this->container = new phpbb_mock_container_builder();
|
$phpbb_container = $this->container = new phpbb_mock_container_builder();
|
||||||
|
|
||||||
$this->notifications = new phpbb_notification_manager_helper(
|
$this->notifications = new phpbb_notification_manager_helper(
|
||||||
|
@ -75,6 +77,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
|
||||||
$this->container,
|
$this->container,
|
||||||
$this->user_loader,
|
$this->user_loader,
|
||||||
$this->config,
|
$this->config,
|
||||||
|
$this->phpbb_dispatcher,
|
||||||
$this->db,
|
$this->db,
|
||||||
$this->cache,
|
$this->cache,
|
||||||
$this->user,
|
$this->user,
|
||||||
|
|
|
@ -123,7 +123,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||||
|
|
||||||
// Notification Manager
|
// Notification Manager
|
||||||
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(),
|
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(),
|
||||||
$phpbb_container, $user_loader, $config, $db, $cache, $user,
|
$phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user,
|
||||||
$phpbb_root_path, $phpEx,
|
$phpbb_root_path, $phpEx,
|
||||||
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
|
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
|
||||||
$phpbb_container->set('notification_manager', $phpbb_notifications);
|
$phpbb_container->set('notification_manager', $phpbb_notifications);
|
||||||
|
|
Loading…
Add table
Reference in a new issue