mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-69600-divertemails' of https://github.com/brendanheywood/moodle
This commit is contained in:
commit
83cf43b045
@ -444,6 +444,17 @@ if ($hassiteconfig) {
|
||||
new lang_string('configallowedemaildomains', 'admin'),
|
||||
''));
|
||||
|
||||
$temp->add(new admin_setting_heading('divertallemailsheading', new lang_string('divertallemails', 'admin'),
|
||||
new lang_string('divertallemailsdetail', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('divertallemailsto',
|
||||
new lang_string('divertallemailsto', 'admin'),
|
||||
new lang_string('divertallemailsto_desc', 'admin'),
|
||||
''));
|
||||
$temp->add(new admin_setting_configtextarea('divertallemailsexcept',
|
||||
new lang_string('divertallemailsexcept', 'admin'),
|
||||
new lang_string('divertallemailsexcept_desc', 'admin'),
|
||||
'', PARAM_RAW, '50', '4'));
|
||||
|
||||
$url = new moodle_url('/admin/testoutgoingmailconf.php');
|
||||
$link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
|
||||
$temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
|
@ -499,6 +499,15 @@ $string['disabled'] = 'Disabled';
|
||||
$string['disableuserimages'] = 'Disable user profile images';
|
||||
$string['displayerrorswarning'] = 'Enabling the PHP setting <em>display_errors</em> is not recommended on production sites because some error messages may reveal sensitive information about your server.';
|
||||
$string['displayloginfailures'] = 'Display login failures';
|
||||
$string['divertallemails'] = 'Email diverting';
|
||||
$string['divertallemailsdetail'] = 'Used as a safeguard in development environments when testing emails and should not be used in production.';
|
||||
$string['divertallemailsexcept'] = 'Email diversion exceptions';
|
||||
$string['divertallemailsexcept_desc'] = 'A list of email exception rules separated by either commas or new lines. Each rule is interpreted as a regular expression, eg<pre>simone@acme.com
|
||||
.*@acme.com
|
||||
fred(\\+.*)?@acme.com
|
||||
</pre>';
|
||||
$string['divertallemailsto'] = 'Divert all emails';
|
||||
$string['divertallemailsto_desc'] = 'If set then all emails will be diverted to this single email address instead.';
|
||||
$string['dndallowtextandlinks'] = 'Drag and drop upload of text/links';
|
||||
$string['doclang'] = 'Language for docs';
|
||||
$string['docroot'] = 'Moodle Docs document root';
|
||||
|
@ -5984,7 +5984,7 @@ function email_should_be_diverted($email) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$patterns = array_map('trim', explode(',', $CFG->divertallemailsexcept));
|
||||
$patterns = array_map('trim', preg_split("/[\s,]+/", $CFG->divertallemailsexcept));
|
||||
foreach ($patterns as $pattern) {
|
||||
if (preg_match("/$pattern/", $email)) {
|
||||
return false;
|
||||
|
@ -3297,6 +3297,26 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
),
|
||||
false,
|
||||
),
|
||||
'divertsexceptionsnewline' => array(
|
||||
'divertallemailsto' => 'somewhere@elsewhere.com',
|
||||
'divertallemailsexcept' => "@dev.com\nfred(\+.*)?@example.com",
|
||||
array(
|
||||
'dev1@dev.com',
|
||||
'fred@example.com',
|
||||
'fred+verp@example.com',
|
||||
),
|
||||
false,
|
||||
),
|
||||
'alsodivertsnewline' => array(
|
||||
'divertallemailsto' => 'somewhere@elsewhere.com',
|
||||
'divertallemailsexcept' => "@dev.com\nfred(\+.*)?@example.com",
|
||||
array(
|
||||
'foo@example.com',
|
||||
'test@real.com',
|
||||
'fred.jones@example.com',
|
||||
),
|
||||
true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user