From 543dcf3e9cf2e5f6fe5899eebfef00cef32aa181 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 28 Apr 2023 16:51:33 +0100 Subject: [PATCH] MDL-78026 group: format retrieved group names from external methods. --- group/externallib.php | 18 +++++++++++------- group/upgrade.txt | 7 +++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/group/externallib.php b/group/externallib.php index 9d258195392..f94a8f30699 100644 --- a/group/externallib.php +++ b/group/externallib.php @@ -218,7 +218,8 @@ class core_group_external extends external_api { } require_capability('moodle/course:managegroups', $context); - list($group->description, $group->descriptionformat) = + $group->name = \core_external\util::format_string($group->name, $context); + [$group->description, $group->descriptionformat] = \core_external\util::format_text($group->description, $group->descriptionformat, $context, 'group', 'description', $group->id); @@ -240,7 +241,7 @@ class core_group_external extends external_api { array( 'id' => new external_value(PARAM_INT, 'group record id'), 'courseid' => new external_value(PARAM_INT, 'id of course'), - 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'), + 'name' => new external_value(PARAM_TEXT, 'group name'), 'description' => new external_value(PARAM_RAW, 'group description text'), 'descriptionformat' => new external_format_value('description'), 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'), @@ -296,7 +297,8 @@ class core_group_external extends external_api { $groups = array(); foreach ($gs as $group) { - list($group->description, $group->descriptionformat) = + $group->name = \core_external\util::format_string($group->name, $context); + [$group->description, $group->descriptionformat] = \core_external\util::format_text($group->description, $group->descriptionformat, $context, 'group', 'description', $group->id); $groups[] = (array)$group; @@ -317,7 +319,7 @@ class core_group_external extends external_api { array( 'id' => new external_value(PARAM_INT, 'group record id'), 'courseid' => new external_value(PARAM_INT, 'id of course'), - 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'), + 'name' => new external_value(PARAM_TEXT, 'group name'), 'description' => new external_value(PARAM_RAW, 'group description text'), 'descriptionformat' => new external_format_value('description'), 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'), @@ -1304,7 +1306,8 @@ class core_group_external extends external_api { 'g.id, g.name, g.description, g.descriptionformat, g.idnumber'); foreach ($groups as $group) { - list($group->description, $group->descriptionformat) = + $group->name = \core_external\util::format_string($group->name, $course->context); + [$group->description, $group->descriptionformat] = \core_external\util::format_text($group->description, $group->descriptionformat, $course->context, 'group', 'description', $group->id); $group->courseid = $course->id; @@ -1343,7 +1346,7 @@ class core_group_external extends external_api { return new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'group record id'), - 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'), + 'name' => new external_value(PARAM_TEXT, 'group name'), 'description' => new external_value(PARAM_RAW, 'group description text'), 'descriptionformat' => new external_format_value('description'), 'idnumber' => new external_value(PARAM_RAW, 'id number'), @@ -1428,7 +1431,8 @@ class core_group_external extends external_api { $groups = groups_get_activity_allowed_groups($cm, $user->id); foreach ($groups as $group) { - list($group->description, $group->descriptionformat) = + $group->name = \core_external\util::format_string($group->name, $coursecontext); + [$group->description, $group->descriptionformat] = \core_external\util::format_text($group->description, $group->descriptionformat, $coursecontext, 'group', 'description', $group->id); $group->courseid = $cm->course; diff --git a/group/upgrade.txt b/group/upgrade.txt index 9d25ad0d45e..1b7720e832b 100644 --- a/group/upgrade.txt +++ b/group/upgrade.txt @@ -1,6 +1,13 @@ This files describes API changes in /group/*, information provided here is intended especially for developers. +=== 4.3 === +* The following external methods now return group names correctly formatted: + - `core_group_get_groups` + - `core_group_get_course_groups` + - `core_group_get_course_user_groups` + - `core_group_get_activity_allowed_groups` + === 4.2 === * `\core_group\visibility` class added to support new `visibility` field in group records. This holds the visibility constants and helper functions for applying visibility restrictions when querying groups or group members in the database.