Bug 41814: Add PatronAgeRestriction syspref and code
This patch adds a new PatronAgeRestriction, which acts in the same way
PatronSelfRegistrationAgeRestriction (a restriction on the maximum age
of a borrower), except for the intranet. It will also act as the
maximum age restrictor on the OPAC, in the event that the
PatronSelfRegistrationAgeRestriction is not set.
To test:
== APPLY PATCH ==
a) updatedatabase
b) Set the PatronAgeRestriction syspref to 20, set the
PatronSelfRegistrationAgeRestriction to 30
c) On the OPAC, try to create or modify a patron whose age is 35 years
*) Note the error message presented, suggesting the age exceeds the
maximum
d) On the OPAC, try to create or modify a patron whose age is 25 years
*) Note the submission succeeds
e) On the staff client, try to create or modify a patron whose age is
25 years *) Note the error message presented, suggesting the age
exceeds the maximum
f) Set the PatronSelfRegistrationAgeRestriction to empty
g) On the OPAC, try to create or modify a patron whose age is 25 years
*) Note the error message presented, suggesting the age exceeds
the maximum
h) On the OPAC, try to create or modify a patron whose age is 19 years
*) Note the submission succeeds
i) Set the PatronAgeRestriction to empty
j) On the staff client, try to create or modify a patron whose age is
75 years
*) Note the submission succeeds
k) On the OPAC, try to create or modify a patron whose age is 75 years
*) Note the submission succeeds
== SIGN OFF ==
Sponsored-by: Cheshire West and Chester Council
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
parent
23c88ff85b
commit
c1f0d97e8b
|
|
@ -0,0 +1,26 @@
|
|||
use Modern::Perl;
|
||||
use Koha::Installer::Output qw(say_warning say_success say_info);
|
||||
|
||||
return {
|
||||
bug_number => "XXXXX",
|
||||
description => "Add a new syspref for PatronAgeRestriction",
|
||||
up => sub {
|
||||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||
|
||||
# Do you stuffs here
|
||||
$dbh->do(
|
||||
q{
|
||||
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('PatronAgeRestriction', '', NULL, 'Patron\'s maximum age during registration. If empty, no age restriction is applied.', 'Integer')
|
||||
}
|
||||
);
|
||||
say $out "Added new syspref 'PatronAgeRestriction'";
|
||||
|
||||
$dbh->do(
|
||||
q{
|
||||
UPDATE IGNORE systempreferences SET `explanation` = 'Patron\'s maximum age during self registration. If empty, honor PatronAgeRestriction.' WHERE `variable` = 'PatronSelfRegistrationAgeRestriction'
|
||||
}
|
||||
);
|
||||
say $out "Updated explanation for syspref 'PatronSelfRegistrationAgeRestriction'";
|
||||
},
|
||||
};
|
||||
|
|
@ -629,6 +629,7 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES
|
|||
('OverduesBlockCirc','noblock'),
|
||||
('OverduesBlockRenewing','allow'),
|
||||
('PassItemMarcToXSLT','0'),
|
||||
('PatronAgeRestriction', ''),
|
||||
('PatronAnonymizeDelay',''),
|
||||
('PatronAutoComplete','1'),
|
||||
('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth'),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
[% SET return_claims = patron.return_claims %]
|
||||
[% SET logged_in_branchcode = Branches.GetLoggedInBranchcode() %]
|
||||
|
||||
[% IF ( has_modifications || warndeparture || returnbeforeexpiry || expired || patron.gonenoaddress || patron.lost || userdebarred || odues || ( return_claims.count > ClaimReturnedWarningThreshold ) || age_limitations || limited_category || charges || charges_guarantors_guarantees || charges_guarantees || credits || patron.account_locked ) %]
|
||||
[% IF ( has_modifications || warndeparture || returnbeforeexpiry || expired || patron.gonenoaddress || patron.lost || userdebarred || odues || ( return_claims.count > ClaimReturnedWarningThreshold ) || age_out_of_range || age_limitations || limited_category || charges || charges_guarantors_guarantees || charges_guarantees || credits || patron.account_locked ) %]
|
||||
<h3>Attention</h3>
|
||||
<ul>
|
||||
[% IF ( has_modifications ) %]
|
||||
|
|
@ -137,6 +137,14 @@
|
|||
</li>
|
||||
[% END %]
|
||||
|
||||
[% IF age_out_of_range %]
|
||||
<li class="invalid_age">
|
||||
<span class="circ-hlt">Patron's age exceeds the maximum age allowed.</span>
|
||||
Maximum permitted age is [% age_max | html %]
|
||||
<a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&borrowernumber=[% patron.borrowernumber | uri %]&step=3" class="btn btn-default btn-xs">Change category</a>
|
||||
</li>
|
||||
[% END %]
|
||||
|
||||
[% IF limited_category %]
|
||||
<li class="limited_category">
|
||||
<span class="circ-hlt">The patron's current category ([% Categories.GetName(patron.categorycode) | html %]) is limited to other libraries.</span>
|
||||
|
|
|
|||
|
|
@ -922,7 +922,7 @@ OPAC:
|
|||
- "Patron's maximum age when registering: "
|
||||
- pref: PatronSelfRegistrationAgeRestriction
|
||||
class: integer
|
||||
- "<br />Note: If empty, do not restrict patron's age during self registration"
|
||||
- "<br />Note: If empty, honor the PatronAgeRestriction preference."
|
||||
Suggestions:
|
||||
-
|
||||
- pref: OpacSuggestionManagedBy
|
||||
|
|
|
|||
|
|
@ -324,6 +324,11 @@ Patrons:
|
|||
type: modalselect
|
||||
source: borrowers
|
||||
- "will be added to the patron quick add form when entering a new patron. Displays only mandatory fields and fields specified here. If applicable the guarantor form will be shown as well, individual fields in that form will be ignored."
|
||||
-
|
||||
- "Patron's maximum age when registering: "
|
||||
- pref: PatronAgeRestriction
|
||||
class: integer
|
||||
- "<br />Note: If this field is left empty, no age restriction is applied."
|
||||
-
|
||||
- "When adding new patrons or editing existing patrons, collapse the following fields from the full form (can still be expanded later):"
|
||||
- pref: CollapseFieldsPatronAddForm
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@
|
|||
[% IF ( ERROR_age_limitations ) %]
|
||||
<li id="ERROR_age_limitations">Patron's age is incorrect for their category. Ages allowed are [% age_low | html %]-[% age_high | html %].</li>
|
||||
[% END %]
|
||||
[% IF ( ERROR_age_out_of_range ) %]
|
||||
<li id="ERROR_age_out_of_range">Patron's age exceeds the maximum age allowed. Maximum permitted age is [% age_max | html %]</li>
|
||||
[% END %]
|
||||
[% IF ( ERROR_branch ) %]
|
||||
<li id="ERROR_branch">Library is invalid.</li>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@
|
|||
[% 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>
|
||||
[% IF field == "ERROR_age_out_of_range" %]
|
||||
<li>Patron's age exceeds the maximum age allowed.</li>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -392,11 +392,18 @@ if ( $op eq 'cud-save' || $op eq 'cud-insert' ) {
|
|||
my $patron = Koha::Patron->new( { dateofbirth => $dateofbirth } );
|
||||
my $age = $patron->get_age;
|
||||
my ( $low, $high ) = ( $category->dateofbirthrequired, $category->upperagelimit );
|
||||
my $age_restriction = C4::Context->preference("PatronAgeRestriction");
|
||||
|
||||
if ( ( $high && ( $age > $high ) ) or ( $age < $low ) ) {
|
||||
push @errors, 'ERROR_age_limitations';
|
||||
$template->param( age_low => $low );
|
||||
$template->param( age_high => $high );
|
||||
}
|
||||
|
||||
if ( $age_restriction && $age > $age_restriction ) {
|
||||
push @errors, 'ERROR_age_out_of_range';
|
||||
$template->param( age_max => $age_restriction );
|
||||
}
|
||||
}
|
||||
|
||||
if ( C4::Context->preference("IndependentBranches") ) {
|
||||
|
|
|
|||
|
|
@ -558,12 +558,17 @@ 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");
|
||||
my $age_restriction =
|
||||
C4::Context->preference("PatronSelfRegistrationAgeRestriction")
|
||||
|| C4::Context->preference("PatronAgeRestriction")
|
||||
|| undef;
|
||||
|
||||
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';
|
||||
|
||||
if ( $age_restriction && $age > $age_restriction ) {
|
||||
push @invalidFields, 'ERROR_age_out_of_range';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue