From: Dan Marsden Date: Tue, 1 May 2018 02:43:05 +0000 (+1200) Subject: Fixes #302 make sure user lang is used when sending mail. X-Git-Url: http://git.cameron1729.xyz/?p=moodle-mod_attendance.git;a=commitdiff_plain;h=39f39676b4ec3068b7246da695234df243fc27ed Fixes #302 make sure user lang is used when sending mail. --- 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)) {