Skip to content
Permalink
Browse files
Merge branch 'MDL-59831_master' of git://github.com/markn86/moodle
  • Loading branch information
David Monllao committed Sep 12, 2017
2 parents 2cef0d3 + 32e5109 commit 651f1a1703b99bd04a906d94ca7e03f6c44f9865
Showing with 17 additions and 5 deletions.
  1. +14 −3 user/index.php
  2. +2 −2 user/renderer.php
  3. +1 −0 user/templates/unified_filter.mustache
@@ -103,6 +103,7 @@

// Get the currently applied filters.
$filtersapplied = optional_param_array('unified-filters', [], PARAM_TEXT);
$filterwassubmitted = optional_param('unified-filter-submitted', 0, PARAM_BOOL);

// Default group ID.
$groupid = false;
@@ -168,9 +169,19 @@
}
}

// If course supports groups, but the user can't access all groups and there's no group filter set, apply a default group filter.
if ($groupid !== false && !$canaccessallgroups && !$hasgroupfilter) {
$filtersapplied[] = USER_FILTER_GROUP . ':' . $groupid;
// If course supports groups we may need to set a default.
if ($groupid !== false) {
// If we are in a course with visible groups and the user has not submitted anything and does not have
// access to all groups, then set a default group. This is the same behaviour in 3.3.
if (!$canaccessallgroups && !$filterwassubmitted && $course->groupmode == VISIBLEGROUPS) {
$filtersapplied[] = USER_FILTER_GROUP . ':' . $groupid;
} else if (!$canaccessallgroups && !$hasgroupfilter && $course->groupmode != VISIBLEGROUPS) {
// The user can't access all groups and has not set a group filter in a course where the groups are not visible
// then apply a default group filter.
$filtersapplied[] = USER_FILTER_GROUP . ':' . $groupid;
} else if (!$hasgroupfilter) { // No need for the group id to be set.
$groupid = false;
}
}

// Manage enrolments.
@@ -265,8 +265,8 @@ public function unified_filter($course, $context, $filtersapplied) {

// Filter options for groups, if available.
if ($course->groupmode != NOGROUPS) {
if (has_capability('moodle/site:accessallgroups', $context)) {
// List all groups if the user can access all groups.
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.
@@ -58,6 +58,7 @@
<option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{{label}}}</option>
{{/filteroptions}}
</select>
<input type="hidden" name="unified-filter-submitted" value="1">
<input type="submit" class="btn btn-primary" id="user-filter-button" value={{#quote}}{{#str}}filter{{/str}}{{/quote}}>
</form>
{{#js}}

0 comments on commit 651f1a1

Please sign in to comment.