From 0c9d8172b56113763a337b17d6df7ff789c4cffa Mon Sep 17 00:00:00 2001 From: Davo Smith Date: Thu, 30 Apr 2015 14:22:03 +0100 Subject: [PATCH] MDL-48074 enrol: option to filter by users 'not in any group' --- enrol/locallib.php | 9 +++++++-- enrol/users_forms.php | 1 + lang/en/enrol.php | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/enrol/locallib.php b/enrol/locallib.php index 7ab3e3d41e8..2115b15de84 100644 --- a/enrol/locallib.php +++ b/enrol/locallib.php @@ -280,8 +280,13 @@ class course_enrolment_manager { // Group condition. if ($this->groupfilter) { - $sql .= " AND gm.groupid = :groupid"; - $params['groupid'] = $this->groupfilter; + if ($this->groupfilter < 0) { + // Show users who are not in any group. + $sql .= " AND gm.groupid IS NULL"; + } else { + $sql .= " AND gm.groupid = :groupid"; + $params['groupid'] = $this->groupfilter; + } } // Status condition. diff --git a/enrol/users_forms.php b/enrol/users_forms.php index b2ac13cdc0a..97b62b73655 100644 --- a/enrol/users_forms.php +++ b/enrol/users_forms.php @@ -167,6 +167,7 @@ class enrol_users_filter_form extends moodleform { // Filter by group. $allgroups = $manager->get_all_groups(); $groupsmenu[0] = get_string('allparticipants'); + $groupsmenu[-1] = get_string('nogroup', 'enrol'); foreach($allgroups as $gid => $unused) { $groupsmenu[$gid] = $allgroups[$gid]->name; } diff --git a/lang/en/enrol.php b/lang/en/enrol.php index b0498ebffc4..1ca0a6e1c2f 100644 --- a/lang/en/enrol.php +++ b/lang/en/enrol.php @@ -94,6 +94,7 @@ $string['manageinstance'] = 'Manage'; $string['migratetomanual'] = 'Migrate to manual enrolments'; $string['nochange'] = 'No change'; $string['noexistingparticipants'] = 'No existing participants'; +$string['nogroup'] = 'No group'; $string['noguestaccess'] = 'Guests can not access this course, please try to log in.'; $string['none'] = 'None'; $string['notenrollable'] = 'You can not enrol yourself in this course.';