Bugzilla – Attachment 182046 Details for
Bug 39579
Add ability to restrict patron date of birth on self registration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39579: Restrict Patron Self Reg Date of Birth
Bug-39579-Restrict-Patron-Self-Reg-Date-of-Birth.patch (text/plain), 7.03 KB, created by
Lisette Scheer
on 2025-05-07 20:10:35 UTC
(
hide
)
Description:
Bug 39579: Restrict Patron Self Reg Date of Birth
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2025-05-07 20:10:35 UTC
Size:
7.03 KB
patch
obsolete
>From f56858b1e1afafbec38945954a67f44817eb95b8 Mon Sep 17 00:00:00 2001 >From: Alexander Blanchard <alexander.blanchard@openfifth.co.uk> >Date: Tue, 8 Apr 2025 12:55:03 +0000 >Subject: [PATCH] Bug 39579: Restrict Patron Self Reg Date of Birth >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Some libraries are getting dates of birth from the >self-registration form that make patrons impossible >ages, e.g. year of birth 1900. > >To Test: >1) Navigate to the oPac >2) Ensure you are not logged in >3) Below the log in, see 'Create an Account' >4) Click the link and complete the relevant fields >5) Add an unrealistic d.o.b e.g 1900 >6) Complete the verification and click 'Submit' >7) Your acount has been created >8) Apply the patch >9) Navigate to the staff site >10) Navigate to Administration > SystemPreferences >11) Navigate to OPAC preferences >12) Identify PatronSelfRegistrationAgeRestriction >13) Add a maximum age in numberals e.g. 100 >14) Repeat steps 1 - 6 >15) An error message that you have exceeded max age will appear. >16) Alter your date of birth to make your age below that of the max age you set >17) Complete the verification >18) Your account should be created as normal > >Sponsored-by: Cheshire >Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com> >Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> >--- > ...9579-patronselfregistrationagerestriction.pl | 17 +++++++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 5 +++++ > .../bootstrap/en/modules/opac-memberentry.tt | 3 +++ > opac/opac-memberentry.pl | 4 ++++ > 5 files changed, 30 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug_39579-patronselfregistrationagerestriction.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_39579-patronselfregistrationagerestriction.pl b/installer/data/mysql/atomicupdate/bug_39579-patronselfregistrationagerestriction.pl >new file mode 100644 >index 00000000000..cb2fd1d21cd >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_39579-patronselfregistrationagerestriction.pl >@@ -0,0 +1,17 @@ >+use Modern::Perl; >+use Koha::Installer::Output qw(say_warning say_success say_info); >+ >+return { >+ bug_number => '39579', >+ description => "Add system preference 'patronSelfRegistrationAgeRestriction'", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ $dbh->do( " >+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ ('PatronSelfRegistrationAgeRestriction', '', NULL, 'Patron\'s maximum age during self registration. If empty, no age restriction is applied.', 'Integer') >+ " ); >+ say_success( $out, "Added new system preference 'PatronSelfRegistrationAgeRestriction'" ); >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index f788223be19..e4dc1fa4a9d 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -623,6 +623,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'), > ('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'), > ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), >+('PatronSelfRegistrationAgeRestriction', '', NULL, 'Patron\'s maximum age during self registration. If empty, no age restriction is applied.', 'Integer'), > ('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo'), > ('PatronSelfRegistrationBorrowerMandatoryField','surname|firstname',NULL,'Choose the mandatory fields for a patron\'s account, when registering via the OPAC.','free'), > ('PatronSelfRegistrationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when registering a new patron via the OPAC.','free'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 58af318881c..29bc0b27056 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -924,6 +924,11 @@ OPAC: > 0: "Don't show" > 1: "Show" > - an alert on staff interface home page when there are patrons in the category defined by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>. >+ - >+ - "Patron's maximum age when registering: " >+ - pref: PatronSelfRegistrationAgeRestriction >+ class: integer >+ - "<br />Note: If empty, do not restrict patron's age during self registration" > Suggestions: > - > - pref: OpacSuggestionManagedBy >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 7e54a42fe25..7b3c9895fbf 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -115,6 +115,9 @@ > [% IF field == "ERROR_age_limitations" %] > <li>Patron's age is incorrect for their category.</li> > [% END %] >+ [% IF field == "ERROR_age_limitations_self_registration" %] >+ <li> Patron's age exceeds the maximum age allowed.</li> >+ [% END %] > [% END %] > </ul> > <span>Please correct and resubmit.</span> >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index eaf37924650..274cb81971e 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -545,9 +545,13 @@ sub CheckForInvalidFields { > my $age = $patron->get_age; > my $borrowercategory = Koha::Patron::Categories->find( $borrower->{'categorycode'} ); > my ( $low, $high ) = ( $borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit ); >+ my $upper_registration_age_restriction = C4::Context->preference("PatronSelfRegistrationAgeRestriction"); > if ( ( $high && ( $age > $high ) ) or ( $age < $low ) ) { > push @invalidFields, 'ERROR_age_limitations'; > } >+ if ( $upper_registration_age_restriction && $age > $upper_registration_age_restriction ) { >+ push @invalidFields, 'ERROR_age_limitations_self_registration'; >+ } > } > > return \@invalidFields; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39579
:
180718
|
180938
| 182046 |
182047