Skip to content

Commit

Permalink
Update email_certificate_task.php
Browse files Browse the repository at this point in the history
global $PAGE to $page
  • Loading branch information
ewallah authored Dec 9, 2022
1 parent 39f8b28 commit 17851b7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions classes/task/email_certificate_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function get_name() {
* Execute.
*/
public function execute() {
global $DB, $PAGE;
global $DB;

// Get all the certificates that have requested someone get emailed.
$emailotherslengthsql = $DB->sql_length('c.emailothers');
Expand All @@ -68,8 +68,9 @@ public function execute() {
}

// The renderers used for sending emails.
$htmlrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'htmlemail');
$textrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'textemail');
$page = new \moodle_page();
$htmlrenderer = $page->get_renderer('mod_customcert', 'email', 'htmlemail');
$textrenderer = $page->get_renderer('mod_customcert', 'email', 'textemail');
foreach ($customcerts as $customcert) {
// Do not process an empty certificate.
$sql = "SELECT ce.*
Expand All @@ -86,8 +87,8 @@ public function execute() {
// 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);
// 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();
Expand Down

0 comments on commit 17851b7

Please sign in to comment.