mirror of
https://github.com/moodle/moodle.git
synced 2025-03-19 15:10:05 +01:00
Merge branch 'MDL-63569-email-header-master' of https://github.com/pauldamiani/moodle
This commit is contained in:
commit
849d2e5dad
@ -354,6 +354,8 @@ $choices = array(new lang_string('never', 'admin'),
|
||||
new lang_string('onlynoreply', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'),
|
||||
new lang_string('configemailfromvia', 'admin'), 1, $choices));
|
||||
$temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'),
|
||||
new lang_string('configemailsubjectprefix', 'admin'), '', PARAM_RAW));
|
||||
|
||||
$ADMIN->add('email', $temp);
|
||||
|
||||
|
@ -223,6 +223,7 @@ $string['configeditordictionary'] = 'This value will be used if aspell doesn\'t
|
||||
$string['configeditorfontlist'] = 'Select the fonts that should appear in the editor\'s drop-down list.';
|
||||
$string['configemailchangeconfirmation'] = 'Require an email confirmation step when users change their email address in their profile.';
|
||||
$string['configemailfromvia'] = 'Add via information in the "From" section of outgoing email. This informs the recipient from where this email came from and also helps combat recipients accidentally replying to no-reply email addresses.';
|
||||
$string['configemailsubjectprefix'] = 'Text to be prefixed to the subject line of all outgoing mail.';
|
||||
$string['configenablecalendarexport'] = 'Enable exporting or subscribing to calendars.';
|
||||
$string['configenablecomments'] = 'Enable comments';
|
||||
$string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
|
||||
@ -499,6 +500,7 @@ $string['editorspellinghelp'] = 'Enable or disable spell-checking. When enabled,
|
||||
$string['editstrings'] = 'Edit words or phrases';
|
||||
$string['emailchangeconfirmation'] = 'Email change confirmation';
|
||||
$string['emailfromvia'] = 'Email via information';
|
||||
$string['emailsubjectprefix'] = 'Email subject prefix text';
|
||||
$string['emoticontext'] = 'Text';
|
||||
$string['emoticonimagename'] = 'Image name';
|
||||
$string['emoticonalt'] = 'Alternative text';
|
||||
|
@ -6047,6 +6047,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
|
||||
'siteshortname' => $SITE->shortname,
|
||||
'sitewwwroot' => $CFG->wwwroot,
|
||||
'subject' => $subject,
|
||||
'prefix' => $CFG->emailsubjectprefix,
|
||||
'to' => $user->email,
|
||||
'toname' => fullname($user),
|
||||
'from' => $mail->From,
|
||||
|
@ -34,9 +34,11 @@
|
||||
* replyto
|
||||
* replytoname
|
||||
* body
|
||||
* prefix
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"prefix": "[Prefix Text]",
|
||||
"body": "Email body"
|
||||
}
|
||||
}}
|
||||
|
@ -31,10 +31,12 @@
|
||||
* fromname
|
||||
* replyto
|
||||
* replytoname
|
||||
* prefix
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"prefix": "[Prefix Text]",
|
||||
"subject": "Email subject"
|
||||
}
|
||||
}}
|
||||
{{{subject}}}
|
||||
{{#prefix}}{{{prefix}}} {{/prefix}}{{{subject}}}
|
||||
|
@ -33,9 +33,11 @@
|
||||
* replyto
|
||||
* replytoname
|
||||
* body
|
||||
* prefix
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"prefix": "[Prefix Text]",
|
||||
"body": "Email body"
|
||||
}
|
||||
}}
|
||||
|
@ -225,4 +225,45 @@ class core_message_testcase extends advanced_testcase {
|
||||
$eventsink->close();
|
||||
$sink->close();
|
||||
}
|
||||
|
||||
public function test_send_message_with_prefix() {
|
||||
global $DB, $CFG;
|
||||
$this->preventResetByRollback();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user(array('maildisplay' => 1));
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
set_config('allowedemaildomains', 'example.com');
|
||||
set_config('emailsubjectprefix', '[Prefix Text]');
|
||||
|
||||
// Test basic email processor.
|
||||
$this->assertFileExists("$CFG->dirroot/message/output/email/version.php");
|
||||
$this->assertFileExists("$CFG->dirroot/message/output/popup/version.php");
|
||||
|
||||
$DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'");
|
||||
set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2);
|
||||
|
||||
// Check that prefix is ammended to the subject of the email.
|
||||
$message = new \core\message\message();
|
||||
$message->courseid = 1;
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'instantmessage';
|
||||
$message->userfrom = $user1;
|
||||
$message->userto = $user2;
|
||||
$message->subject = get_string('unreadnewmessage', 'message', fullname($user1));
|
||||
$message->fullmessage = 'message body';
|
||||
$message->fullmessageformat = FORMAT_MARKDOWN;
|
||||
$message->fullmessagehtml = '<p>message body</p>';
|
||||
$message->smallmessage = 'small message';
|
||||
$message->notification = '0';
|
||||
$content = array('*' => array('header' => ' test ', 'footer' => ' test '));
|
||||
$message->set_additional_content('email', $content);
|
||||
$sink = $this->redirectEmails();
|
||||
$messageid = message_send($message);
|
||||
$emails = $sink->get_messages();
|
||||
$this->assertCount(1, $emails);
|
||||
$email = reset($emails);
|
||||
$this->assertSame('[Prefix Text] '. get_string('unreadnewmessage', 'message', fullname($user1)), $email->subject);
|
||||
$sink->clear();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user