From fd8d9182265aa4a5ecf48074447c33e445c2bbbe Mon Sep 17 00:00:00 2001 From: Ross Parker Date: Mon, 3 Feb 2025 10:45:01 +0800 Subject: [PATCH] System: removed Date of Birth field from Public Registration when no minimum registration age is set (#1881) Co-authored-by: Ross Parker <> Co-authored-by: Sandra Kuipers --- CHANGELOG.txt | 1 + publicRegistration.php | 8 +++++--- publicRegistrationProcess.php | 13 ++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1d754da0af..80f03ae6e0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/publicRegistration.php b/publicRegistration.php index ac47ae84aa..3354c1aa4d 100644 --- a/publicRegistration.php +++ b/publicRegistration.php @@ -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')); diff --git a/publicRegistrationProcess.php b/publicRegistrationProcess.php index 3cfc72252a..451a98bde1 100644 --- a/publicRegistrationProcess.php +++ b/publicRegistrationProcess.php @@ -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') { @@ -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']); @@ -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; } @@ -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;