MDL-77057 group: format group names in module override pages.

This commit is contained in:
Paul Holden 2023-01-26 17:37:14 +00:00
parent 880462a168
commit fdc9bd1a76
10 changed files with 24 additions and 17 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -235,8 +235,8 @@ foreach ($overrides as $override) {
$OUTPUT->pix_icon('t/delete', get_string('delete')) . '</a> ';
if ($groupmode) {
$usergroupstr = '<a href="' . $groupurl->out(true,
array('group' => $override->groupid)) . '" >' . $override->name . '</a>';
$usergroupstr = '<a href="' . $groupurl->out(true, ['group' => $override->groupid]) . '" >' .
format_string($override->name, true, ['context' => $context]) . '</a>';
// Move up.
if ($override->sortorder > 1) {

View File

@ -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);

View File

@ -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;

View File

@ -284,8 +284,8 @@ foreach ($overrides as $override) {
$OUTPUT->pix_icon('t/delete', get_string('delete')) . '</a> ';
if ($groupmode) {
$usergroupstr = '<a href="' . $groupurl->out(true,
array('group' => $override->groupid)) . '" >' . $override->name . '</a>';
$usergroupstr = '<a href="' . $groupurl->out(true, ['group' => $override->groupid]) . '" >' .
format_string($override->name, true, ['context' => $context]) . '</a>';
} else {
$usergroupstr = '<a href="' . $userurl->out(true,
array('id' => $override->userid)) . '" >' . fullname($override) . '</a>';

View File

@ -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);

View File

@ -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);

View File

@ -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();