mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-69600 core: Expose divertallemails config in UI
This commit is contained in:
parent
8b026809c5
commit
acb848cdce
4 changed files with 41 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue