Commit 97d1ad65 authored by Nigel McNie's avatar Nigel McNie

Prevent a crash when adding an institution with the same name as an existing one. Fixes #1851.

parent b1dcb7a2
......@@ -250,6 +250,12 @@ else {
$smarty->assign('institutions', $institutions);
}
function institution_validate(Pieform $form, $values) {
if (!$form->get_error('name') && record_exists('institution', 'name', $values['name'])) {
$form->set_error('name', get_string('institutionnamealreadytaken', 'admin'));
}
}
function institution_submit(Pieform $form, $values) {
global $SESSION, $institution, $add, $instancearray;
......
......@@ -256,6 +256,7 @@ $string['deleteinstitutionconfirm'] = 'Are you really sure you wish to delete th
$string['institutionaddedsuccessfully'] = 'Institution added successfully. Please configure an authentication plugin for this institution.';
$string['institutiondeletedsuccessfully'] = 'Institution deleted successfully';
$string['institutionname'] = 'Institution name';
$string['institutionnamealreadytaken'] = 'This institution name is already taken';
$string['institutiondisplayname'] = 'Institution display name';
$string['institutionupdatedsuccessfully'] = 'Institution updated successfully';
$string['registrationallowed'] = 'Registration allowed?';
......
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