diff --git a/lang/en/enrol.php b/lang/en/enrol.php index ae18f7ce4fc47..666a8a59d99d7 100644 --- a/lang/en/enrol.php +++ b/lang/en/enrol.php @@ -139,6 +139,7 @@ $string['uninstallmigrating'] = 'Migrating "{$a}" enrolments'; $string['unknowajaxaction'] = 'Unknown action requested'; $string['unlimitedduration'] = 'Unlimited'; +$string['userremovedfromselectiona'] = 'User "{$a}" was removed from the selection.'; $string['usersearch'] = 'Search '; $string['withselectedusers'] = 'With selected users'; $string['extremovedaction'] = 'External unenrol action'; diff --git a/user/action_redir.php b/user/action_redir.php index d5eed2556207a..2401cec5139a5 100644 --- a/user/action_redir.php +++ b/user/action_redir.php @@ -114,6 +114,18 @@ $users = $manager->get_users_enrolments($userids); + $removed = array_diff($userids, array_keys($users)); + if (!empty($removed)) { + // This manager does not filter by enrolment method - so we can get the removed users details. + $removedmanager = new course_enrolment_manager($PAGE, $course); + $removedusers = $removedmanager->get_users_enrolments($removed); + + foreach ($removedusers as $removeduser) { + $msg = get_string('userremovedfromselectiona', 'enrol', fullname($removeduser)); + \core\notification::warning($msg); + } + } + // We may have users from any kind of enrolment, we need to filter for the enrolment plugin matching the bulk action. $matchesplugin = function($user) use ($plugin) { foreach ($user->enrolments as $enrolment) { @@ -123,12 +135,14 @@ } return false; }; - $users = array_filter($users, $matchesplugin); + $filteredusers = array_filter($users, $matchesplugin); - if (empty($users)) { + if (empty($filteredusers)) { redirect($returnurl, get_string('noselectedusers', 'bulkusers')); } + $users = $filteredusers; + // Get the form for the bulk operation. $mform = $operation->get_form($PAGE->url, array('users' => $users)); // If the mform is false then attempt an immediate process. This may be an immediate action that