From 7338571f4ad3c9fcc0cf090c5ca96c484d7251d9 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 31 Aug 2016 15:27:44 +0200 Subject: [PATCH] Bug 17229: Check if patron is expired in CanItemBeReserved This way, calls to ILS-DI HoldTitle and HoldItem do this check too Added test plan to commit message : -Set Syspref BlockExpiredPatronOpacActions to "ON", -Set a patron's category variable "Block expired patrons" to "Follow SysPref" or -"Block" (ideally test both). -Get the id of a patron from this category (ie : 1234). -Set this patron's expiration date to a date earlier than today. -Get a biblionumber which can be reserved (ie : 5678). Put the following string in your webbrowser (replacing OpacBaseUrl, 1234 and 5678 by your own values) : http://[OpacBaseUrl]/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=1234&bib_id=5678&request_location='127.0.0.1' Should not create a new hold for the patron and report an error. Signed-off-by: Brendan Gallagher Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 9c3f267350b07c16b4c8297ee7c05853748a26f9) Signed-off-by: Fridolin Somers --- C4/ILSDI/Services.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index dfe80c14f2..a28c382d68 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -728,9 +728,13 @@ sub HoldTitle { my $patron = Koha::Patrons->find( $borrowernumber ); return { code => 'PatronNotFound' } unless $patron; + # If borrower is restricted return an error code return { code => 'PatronRestricted' } if $patron->is_debarred; + # Check for patron expired, category and syspref settings + return { code => 'PatronExpired' } if ($patron->category->effective_BlockExpiredPatronOpacActions && $patron->is_expired); + # Get the biblio record, or return an error code my $biblionumber = $cgi->param('bib_id'); my $biblio = Koha::Biblios->find( $biblionumber ); @@ -839,6 +843,9 @@ sub HoldItem { # If borrower is restricted return an error code return { code => 'PatronRestricted' } if $patron->is_debarred; + # Check for patron expired, category and syspref settings + return { code => 'PatronExpired' } if ($patron->category->effective_BlockExpiredPatronOpacActions && $patron->is_expired); + # Get the biblio or return an error code my $biblionumber = $cgi->param('bib_id'); my $biblio = Koha::Biblios->find( $biblionumber ); -- 2.39.5