MDL-68980 core_user: Show user participation group when groupmode set

This commit is contained in:
Andrew Nicols
2020-06-10 14:14:50 +08:00
parent bbb7dfc62e
commit 20531b30f6
+17 -6
View File
@@ -111,14 +111,25 @@ $canaccessallgroups = has_capability('moodle/site:accessallgroups', $context);
$filtergroupids = $urlgroupid ? [$urlgroupid] : [];
// Force group filtering if user should only see a subset of groups' users.
if ($course->groupmode == SEPARATEGROUPS && !$canaccessallgroups) {
$filtergroupids = array_keys(groups_get_all_groups($course->id, $USER->id));
if ($course->groupmode != NOGROUPS && !$canaccessallgroups) {
if ($filtergroupids) {
$filtergroupids = array_intersect(
$filtergroupids,
array_keys(groups_get_all_groups($course->id, $USER->id))
);
} else {
$filtergroupids = array_keys(groups_get_all_groups($course->id, $USER->id));
}
if (empty($filtergroupids)) {
// The user is not in a group so show message and exit.
echo $OUTPUT->notification(get_string('notingroup'));
echo $OUTPUT->footer();
exit();
if ($course->groupmode == SEPARATEGROUPS) {
// The user is not in a group so show message and exit.
echo $OUTPUT->notification(get_string('notingroup'));
echo $OUTPUT->footer();
exit();
} else {
$filtergroupids = [(int) groups_get_course_group($course, true)];
}
}
}