From 64820546d758b34720888311d0abffcf95609436 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 4 Oct 2012 13:40:40 -0500 Subject: [ticket/11103] Move notification files to includes/notification/ PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 104 +++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 phpBB/includes/notification/method/email.php (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php new file mode 100644 index 0000000000..1b6b44d137 --- /dev/null +++ b/phpBB/includes/notification/method/email.php @@ -0,0 +1,104 @@ +queue)) + { + return; + } + + // Load all users we want to notify (we need their email address) + $user_ids = $users = array(); + foreach ($this->queue as $notification) + { + $user_ids[] = $notification->user_id; + } + + // We do not send emails to banned users + if (!function_exists('phpbb_get_banned_user_ids')) + { + include($this->phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $this->phpbb_container->getParameter('core.php_ext')); + } + $banned_users = phpbb_get_banned_user_ids($user_ids); + + // Load all the users we need + $this->service->load_users($user_ids); + + // Load the messenger + if (!class_exists('messenger')) + { + include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); + } + $messenger = new messenger(); + $board_url = generate_board_url(); + + // Time to go through the queue and send emails + foreach ($this->queue as $notification) + { + $user = $this->service->get_user($notification->user_id); + + if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) + { + continue; + } + + $messenger->template($notification->email_template, $user['user_lang']); + + $messenger->to($user['user_email'], $user['username']); + + $messenger->assign_vars(array_merge(array( + 'USERNAME' => $user['username'], + + 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications', + ), $notification->get_email_template_variables())); + + $messenger->send($this->notify_method); + } + + // Save the queue in the messenger class (has to be called or these emails could be lost?) + $messenger->save_queue(); + + // We're done, empty the queue + $this->empty_queue(); + } +} -- cgit v1.2.1 From cea94d89848a806f449610ddb2a7df7b7eec1328 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 4 Oct 2012 14:27:43 -0500 Subject: [ticket/11103] Use dependency injection instead of phpbb_container PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index 1b6b44d137..c2e272aca1 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -57,12 +57,12 @@ class phpbb_notification_method_email extends phpbb_notification_method_base // We do not send emails to banned users if (!function_exists('phpbb_get_banned_user_ids')) { - include($this->phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $this->phpbb_container->getParameter('core.php_ext')); + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); } $banned_users = phpbb_get_banned_user_ids($user_ids); // Load all the users we need - $this->service->load_users($user_ids); + $this->notification_manager->load_users($user_ids); // Load the messenger if (!class_exists('messenger')) @@ -75,7 +75,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base // Time to go through the queue and send emails foreach ($this->queue as $notification) { - $user = $this->service->get_user($notification->user_id); + $user = $this->notification_manager->get_user($notification->user_id); if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) { -- cgit v1.2.1 From f96dac335287f2fd51ff6628facbc8b6af6a517f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 18 Oct 2012 19:13:47 -0500 Subject: [ticket/11103] Interface docblocks PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index c2e272aca1..e902ea1e85 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -40,6 +40,9 @@ class phpbb_notification_method_email extends phpbb_notification_method_base return true; } + /** + * Parse the queue and notify the users + */ public function notify() { if (!sizeof($this->queue)) -- cgit v1.2.1 From 0ac9079d1c4e32ae04bb7b5da55fa030279ec9b5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 20 Oct 2012 18:55:13 -0500 Subject: [ticket/11103] Replace $email_template with get_email_template() PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index e902ea1e85..df7edb13e7 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -78,6 +78,11 @@ class phpbb_notification_method_email extends phpbb_notification_method_base // Time to go through the queue and send emails foreach ($this->queue as $notification) { + if ($notification->get_email_template() === false) + { + continue; + } + $user = $this->notification_manager->get_user($notification->user_id); if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) @@ -85,7 +90,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base continue; } - $messenger->template($notification->email_template, $user['user_lang']); + $messenger->template($notification->get_email_template(), $user['user_lang']); $messenger->to($user['user_email'], $user['username']); -- cgit v1.2.1 From f09ee162528d931aabc3f216410d02d3a072c21d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 9 Nov 2012 07:40:08 -0600 Subject: [ticket/11103] Use phpBB Container to load types/methods PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index df7edb13e7..a47284bc61 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -23,6 +23,16 @@ if (!defined('IN_PHPBB')) */ class phpbb_notification_method_email extends phpbb_notification_method_base { + /** + * Get notification method name + * + * @return string + */ + public function get_type() + { + return 'email'; + } + /** * Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication) * -- cgit v1.2.1 From 7948aaa78ed7e543a0773ee1a858ef45f5e5a5bf Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 11 Nov 2012 11:41:18 -0600 Subject: [ticket/11103] Make jabber use short/ email template files PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index a47284bc61..2ff30b177f 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -40,6 +40,13 @@ class phpbb_notification_method_email extends phpbb_notification_method_base */ protected $notify_method = NOTIFY_EMAIL; + /** + * Base directory to prepend to the email template name + * + * @var string + */ + protected $email_template_base_dir = ''; + /** * Is this method available for the user? * This is checked on the notifications options @@ -100,7 +107,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base continue; } - $messenger->template($notification->get_email_template(), $user['user_lang']); + $messenger->template($this->email_template_base_dir . $notification->get_email_template(), $user['user_lang']); $messenger->to($user['user_email'], $user['username']); -- cgit v1.2.1 From 2afb8b9df873c3f9572a32ab7a62ea8ba8d8a45b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 18:14:48 -0600 Subject: [ticket/11103] Create user loader class, update for DIC Create a very basic user loader class to handle querying/storing user data in a centralized location. Use DIC collection service for notification types/methods. Cleanup unused dependencies. Fix some other issues. PHPBB3-11103 --- phpBB/includes/notification/method/email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/notification/method/email.php') diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index 2ff30b177f..429dfda2ba 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -82,7 +82,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base $banned_users = phpbb_get_banned_user_ids($user_ids); // Load all the users we need - $this->notification_manager->load_users($user_ids); + $this->user_loader->load_users($user_ids); // Load the messenger if (!class_exists('messenger')) @@ -100,7 +100,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base continue; } - $user = $this->notification_manager->get_user($notification->user_id); + $user = $this->user_loader->get_user($notification->user_id); if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) { -- cgit v1.2.1