MDL-80809 course: correct context arguments when formatting strings.

This commit is contained in:
Paul Holden 2024-02-01 17:31:41 +00:00
parent f30110b5eb
commit f32c74e654
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -52,9 +52,7 @@ class content_notification_task extends adhoc_task {
// Get only active users.
$coursecontext = \context_course::instance($course->id);
$modcontext = \context_module::instance($cm->id);
$users = get_enrolled_users($coursecontext, '', 0, 'u.*', null, 0, 0, true);
if (empty($users)) {
return;
}
@ -81,9 +79,9 @@ class content_notification_task extends adhoc_task {
// Get module names in the user's language.
$modnames = get_module_types_names();
$a = [
'coursename' => format_string(get_course_display_name_for_list($course), true, ['context' => $modcontext]),
'coursename' => format_string(get_course_display_name_for_list($course), true, ['context' => $coursecontext]),
'courselink' => (new \moodle_url('/course/view.php', ['id' => $course->id]))->out(false),
'modulename' => format_string($cm->name, $modcontext->id),
'modulename' => $cm->get_formatted_name(),
'moduletypename' => $modnames[$cm->modname],
'link' => (new \moodle_url('/mod/' . $cm->modname . '/view.php', ['id' => $cm->id]))->out(false),
'notificationpreferenceslink' =>
@ -110,7 +108,7 @@ class content_notification_task extends adhoc_task {
$eventdata->fullmessagehtml = $messagebody;
$eventdata->smallmessage = strip_tags($eventdata->fullmessagehtml);
$eventdata->contexturl = (new \moodle_url('/mod/' . $cm->modname . '/view.php', ['id' => $cm->id]))->out(false);
$eventdata->contexturlname = $cm->name;
$eventdata->contexturlname = $cm->get_formatted_name();
$eventdata->notification = 1;
// Add notification custom data.