MDL-63485 core_user: Allow filtering by No groups on participants page

A new optional parameter $context has been added to the
core_group::groups_get_members_join() function.
Besides, some core_group methods now accept -1 (USERSWITHOUTHGROUP) for
the groupid field.

Backport of MDL-61967.
This commit is contained in:
Sara Arjona
2018-12-10 20:29:04 +08:00
committed by Mark Nelson
parent 2fbae51df0
commit 9cfb533e2d
11 changed files with 244 additions and 25 deletions
+5
View File
@@ -145,6 +145,11 @@ class core_user_renderer extends plugin_renderer_base {
if (has_capability('moodle/site:accessallgroups', $context) || $course->groupmode != SEPARATEGROUPS) {
// List all groups if the user can access all groups, or we are in visible group mode or no groups mode.
$groups = $manager->get_all_groups();
if (!empty($groups)) {
// Add 'No group' option, to enable filtering users without any group.
$nogroup[USERSWITHOUTGROUP] = (object)['name' => get_string('nogroup', 'group')];
$groups = $nogroup + $groups;
}
} else {
// Otherwise, just list the groups the user belongs to.
$groups = groups_get_all_groups($course->id, $USER->id);