From ff2abc4b7d37ea284d9fc6caa859665f778ed381 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 4 Oct 2016 09:55:57 +0800 Subject: [PATCH] MDL-44467 core: mail settings and navigation improvements This commit groups all mail settings under Server node, splitting into two categories: Outgoing mail configuration and Incoming mail configuration. Also, it make maildomain setting available on the Email settings page. --- admin/settings/plugins.php | 11 ----------- admin/settings/server.php | 12 ++++++++++++ admin/tool/messageinbound/settings.php | 2 +- message/output/email/lang/en/message_email.php | 7 ++++++- message/output/email/settings.php | 8 +++++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 2dbff19d87e..e7c729c8989 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -69,17 +69,6 @@ if ($hassiteconfig) { $plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig); } - // message outputs - $ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message'))); - $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs()); - $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs()); - $plugins = core_plugin_manager::instance()->get_plugins_of_type('message'); - core_collator::asort_objects_by_property($plugins, 'displayname'); - foreach ($plugins as $plugin) { - /** @var \core\plugininfo\message $plugin */ - $plugin->load_settings($ADMIN, 'messageoutputs', $hassiteconfig); - } - // authentication plugins $ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin'))); diff --git a/admin/settings/server.php b/admin/settings/server.php index aae21f9adea..3054f365dd6 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -213,6 +213,18 @@ $ADMIN->add('server', $temp); $ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('hubs', 'admin'), "$CFG->wwwroot/$CFG->admin/registration/index.php")); +// E-mail settings. +$ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'message_email'))); +$ADMIN->add('email', new admin_category('outgoingmailconfig', new lang_string('outgoingmailconfig', 'message_email'))); +$ADMIN->add('outgoingmailconfig', new admin_page_managemessageoutputs()); +$ADMIN->add('outgoingmailconfig', new admin_page_defaultmessageoutputs()); +$plugins = core_plugin_manager::instance()->get_plugins_of_type('message'); +core_collator::asort_objects_by_property($plugins, 'displayname'); +foreach ($plugins as $plugin) { + /** @var \core\plugininfo\message $plugin */ + $plugin->load_settings($ADMIN, 'outgoingmailconfig', $hassiteconfig); +} + // "update notifications" settingpage if (empty($CFG->disableupdatenotifications)) { $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin')); diff --git a/admin/tool/messageinbound/settings.php b/admin/tool/messageinbound/settings.php index bb562e00c52..bc2266c8c02 100644 --- a/admin/tool/messageinbound/settings.php +++ b/admin/tool/messageinbound/settings.php @@ -83,5 +83,5 @@ if ($hassiteconfig) { "$CFG->wwwroot/$CFG->admin/tool/messageinbound/index.php")); // Add the category to the admin tree. - $ADMIN->add('server', $category); + $ADMIN->add('email', $category); } diff --git a/message/output/email/lang/en/message_email.php b/message/output/email/lang/en/message_email.php index a2aec01b951..6f4f998285b 100644 --- a/message/output/email/lang/en/message_email.php +++ b/message/output/email/lang/en/message_email.php @@ -24,11 +24,13 @@ $string['allowattachments'] = 'Allow attachments'; $string['allowusermailcharset'] = 'Allow user to select character set'; +$string['categoryemail'] = 'E-mail'; $string['configallowattachments'] = 'If enabled, emails sent from the site can have attachments, such as badges.'; $string['configallowusermailcharset'] = 'If enabled, users can choose an email charset in their messaging preferences.'; +$string['configmaildomain'] = 'This setting specifies a trusted email domain that will be used to detect spoofing, handle bouncing and validate users emails.'; $string['configmailnewline'] = 'Newline characters used in mail messages. CRLF is required according to RFC 822bis, some mail servers do automatic conversion from LF to CRLF, other mail servers do incorrect conversion from CRLF to CRCRLF, yet others reject mails with bare LF (qmail for example). Try changing this setting if you are having problems with undelivered emails or double newlines.'; $string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the "From" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).'; -$string['configemailonlyfromnoreplyaddress'] = 'If enabled, all email will be sent using the no-reply address as the "from" address. This can be used to stop anti-spoofing controls in external mail systems blocking emails.'; +$string['configemailonlyfromnoreplyaddress'] = 'By default all email will be sent using the no-reply address as the "from" address or emails can sent using users email address if allowed. This can be used to stop anti-spoofing controls in external mail systems blocking emails.'; $string['configsitemailcharset'] = 'This setting specifies the default charset for all emails sent from the site.'; $string['configsmtpauthtype'] = 'This sets the authentication type to use on smtp server.'; $string['configsmtphosts'] = 'Give the full name of one or more local SMTP servers that Moodle should use to send mail (eg \'mail.a.com\' or \'mail.a.com;mail.b.com\'). To specify a non-default port (i.e other than port 25), you can use the [server]:[port] syntax (eg \'mail.a.com:587\'). For secure connections, port 465 is usually used with SSL, port 587 is usually used with TLS, specify security protocol below if required. If you leave this field blank, Moodle will use the PHP default method of sending mail.'; @@ -41,11 +43,14 @@ $string['ifemailleftempty'] = 'Leave empty to send notifications to {$a}'; $string['mailnewline'] = 'Newline characters in mail'; $string['none'] = 'None'; $string['noreplyaddress'] = 'No-reply address'; +$string['outgoingmailconfig'] = 'Outgoing mail configuration'; $string['pluginname'] = 'Email'; $string['sitemailcharset'] = 'Character set'; $string['smtpauthtype'] = 'SMTP Auth Type'; +$string['sendusinguseremail'] = 'Use user email address (if allowed)'; $string['smtphosts'] = 'SMTP hosts'; $string['smtpmaxbulk'] = 'SMTP session limit'; $string['smtppass'] = 'SMTP password'; $string['smtpsecure'] = 'SMTP security'; $string['smtpuser'] = 'SMTP username'; +$string['maildomain'] = 'Mail domain'; diff --git a/message/output/email/settings.php b/message/output/email/settings.php index 69f58dca354..bd95fa5e87d 100644 --- a/message/output/email/settings.php +++ b/message/output/email/settings.php @@ -34,10 +34,12 @@ if ($ADMIN->fulltree) { $settings->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'message_email'), get_string('configsmtpuser', 'message_email'), '')); $settings->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'message_email'), get_string('configsmtpmaxbulk', 'message_email'), 1, PARAM_INT)); $settings->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'message_email'), get_string('confignoreplyaddress', 'message_email'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS)); - $settings->add(new admin_setting_configcheckbox('emailonlyfromnoreplyaddress', + $sendemailoptions = array(0 => get_string('sendusinguseremail', 'message_email'), 1 => get_string('yes')); + $settings->add(new admin_setting_configselect('emailonlyfromnoreplyaddress', get_string('emailonlyfromnoreplyaddress', 'message_email'), - get_string('configemailonlyfromnoreplyaddress', 'message_email'), 0)); - + get_string('configemailonlyfromnoreplyaddress', 'message_email'), + 1, $sendemailoptions)); + $settings->add(new admin_setting_configtext('maildomain', get_string('maildomain', 'message_email'), get_string('configmaildomain', 'message_email'), '', PARAM_RAW)); $charsets = get_list_of_charsets(); unset($charsets['UTF-8']); // not needed here $options = array();