Skip to content

Commit

Permalink
System: removed Date of Birth field from Public Registration when no …
Browse files Browse the repository at this point in the history
…minimum registration age is set (#1881)

Co-authored-by: Ross Parker <>
Co-authored-by: Sandra Kuipers <[email protected]>
  • Loading branch information
rossdotparker and SKuipers authored Feb 3, 2025
1 parent 695b291 commit fd8d918
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ v29.0.00
Security

Tweaks & Additions
System: removed Date of Birth field from Public Registration when no minimum registration age is set
Attendance: updated Student History view to display Off Timetable days
Library: improved the Library Borrowing page on student profiles
Library: improved the Lending & Activity Log workflow when scanning in IDs from barcodes
Expand Down
8 changes: 5 additions & 3 deletions publicRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@
$row->addLabel('gender', __('Gender'));
$row->addSelectGender('gender')->required();

$row = $form->addRow();
$row->addLabel('dob', __('Date of Birth'));
$row->addDate('dob')->required();
if ($publicRegistrationMinimumAge != "") {
$row = $form->addRow();
$row->addLabel('dob', __('Date of Birth'));
$row->addDate('dob')->required();
}

$row = $form->addRow();
$row->addLabel('usernameCheck', __('Username'));
Expand Down
13 changes: 4 additions & 9 deletions publicRegistrationProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

$settingGateway = $container->get(SettingGateway::class);

$publicRegistrationMinimumAge = $settingGateway->getSettingByScope('User Admin', 'publicRegistrationMinimumAge');

if ($session->exists('username') == false) {
$enablePublicRegistration = $settingGateway->getSettingByScope('User Admin', 'enablePublicRegistration');
if ($enablePublicRegistration == 'Y') {
Expand All @@ -65,12 +67,7 @@
$preferredName = trim($firstName);
$officialName = $firstName.' '.$surname;
$gender = $_POST['gender'] ?? '';
$dob = $_POST['dob'] ?? '';
if ($dob == '') {
$dob = null;
} else {
$dob = Format::dateConvert($dob);
}
$dob = !empty($_POST['dob']) ? Format::dateConvert($_POST['dob']) : null;
$email = filter_var(trim($_POST['email'] ?? ''), FILTER_SANITIZE_EMAIL);
$emailAlternate = filter_var(trim($_POST['emailAlternate'] ?? ''), FILTER_SANITIZE_EMAIL);
$username = trim($_POST['usernameCheck']);
Expand All @@ -81,7 +78,7 @@
$gibbonRoleIDPrimary = $settingGateway->getSettingByScope('User Admin', 'publicRegistrationDefaultRole');
$gibbonRoleIDAll = $gibbonRoleIDPrimary;

if ($surname == '' or $firstName == '' or $preferredName == '' or $officialName == '' or $gender == '' or $dob == '' or $email == '' or $username == '' or $password == '' or $gibbonRoleIDPrimary == '' or $gibbonRoleIDPrimary == '' or ($status != 'Pending Approval' and $status != 'Full')) {
if ($surname == '' or $firstName == '' or $preferredName == '' or $officialName == '' or $gender == '' or ($publicRegistrationMinimumAge != '' and $dob == '') or $email == '' or $username == '' or $password == '' or $gibbonRoleIDPrimary == '' or $gibbonRoleIDPrimary == '' or ($status != 'Pending Approval' and $status != 'Full')) {
header("Location: {$URL->withReturn('error1')}");
exit;
}
Expand Down Expand Up @@ -135,8 +132,6 @@
}

// Check publicRegistrationMinimumAge
$publicRegistrationMinimumAge = $settingGateway->getSettingByScope('User Admin', 'publicRegistrationMinimumAge');

if (!empty($publicRegistrationMinimumAge) > 0 and $publicRegistrationMinimumAge > (new DateTime('@'.Format::timestamp($dob)))->diff(new DateTime())->y) {
header("Location: {$URL->withReturn('error5')}");
exit;
Expand Down

0 comments on commit fd8d918

Please sign in to comment.