mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-59688 enrol: Show removed users
When users are automatically removed from the bulk action selection (due to a non-matching enrolment method) we should show a warning to make it obvious.
This commit is contained in:
parent
27466d7548
commit
80a2937dbe
@ -139,6 +139,7 @@ $string['unenrolroleusers'] = 'Unenrol users';
|
||||
$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';
|
||||
|
@ -114,6 +114,18 @@ if ($formaction == 'bulkchange.php') {
|
||||
|
||||
$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 @@ if ($formaction == 'bulkchange.php') {
|
||||
}
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user