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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user