From 38d93cb0ff10577601d63d6f86fe5a40caae13c6 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 30 Jan 2011 10:56:18 +0100 Subject: [PATCH] MDL-26046 prevent jabber messages wehn noemailever active Standardise also the debug when emailing message. --- config-dist.php | 3 ++- message/output/email/message_output_email.php | 8 +++++++- message/output/jabber/message_output_jabber.php | 8 +++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config-dist.php b/config-dist.php index f9909be891542..79e0d9d435cfb 100644 --- a/config-dist.php +++ b/config-dist.php @@ -379,7 +379,8 @@ // Prevent core_string_manager on-disk cache // $CFG->langstringcache = false; // NOT FOR PRODUCTION SERVERS! // -// When working with production data on test servers, no emails should ever be send to real users +// When working with production data on test servers, no emails or other messages +// should ever be send to real users // $CFG->noemailever = true; // NOT FOR PRODUCTION SERVERS! // // Divert all outgoing emails to this address to test and debug emailing features diff --git a/message/output/email/message_output_email.php b/message/output/email/message_output_email.php index 3edfb1f089bcc..90bf792396da1 100644 --- a/message/output/email/message_output_email.php +++ b/message/output/email/message_output_email.php @@ -38,7 +38,13 @@ class message_output_email extends message_output { * @param object $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid */ function send_message($eventdata) { - global $SITE; + global $CFG; + + if (!empty($CFG->noemailever)) { + // hidden setting for development sites, set in config.php if needed + debugging('$CFG->noemailever active, no email message sent.', DEBUG_MINIMAL); + return true; + } //hold onto email preference because /admin/cron.php sends a lot of messages at once static $useremailaddresses = array(); diff --git a/message/output/jabber/message_output_jabber.php b/message/output/jabber/message_output_jabber.php index 6f3c4a52d2a89..a6f9f65d5da2a 100644 --- a/message/output/jabber/message_output_jabber.php +++ b/message/output/jabber/message_output_jabber.php @@ -45,6 +45,12 @@ function send_message($eventdata){ global $CFG; if (message_output_jabber::_jabber_configured()) { + if (!empty($CFG->noemailever)) { + // hidden setting for development sites, set in config.php if needed + debugging('$CFG->noemailever active, no jabber message sent.', DEBUG_MINIMAL); + return true; + } + //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once static $jabberaddresses = array(); @@ -86,7 +92,7 @@ function send_message($eventdata){ */ function config_form($preferences){ global $CFG; - + if (!message_output_jabber::_jabber_configured()) { return get_string('notconfigured','message_jabber'); } else {