Skip to content

Commit

Permalink
Merge branch 'MDL-78026' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 8, 2023
2 parents 46ba6e8 + 543dcf3 commit f31d8f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
18 changes: 11 additions & 7 deletions group/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public static function get_groups($groupids) {
}
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);

Expand All @@ -240,7 +241,7 @@ public static function get_groups_returns() {
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'),
Expand Down Expand Up @@ -296,7 +297,8 @@ public static function get_course_groups($courseid) {

$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;
Expand All @@ -317,7 +319,7 @@ public static function get_course_groups_returns() {
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'),
Expand Down Expand Up @@ -1304,7 +1306,8 @@ public static function get_course_user_groups($courseid = 0, $userid = 0, $group
'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;
Expand Down Expand Up @@ -1343,7 +1346,7 @@ public static function group_description() {
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'),
Expand Down Expand Up @@ -1428,7 +1431,8 @@ public static function get_activity_allowed_groups($cmid, $userid = 0) {
$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;
Expand Down
7 changes: 7 additions & 0 deletions group/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit f31d8f6

Please sign in to comment.