From 7512efed9e440fe7be55c3882c694f2b10ce16eb Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 17 Dec 2014 15:17:44 +0000 Subject: [PATCH 1/8] [ticket/13154] Allow filtering the list of users to be notified PHPBB3-13154 --- phpBB/phpbb/notification/manager.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index dd611e1dd1..e8cfae9b53 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -350,6 +350,26 @@ class manager // 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); + /** + * 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($phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars))); + $this->add_notifications_for_users($notification_type_name, $data, $notify_users); return $notify_users; From 458f9cade60e145a2657a7080f0e2968d1f0c6cb Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 17 Dec 2014 23:10:37 +0000 Subject: [PATCH 2/8] [ticket/13154] Adding phpBB dispatcher to notifications manager PHPBB3-13154 --- phpBB/config/notification.yml | 1 + phpBB/phpbb/notification/manager.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/phpBB/config/notification.yml b/phpBB/config/notification.yml index add577be2c..b17a172fb5 100644 --- a/phpBB/config/notification.yml +++ b/phpBB/config/notification.yml @@ -7,6 +7,7 @@ services: - @service_container - @user_loader - @config + - @dispatcher - @dbal.conn - @cache - @user diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index e8cfae9b53..c3fa04b457 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -38,6 +38,9 @@ class manager /** @var \phpbb\config\config */ protected $config; + /** @var \phpbb\event\dispatcher */ + protected $phpbb_dispatcher; + /** @var \phpbb\db\driver\driver_interface */ protected $db; @@ -70,6 +73,7 @@ class manager * @param ContainerInterface $phpbb_container * @param \phpbb\user_loader $user_loader * @param \phpbb\config\config $config + * @param \phpbb\event\dispatcher $config * @param \phpbb\db\driver\driver_interface $db * @param \phpbb\cache\service $cache * @param \phpbb\user $user @@ -81,7 +85,7 @@ class 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_methods = $notification_methods; @@ -89,6 +93,7 @@ class manager $this->user_loader = $user_loader; $this->config = $config; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->db = $db; $this->cache = $cache; $this->user = $user; From 8098d313e6b56822b202ff3be8c12762dfc33bf7 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 17 Dec 2014 23:11:14 +0000 Subject: [PATCH 3/8] [ticket/13154] Adjusting phpBB tests for the dispatcher PHPBB3-13154 --- tests/notification/base.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/notification/base.php b/tests/notification/base.php index c97b7c24e2..ee8c8e0f3b 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -66,6 +66,8 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $phpbb_root_path, $phpEx ); + + $phpbb_dispatcher = $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = $this->container = new phpbb_mock_container_builder(); @@ -75,6 +77,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $this->container, $this->user_loader, $this->config, + $this->phpbb_dispatcher, $this->db, $this->cache, $this->user, From 13320a08ef4f9dddeac5b93d4186f6bf05256466 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 17 Dec 2014 23:17:12 +0000 Subject: [PATCH 4/8] [ticket/13154] Forgot the $this-> PHPBB3-13154 --- phpBB/phpbb/notification/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index c3fa04b457..8eda8dc17b 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -373,7 +373,7 @@ class manager 'notify_users', 'options', ); - extract($phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars))); + extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars))); $this->add_notifications_for_users($notification_type_name, $data, $notify_users); From dd6efdad595f5a2ee107b0f2de0ce888e94e3293 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 18 Dec 2014 14:54:35 +0000 Subject: [PATCH 5/8] [ticket/13154] Fix submit_post_test() test group PHPBB3-13154 --- tests/notification/submit_post_base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 684dd99280..2d636e9d93 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -122,7 +122,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Notification Manager $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, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications); From dd9c415020935710aa525bd99a592e26e6143165 Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 19 Dec 2014 10:03:57 +0000 Subject: [PATCH 6/8] [ticket/13154] space before @var Not a tab. PHPBB3-13154 --- phpBB/phpbb/notification/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 8eda8dc17b..4bf61170b2 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -38,7 +38,7 @@ class manager /** @var \phpbb\config\config */ protected $config; - /** @var \phpbb\event\dispatcher */ + /** @var \phpbb\event\dispatcher */ protected $phpbb_dispatcher; /** @var \phpbb\db\driver\driver_interface */ From 0929267e722c9aa3019a46509950ce3b74ba9c83 Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 19 Dec 2014 11:23:23 +0000 Subject: [PATCH 7/8] [ticket/13154] Wrong variable name in the comment block PHPBB3-13154 --- phpBB/phpbb/notification/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 4bf61170b2..aa52eb61d0 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -73,7 +73,7 @@ class manager * @param ContainerInterface $phpbb_container * @param \phpbb\user_loader $user_loader * @param \phpbb\config\config $config - * @param \phpbb\event\dispatcher $config + * @param \phpbb\event\dispatcher $phpbb_dispatcher * @param \phpbb\db\driver\driver_interface $db * @param \phpbb\cache\service $cache * @param \phpbb\user $user From 2b76d7dc7c21d927398fdb5abe7b60875badc6ce Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 17:06:51 +0000 Subject: [PATCH 8/8] [ticket/13154] Don't assign dispatcher to a variable. Just the obj param. PHPBB3-13154 --- tests/notification/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/notification/base.php b/tests/notification/base.php index ee8c8e0f3b..162feae557 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -67,7 +67,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $phpEx ); - $phpbb_dispatcher = $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = $this->container = new phpbb_mock_container_builder();