Commit de4f11e8 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Don't allow institutional admins to add users if their institutions have no authinstances

parent b09f51ff
......@@ -78,7 +78,17 @@ $elements['quota'] = array(
'defaultvalue' => get_config_plugin('artefact', 'file', 'defaultquota'),
);
$authinstances = auth_get_auth_instances();
if ($USER->get('admin')) {
$authinstances = auth_get_auth_instances();
} else {
$admininstitutions = $USER->get('admininstitutions');
$authinstances = auth_get_auth_instances_for_institutions($admininstitutions);
if (empty($authinstances)) {
$SESSION->add_info_msg(get_string('configureauthplugin', 'admin'));
redirect(get_config('wwwroot').'admin/users/institutions.php?i='.key($admininstitutions).'&edit=1');
}
}
if (count($authinstances) > 1) {
$options = array();
......
......@@ -74,7 +74,7 @@ if ($USER->get('admin')) {
$admininstitutions = $USER->get('admininstitutions');
$authinstances = auth_get_auth_instances_for_institutions($admininstitutions);
if (empty($authinstances)) {
$SESSION->add_info_msg(get_string('uploadcsvconfigureauthplugin', 'admin'));
$SESSION->add_info_msg(get_string('configureauthplugin', 'admin'));
redirect(get_config('wwwroot').'admin/users/institutions.php?i='.key($admininstitutions).'&edit=1');
}
}
......
......@@ -208,7 +208,7 @@ $string['emailusersaboutnewaccountdescription'] = 'Whether an e-mail should be s
$string['forceuserstochangepassword'] = 'Force password change?';
$string['forceuserstochangepassworddescription'] = 'Whether users should be forced to change their password when they log in for the first time';
$string['uploadcsvinstitution'] = 'The institution and authentication method for the new users';
$string['uploadcsvconfigureauthplugin'] = 'You must configure an authentication plugin before you can add users by CSV';
$string['configureauthplugin'] = 'You must configure an authentication plugin before you can add users';
$string['csvfiledescription'] = 'The file containing users to add';
$string['uploadcsverrorinvalidfieldname'] = 'The field name "%s" is invalid';
$string['uploadcsverrorrequiredfieldnotspecified'] = 'A required field "%s" has not been specified in the format line';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment