From fdc9bd1a76f17bc3ac38b198f70ccac98534ffeb Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 26 Jan 2023 17:37:14 +0000 Subject: [PATCH] MDL-77057 group: format group names in module override pages. --- lib/grouplib.php | 4 ++++ mod/assign/override_form.php | 7 ++++--- mod/assign/overridedelete.php | 2 +- mod/assign/overrides.php | 4 ++-- mod/lesson/override_form.php | 7 ++++--- mod/lesson/overridedelete.php | 2 +- mod/lesson/overrides.php | 4 ++-- mod/quiz/classes/form/edit_override_form.php | 7 ++++--- mod/quiz/overridedelete.php | 2 +- mod/quiz/overrides.php | 2 +- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/grouplib.php b/lib/grouplib.php index 7fcf9bff790..bee8583d979 100644 --- a/lib/grouplib.php +++ b/lib/grouplib.php @@ -74,6 +74,8 @@ function groups_group_exists($groupid) { /** * Gets the name of a group with a specified id * + * Before output, you should call {@see format_string} on the result + * * @category group * @param int $groupid The id of the group * @return string The name of the group @@ -86,6 +88,8 @@ function groups_get_group_name($groupid) { /** * Gets the name of a grouping with a specified id * + * Before output, you should call {@see format_string} on the result + * * @category group * @param int $groupingid The id of the grouping * @return string The name of the grouping diff --git a/mod/assign/override_form.php b/mod/assign/override_form.php index 537c311b7bb..514db23f603 100644 --- a/mod/assign/override_form.php +++ b/mod/assign/override_form.php @@ -106,8 +106,9 @@ class assign_override_form extends moodleform { // Group override. if ($this->groupid) { // There is already a groupid, so freeze the selector. - $groupchoices = array(); - $groupchoices[$this->groupid] = groups_get_group_name($this->groupid); + $groupchoices = [ + $this->groupid => format_string(groups_get_group_name($this->groupid), true, $this->context), + ]; $mform->addElement('select', 'groupid', get_string('overridegroup', 'assign'), $groupchoices); $mform->freeze('groupid'); @@ -127,7 +128,7 @@ class assign_override_form extends moodleform { $groupchoices = array(); foreach ($groups as $group) { - $groupchoices[$group->id] = $group->name; + $groupchoices[$group->id] = format_string($group->name, true, $this->context); } unset($groups); diff --git a/mod/assign/overridedelete.php b/mod/assign/overridedelete.php index fb8a07c64f2..983d4b5f340 100644 --- a/mod/assign/overridedelete.php +++ b/mod/assign/overridedelete.php @@ -94,7 +94,7 @@ echo $OUTPUT->header(); if ($override->groupid) { $group = $DB->get_record('groups', array('id' => $override->groupid), 'id, name'); - $confirmstr = get_string("overridedeletegroupsure", "assign", $group->name); + $confirmstr = get_string("overridedeletegroupsure", "assign", format_string($group->name, true, ['context' => $context])); } else { $userfieldsapi = \core_user\fields::for_name(); $namefields = $userfieldsapi->get_sql('', false, '', '', false)->selects; diff --git a/mod/assign/overrides.php b/mod/assign/overrides.php index 74640d2a372..dd65575ebae 100644 --- a/mod/assign/overrides.php +++ b/mod/assign/overrides.php @@ -235,8 +235,8 @@ foreach ($overrides as $override) { $OUTPUT->pix_icon('t/delete', get_string('delete')) . ' '; if ($groupmode) { - $usergroupstr = '' . $override->name . ''; + $usergroupstr = '' . + format_string($override->name, true, ['context' => $context]) . ''; // Move up. if ($override->sortorder > 1) { diff --git a/mod/lesson/override_form.php b/mod/lesson/override_form.php index de62efb7064..4fd54a012f0 100644 --- a/mod/lesson/override_form.php +++ b/mod/lesson/override_form.php @@ -95,8 +95,9 @@ class lesson_override_form extends moodleform { // Group override. if ($this->groupid) { // There is already a groupid, so freeze the selector. - $groupchoices = array(); - $groupchoices[$this->groupid] = groups_get_group_name($this->groupid); + $groupchoices = [ + $this->groupid => format_string(groups_get_group_name($this->groupid), true, $this->context), + ]; $mform->addElement('select', 'groupid', get_string('overridegroup', 'lesson'), $groupchoices); $mform->freeze('groupid'); @@ -112,7 +113,7 @@ class lesson_override_form extends moodleform { $groupchoices = array(); foreach ($groups as $group) { - $groupchoices[$group->id] = $group->name; + $groupchoices[$group->id] = format_string($group->name, true, $this->context); } unset($groups); diff --git a/mod/lesson/overridedelete.php b/mod/lesson/overridedelete.php index ac552ca5b02..f872df76b8e 100644 --- a/mod/lesson/overridedelete.php +++ b/mod/lesson/overridedelete.php @@ -92,7 +92,7 @@ echo $OUTPUT->heading(format_string($lesson->name, true, array('context' => $con if ($override->groupid) { $group = $DB->get_record('groups', array('id' => $override->groupid), 'id, name'); - $confirmstr = get_string("overridedeletegroupsure", "lesson", $group->name); + $confirmstr = get_string("overridedeletegroupsure", "lesson", format_string($group->name, true, ['context' => $context])); } else { $userfieldsapi = \core_user\fields::for_name(); $namefields = $userfieldsapi->get_sql('', false, '', '', false)->selects; diff --git a/mod/lesson/overrides.php b/mod/lesson/overrides.php index 4db1a1a310a..2e81ea40491 100644 --- a/mod/lesson/overrides.php +++ b/mod/lesson/overrides.php @@ -284,8 +284,8 @@ foreach ($overrides as $override) { $OUTPUT->pix_icon('t/delete', get_string('delete')) . ' '; if ($groupmode) { - $usergroupstr = '' . $override->name . ''; + $usergroupstr = '' . + format_string($override->name, true, ['context' => $context]) . ''; } else { $usergroupstr = '' . fullname($override) . ''; diff --git a/mod/quiz/classes/form/edit_override_form.php b/mod/quiz/classes/form/edit_override_form.php index b830ce73a47..1e03354d986 100644 --- a/mod/quiz/classes/form/edit_override_form.php +++ b/mod/quiz/classes/form/edit_override_form.php @@ -95,8 +95,9 @@ class edit_override_form extends moodleform { // Group override. if ($this->groupid) { // There is already a groupid, so freeze the selector. - $groupchoices = []; - $groupchoices[$this->groupid] = groups_get_group_name($this->groupid); + $groupchoices = [ + $this->groupid => format_string(groups_get_group_name($this->groupid), true, $this->context), + ]; $mform->addElement('select', 'groupid', get_string('overridegroup', 'quiz'), $groupchoices); $mform->freeze('groupid'); @@ -112,7 +113,7 @@ class edit_override_form extends moodleform { $groupchoices = []; foreach ($groups as $group) { - $groupchoices[$group->id] = $group->name; + $groupchoices[$group->id] = format_string($group->name, true, $this->context); } unset($groups); diff --git a/mod/quiz/overridedelete.php b/mod/quiz/overridedelete.php index 4b68d50f3fb..e77f7769c71 100644 --- a/mod/quiz/overridedelete.php +++ b/mod/quiz/overridedelete.php @@ -97,7 +97,7 @@ echo $OUTPUT->header(); if ($override->groupid) { $group = $DB->get_record('groups', ['id' => $override->groupid], 'id, name'); - $confirmstr = get_string("overridedeletegroupsure", "quiz", $group->name); + $confirmstr = get_string("overridedeletegroupsure", "quiz", format_string($group->name, true, ['context' => $context])); } else { $user = $DB->get_record('user', ['id' => $override->userid]); profile_load_custom_fields($user); diff --git a/mod/quiz/overrides.php b/mod/quiz/overrides.php index 8bb12c6ab58..d0308b34174 100644 --- a/mod/quiz/overrides.php +++ b/mod/quiz/overrides.php @@ -233,7 +233,7 @@ foreach ($overrides as $override) { $groupcell = new html_table_cell(); $groupcell->rowspan = count($fields); $groupcell->text = html_writer::link(new moodle_url($groupurl, ['group' => $override->groupid]), - $override->name . $extranamebit); + format_string($override->name, true, ['context' => $context]) . $extranamebit); $usercells[] = $groupcell; } else { $usercell = new html_table_cell();