LP1902937: Use setting for guardian check
authorJason Stephenson <jason@sigio.com>
Thu, 18 Nov 2021 13:54:08 +0000 (08:54 -0500)
committerJason Stephenson <jason@sigio.com>
Thu, 6 Apr 2023 18:32:29 +0000 (14:32 -0400)
Check the value of the ui.patron.edit.guardian_required_for_juv
setting before requiring the guardian field for juvenile eCard
registrations.  We should add our own setting for this.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm

index 68481c8..1b16c94 100644 (file)
@@ -465,17 +465,25 @@ sub verify_dob {
         return undef;
     }
 
+    # Check if guardian required for underage patrons.
+    # TODO: Add our own setting for this.
+    my $guardian_required = $U->ou_ancestor_setting_value(
+        $cgi->param('home_ou'),
+        'ui.patron.edit.guardian_required_for_juv'
+    );
+
     my $comp_date = DateTime->now;
     $comp_date->set_hour(0);
     $comp_date->set_minute(0);
     $comp_date->set_second(0);
+    # The juvenile age should be configurable.
     $comp_date->subtract(years => 18); # juv age
 
-    if (
-        $dob_date > $comp_date # less than 18 years old
-        && !$cgi->param('ident_value2')) {
+    if ($U->is_true($guardian_required)
+        && $dob_date > $comp_date
+        && !$cgi->param('guardian')) {
 
-        my $msg = "Parent/Guardian (ident_value2) is required for patrons ".
+        my $msg = "Parent/Guardian (guardian) is required for patrons ".
             "under 18 years of age. dob=$dob";
         $ctx->{response}->{status} = 'INVALID_PARAMS';
         push(@{$ctx->{response}->{messages}}, $msg);