From c67dd0c5912844a50323b97e8fecb30d21bb361c Mon Sep 17 00:00:00 2001 From: DSR! Date: Sat, 3 Mar 2018 12:12:38 -0300 Subject: [PATCH 1/2] [ticket/15836] Event to send message via external transport PHPBB3-15836 --- phpBB/includes/functions_messenger.php | 81 +++++++++++++++++++++----- 1 file changed, 65 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index fdd1dc6e32..7b530d7119 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -521,7 +521,7 @@ class messenger */ function msg_email() { - global $config; + global $config, $phpbb_dispatcher; if (empty($config['email_enable'])) { @@ -549,6 +549,33 @@ class messenger $contact_name = htmlspecialchars_decode($config['board_contact_name']); $board_contact = (($contact_name !== '') ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>'; + $break = false; + $addresses = $this->addresses; + $subject = $this->subject; + $msg = $this->msg; + /** + * Event to send message via external transport + * + * @event core.notification_message_email + * @var bool break Flag indicating if the function return after hook + * @var array addresses The message recipients + * @var string subject The message subject + * @var string msg The message text + * @since 3.2.4-RC1 + */ + $vars = array( + 'break', + 'addresses', + 'subject', + 'msg', + ); + extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars))); + + if ($break) + { + return true; + } + if (empty($this->replyto)) { $this->replyto = $board_contact; @@ -787,7 +814,7 @@ class queue */ function process() { - global $config, $phpEx, $phpbb_root_path, $user; + global $config, $phpEx, $phpbb_root_path, $user, $phpbb_dispatcher; $lock = new \phpbb\lock\flock($this->cache_file); $lock->acquire(); @@ -884,23 +911,45 @@ class queue switch ($object) { case 'email': - $err_msg = ''; - $to = (!$to) ? 'undisclosed-recipients:;' : $to; + $break = false; + /** + * Event to send message via external transport + * + * @event core.notification_message_email + * @var bool break Flag indicating if the function return after hook + * @var array addresses The message recipients + * @var string subject The message subject + * @var string msg The message text + * @since 3.2.4-RC1 + */ + $vars = array( + 'break', + 'addresses', + 'subject', + 'msg', + ); + extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars))); - if ($config['smtp_delivery']) + if (!$break) { - $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); - } - else - { - $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg); - } + $err_msg = ''; + $to = (!$to) ? 'undisclosed-recipients:;' : $to; - if (!$result) - { - $messenger = new messenger(); - $messenger->error('EMAIL', $err_msg); - continue 2; + if ($config['smtp_delivery']) + { + $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); + } + else + { + $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg); + } + + if (!$result) + { + $messenger = new messenger(); + $messenger->error('EMAIL', $err_msg); + continue 2; + } } break; From dbd0304c1d659e938d4f311649631e7a6fdb32f6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Oct 2018 12:26:37 -0400 Subject: [PATCH 2/2] [ticket/15836] Rename event to have unique name PHPBB3-15836 --- phpBB/includes/functions_messenger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 7b530d7119..75c15657b0 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -915,7 +915,7 @@ class queue /** * Event to send message via external transport * - * @event core.notification_message_email + * @event core.notification_message_process * @var bool break Flag indicating if the function return after hook * @var array addresses The message recipients * @var string subject The message subject @@ -928,7 +928,7 @@ class queue 'subject', 'msg', ); - extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.notification_message_process', compact($vars))); if (!$break) {