MDL-44467 core: mail settings and navigation improvements
authorSimey Lameze <simey@moodle.com>
Tue, 4 Oct 2016 01:55:57 +0000 (09:55 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 28 Oct 2016 05:04:09 +0000 (13:04 +0800)
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
admin/settings/server.php
admin/tool/messageinbound/settings.php
message/output/email/lang/en/message_email.php
message/output/email/settings.php

index 2dbff19..e7c729c 100644 (file)
@@ -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')));
 
index aae21f9..3054f36 100644 (file)
@@ -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'));
index bb562e0..bc2266c 100644 (file)
@@ -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);
 }
index a2aec01..6f4f998 100644 (file)
 
 $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';
index 69f58dc..bd95fa5 100644 (file)
@@ -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();