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

Respect institution's registerallowed setting on register page

parent c05e44b7
......@@ -180,6 +180,7 @@ $string['registerstep3fieldsmandatory'] = '<h3>Fill Out Mandatory Profile Fields
$string['registeringdisallowed'] = 'Sorry, you cannot register for this system at this time';
$string['membershipexpiry'] = 'Membership expires';
$string['institutionfull'] = 'The institution you have chosen is not accepting any more registrations.';
$string['registrationnotallowed'] = 'The institution you have chosen does not allow self-registration.';
// Forgot password
$string['cantchangepassword'] = 'Sorry, you are unable to change your password through this interface - please use your institution\'s interface instead';
......
......@@ -316,7 +316,8 @@ $sql = 'SELECT
{auth_instance} ai
WHERE
ai.authname = \'internal\' AND
ai.institution = i.name';
ai.institution = i.name AND
i.registerallowed = 1';
$institutions = get_records_sql_array($sql, array());
if (count($institutions) > 1) {
......@@ -433,21 +434,25 @@ function register_validate(Pieform $form, $values) {
$form->set_error('captcha', get_string('captchaincorrect'));
}
$membercount = get_record_sql('
$institution = get_record_sql('
SELECT
i.name, i.maxuseraccounts, COUNT(u.id)
i.name, i.maxuseraccounts, i.registerallowed, COUNT(u.id)
FROM {institution} i
LEFT OUTER JOIN {usr_institution} ui ON ui.institution = i.name
LEFT OUTER JOIN {usr} u ON (ui.usr = u.id AND u.deleted = 0)
WHERE
i.name = ?
GROUP BY
i.name, i.maxuseraccounts', array($institution));
i.name, i.maxuseraccounts, i.registerallowed', array($institution));
if (!empty($membercount->maxuseraccounts) && $membercount->count >= $membercount->maxuseraccounts) {
if (!empty($institution->maxuseraccounts) && $institution->count >= $institution->maxuseraccounts) {
$form->set_error('institution', get_string('institutionfull'));
}
if (!$institution->registerallowed) {
$form->set_error('institution', get_string('registrationnotallowed'));
}
}
function register_submit(Pieform $form, $values) {
......
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