From 7a45c41cd96f2bc07d8268f3cb4845d21e7190c0 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sun, 13 Jun 2021 13:32:11 +0800 Subject: [PATCH] Set proper context when sending emails (#402) --- CHANGES.md | 3 ++- classes/task/email_certificate_task.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index b793fa8..6d86f1f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. Note - All hash comments refer to the issue number. Eg. #169 refers to https://github.com/mdjnelson/moodle-mod_customcert/issues/169. -## [3.10.1] - 2021-XX-YY +## [3.10.1] - 2021-06-13 ### Added - Usage of github actions (#407). @@ -15,6 +15,7 @@ Note - All hash comments refer to the issue number. Eg. #169 refers to https://g - Managers are now able to download their students' certificates (#412). - Users being able to view the certificate before the required time set (#403). - Fixed the issue with displaying PDF when debugging is ON (#420). +- Using incorrect context when sending emails (#402). ## [3.8.5] - 2020-11-26 diff --git a/classes/task/email_certificate_task.php b/classes/task/email_certificate_task.php index fb27769..e0906dd 100644 --- a/classes/task/email_certificate_task.php +++ b/classes/task/email_certificate_task.php @@ -84,6 +84,9 @@ class email_certificate_task extends \core\task\scheduled_task { // Get the context. $context = \context::instance_by_id($customcert->contextid); + // Set the $PAGE context - this ensure settings, such as language, are kept and don't default to the site settings. + $PAGE->set_context($context); + // Get the person we are going to send this email on behalf of. $userfrom = \core_user::get_noreply_user();