Commit d3088a6e authored by Nigel McNie's avatar Nigel McNie
Browse files

If a new institution is being created and registration is turned on,...

If a new institution is being created and registration is turned on, automatically insert an internal authinstance.

Cleaned up the message relating to this behaviour too. This change make it easier to add institutions.
parent ae0ac744
......@@ -406,6 +406,17 @@ function institution_submit(Pieform $form, $values) {
if ($add) {
insert_record('institution', $newinstitution);
// If registration has been turned on, then we automatically insert an
// internal authentication authinstance
if ($newinstitution->registerallowed) {
$authinstance = (object)array(
'instancename' => 'internal',
'priority' => 0,
'institution' => $newinstitution->name,
'authname' => 'internal',
);
insert_record('auth_instance', $authinstance);
}
}
else {
$where = new StdClass;
......@@ -426,7 +437,12 @@ function institution_submit(Pieform $form, $values) {
db_commit();
if ($add) {
$message = get_string('institutionaddedsuccessfully', 'admin');
if ($newinstitution->registerallowed) {
// If registration is not allowed, then an authinstance will not
// have been created, and thus cause the institution page to add
// its own error message on the next page load
$SESSION->add_ok_msg(get_string('institutionaddedsuccessfully2', 'admin'));
}
$nexturl = '/admin/users/institutions.php?i='.urlencode($institution);
}
else {
......@@ -435,10 +451,10 @@ function institution_submit(Pieform $form, $values) {
&& (!empty($oldtheme) || $values['theme'] != 'sitedefault')) {
$message .= ' ' . get_string('usersseenewthemeonlogin', 'admin');
}
$SESSION->add_ok_msg($message);
$nexturl = '/admin/users/institutions.php';
}
$SESSION->add_ok_msg($message);
redirect($nexturl);
}
......
......@@ -328,7 +328,7 @@ $string['addinstitution'] = 'Add Institution';
$string['authplugin'] = 'Authentication plugin';
$string['deleteinstitution'] = 'Delete Institution';
$string['deleteinstitutionconfirm'] = 'Are you really sure you wish to delete this institution?';
$string['institutionaddedsuccessfully'] = 'Institution added successfully. Please configure an authentication plugin for this institution.';
$string['institutionaddedsuccessfully2'] = 'Institution added successfully';
$string['institutiondeletedsuccessfully'] = 'Institution deleted successfully';
$string['noauthpluginforinstitution'] = 'Your site administrator has not configured an authentication plugin for this institution.';
$string['adminnoauthpluginforinstitution'] = 'Please configure an authentication plugin for this institution.';
......
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