From 39f39676b4ec3068b7246da695234df243fc27ed Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Tue, 1 May 2018 14:43:05 +1200 Subject: [PATCH] Fixes #302 make sure user lang is used when sending mail. --- classes/task/notify.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/task/notify.php b/classes/task/notify.php index 11b7137..70aaa09 100644 --- a/classes/task/notify.php +++ b/classes/task/notify.php @@ -91,11 +91,13 @@ class notify extends \core\task\scheduled_task { $record = attendance_template_variables($record); $user = $DB->get_record('user', array('id' => $record->userid)); $from = \core_user::get_noreply_user(); + $oldforcelang = force_current_language($user->lang); $emailcontent = format_text($record->emailcontent, $record->emailcontentformat); + $emailsubject = format_text($record->emailsubject); + email_to_user($user, $from, $emailsubject, $emailcontent, $emailcontent); - email_to_user($user, $from, $record->emailsubject, $emailcontent, $emailcontent); - + force_current_language($oldforcelang); $sentnotifications[$record->userid][] = $record->aid; $numsentusers++; } @@ -137,6 +139,7 @@ class notify extends \core\task\scheduled_task { foreach ($thirdpartynotifications as $sendid => $notifications) { $user = $DB->get_record('user', array('id' => $sendid)); $from = \core_user::get_noreply_user(); + $oldforcelang = force_current_language($user->lang); $emailcontent = implode("\n", $notifications); $emailcontent .= "\n\n".get_string('thirdpartyemailtextfooter', 'attendance'); @@ -144,6 +147,7 @@ class notify extends \core\task\scheduled_task { $emailsubject = get_string('thirdpartyemailsubject', 'attendance'); email_to_user($user, $from, $emailsubject, $emailcontent, $emailcontent); + force_current_language($oldforcelang); $numsentthird++; } if (!empty($numsentthird)) {