Skip to content

Commit

Permalink
Merge branch 'MDL-60732-master' of git://github.com/damyon/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Nov 8, 2017
2 parents 7effd6d + a471bc4 commit ed0e2ce
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions user/renderer.php
Expand Up @@ -121,6 +121,7 @@ public function unified_filter($course, $context, $filtersapplied) {
global $CFG, $DB, $USER;

require_once($CFG->dirroot . '/enrol/locallib.php');
require_once($CFG->dirroot . '/lib/grouplib.php');
$manager = new course_enrolment_manager($this->page, $course);

$filteroptions = [];
Expand All @@ -135,21 +136,19 @@ public function unified_filter($course, $context, $filtersapplied) {
$filteroptions += $roleoptions;

// Filter options for groups, if available.
if ($course->groupmode != NOGROUPS) {
if (has_capability('moodle/site:accessallgroups', $context) || $course->groupmode == VISIBLEGROUPS) {
// List all groups if the user can access all groups, or we are in visible group mode.
$groups = $manager->get_all_groups();
} else {
// Otherwise, just list the groups the user belongs to.
$groups = groups_get_all_groups($course->id, $USER->id);
}
$criteria = get_string('group');
$groupoptions = [];
foreach ($groups as $id => $group) {
$groupoptions += $this->format_filter_option(USER_FILTER_GROUP, $criteria, $id, $group->name);
}
$filteroptions += $groupoptions;
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();
} else {
// Otherwise, just list the groups the user belongs to.
$groups = groups_get_all_groups($course->id, $USER->id);
}
$criteria = get_string('group');
$groupoptions = [];
foreach ($groups as $id => $group) {
$groupoptions += $this->format_filter_option(USER_FILTER_GROUP, $criteria, $id, $group->name);
}
$filteroptions += $groupoptions;

$canreviewenrol = has_capability('moodle/course:enrolreview', $context);

Expand Down Expand Up @@ -241,7 +240,6 @@ public function unified_filter($course, $context, $filtersapplied) {
}
}


// Add missing applied filters to the filter options.
$filteroptions = $this->handle_missing_applied_filters($filtersapplied, $filteroptions);

Expand Down

0 comments on commit ed0e2ce

Please sign in to comment.