From c8a4c287794d3f8807f21b73f5f1c050561145e0 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 6 Nov 2024 11:01:24 +0000 Subject: [PATCH] MDL-83265 course: user placeholders for request approval notification. --- course/lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/course/lib.php b/course/lib.php index 0449cd5fd5827..eb72ccdaf9abb 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2633,8 +2633,14 @@ public function approve() { $this->delete(); $a = new stdClass(); - $a->name = format_string($course->fullname, true, array('context' => context_course::instance($course->id))); - $a->url = $CFG->wwwroot.'/course/view.php?id=' . $course->id; + $a->name = format_string($course->fullname, true, ['context' => $context]); + $a->url = course_get_url($course); + + $usernameplaceholders = \core\user::get_name_placeholders($user); + foreach ($usernameplaceholders as $field => $value) { + $a->{$field} = $value; + } + $this->notify($user, $USER, 'courserequestapproved', get_string('courseapprovedsubject'), get_string('courseapprovedemail2', 'moodle', $a), $course->id); return $course->id;