From 262abe63fde7304061ae826165cf0eecf5f9171d Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 8 Oct 2014 17:19:22 +0800 Subject: [PATCH] MDL-46284 tool_messageinbound: Fail with warning if handler disabled If a handler is disabled, the user should be informed of this issue. This issue is a part of the MDL-47194 Task. This issue is a part of the MDL-39707 Epic. --- admin/tool/messageinbound/classes/manager.php | 9 +++++++++ .../tool/messageinbound/lang/en/tool_messageinbound.php | 1 + 2 files changed, 10 insertions(+) diff --git a/admin/tool/messageinbound/classes/manager.php b/admin/tool/messageinbound/classes/manager.php index ebfa8abca4d..e9f01089044 100644 --- a/admin/tool/messageinbound/classes/manager.php +++ b/admin/tool/messageinbound/classes/manager.php @@ -334,6 +334,15 @@ class manager { // Now pass it through the Inbound Message processor. $status = $this->addressmanager->process_envelope($recipient, $sender); + if (($status & ~ \core\message\inbound\address_manager::VALIDATION_DISABLED_HANDLER) !== $status) { + // The handler is disabled. + mtrace("-- Skipped message - Handler is disabled. Fail code {$status}"); + // In order to handle the user error, we need more information about the message being failed. + $this->process_message_data($envelope, $messagedata, $messageid); + $this->inform_user_of_error(get_string('handlerdisabled', 'tool_messageinbound', $this->currentmessagedata)); + return; + } + // Check the validation status early. No point processing garbage messages, but we do need to process it // for some validation failure types. if (!$this->passes_key_validation($status, $messageid)) { diff --git a/admin/tool/messageinbound/lang/en/tool_messageinbound.php b/admin/tool/messageinbound/lang/en/tool_messageinbound.php index 19c5c759d92..329c956f3ab 100644 --- a/admin/tool/messageinbound/lang/en/tool_messageinbound.php +++ b/admin/tool/messageinbound/lang/en/tool_messageinbound.php @@ -36,6 +36,7 @@ $string['enabled'] = 'Enabled'; $string['fixedvalidateaddress'] = 'Validate sender address'; $string['fixedvalidateaddress_help'] = 'You cannot change the address validation for this handler. This may be because the handler requires a specific setting.'; $string['fixedenabled_help'] = 'You cannot change the state of this handler. This may be because the handler is required by other handlers.'; +$string['handlerdisabled'] = 'The email handler you tried to contact has been disabled. Unable to process message at this time.'; $string['incomingmailconfiguration'] = 'Incoming mail configuration'; $string['incomingmailserversettings'] = 'Incoming mail server settings'; $string['incomingmailserversettings_desc'] = 'Moodle is capable of connecting to appropriately configured IMAP servers. You can specify the settings used to connect to your IMAP server here.';