MDL-26061 Prevent fatal error in remote enrolment client when there are no roaming users
This commit is contained in:
@@ -40,6 +40,14 @@ if (!$service->is_available()) {
|
||||
die();
|
||||
}
|
||||
|
||||
$roamingusers = get_users_by_capability(get_system_context(), 'moodle/site:mnetlogintoremote', 'u.id');
|
||||
if (empty($roamingusers)) {
|
||||
$capname = get_string('site:mnetlogintoremote', 'role');
|
||||
$url = new moodle_url('/admin/roles/manage.php');
|
||||
echo notice(get_string('noroamingusers', 'mnetservice_enrol', $capname), $url);
|
||||
}
|
||||
unset($roamingusers);
|
||||
|
||||
// remote hosts that may publish remote enrolment service and we are subscribed to it
|
||||
$hosts = $service->get_remote_publishers();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ $string['hostappname'] = 'Application';
|
||||
$string['hostname'] = 'Host name';
|
||||
$string['hosturl'] = 'Remote host URL';
|
||||
$string['nopublishers'] = 'No remote peers available.';
|
||||
$string['noroamingusers'] = 'Users need capability \'{$a}\' to be enrolled to remote courses. No users with such capability were found. Click the continue button to assign the required capability to some roles at your site.';
|
||||
$string['otherenrolledusers'] = 'Other enrolled users';
|
||||
$string['pluginname'] = 'Remote enrolment service';
|
||||
$string['refetch'] = 'Re-fetch up to date state from remote hosts';
|
||||
|
||||
@@ -552,6 +552,10 @@ class mnetservice_enrol_potential_users_selector extends user_selector_base {
|
||||
$systemcontext = get_system_context();
|
||||
$userids = get_users_by_capability($systemcontext, 'moodle/site:mnetlogintoremote', 'u.id');
|
||||
|
||||
if (empty($userids)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($userids), SQL_PARAMS_NAMED, 'uid0000');
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
|
||||
Reference in New Issue
Block a user