From 52d1a2c2eada7084596dce88afcf9f20a7567c95 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 28 Mar 2024 12:52:29 +0000 Subject: [PATCH] Bug 34597: Implementation New can_patron_place_ill_in_opac method to include all rules that need checking to determine if a patron is allowed to place an ILL request on the OPAC or not. Added effective_BlockExpiredPatronOpacActions_contains rule to this new method. Test plan, k-t-d,: 1) Install FreeForm and enable ILLmodule, run: bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) 2) Edit a patron category, visit: /cgi-bin/koha/admin/categories.pl 3) Set 'Placing an ILL request' for the "Block expired patrons" input config 4) Add a new patron of one of the above category, make sure this patron is expired (set an expirydate to the past). 5) Login as that user and visit ILL page in OPAC: /cgi-bin/koha/opac-illrequests.pl 6) Confirm there is no "Create a new request" button 7) Access the create a new request page url directly: /cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=FreeForm 8) Confirm you get a 403 page 9) Set the 'Block expired actions' to "Follow system preference BlockExpiredPatronOpacActions" 10) Test different values of the BlockExpiredPatronOpacActions system preference and confirm the behaviour matches what's configured --- Koha/Illrequest.pm | 26 +++++++++++++++++++ .../bootstrap/en/modules/opac-illrequests.tt | 4 +-- opac/opac-illrequests.pl | 11 ++++---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 9dfe275eff0..b3dad703476 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -2033,6 +2033,32 @@ sub strings_map { return $strings; } +=head3 can_patron_place_ill_in_opac + + my $can_patron_place_ill_in_opac = Koha::Illrequest->can_patron_place_ill_in_opac($patron); + +Returns whether the given patron can place an ILL request in OPAC + +=over + +=item patron + +Patron object + +=back + +=cut + +sub can_patron_place_ill_in_opac { + my ( $self, $patron ) = @_; + + return 0 + unless $patron->_result->categorycode->can_place_ill_in_opac + && !( $patron->is_expired + && $patron->category->effective_BlockExpiredPatronOpacActions_contains('ill_request') ); + return 1; +} + =head3 get_op_param_deprecation my $op = Koha::Illrequest->check_url_param_deprecation($params); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt index bea312b56f6..a6c836444b0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -112,7 +112,7 @@

Interlibrary loan requests

[% INCLUDE messages %] - [% IF can_place_ill_in_opac %] + [% IF can_patron_place_ill_in_opac %] [% END %] - [% IF can_place_ill_in_opac %] + [% IF can_patron_place_ill_in_opac %]
diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index eea96ddf2e7..882b1b0a7fd 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -73,7 +73,8 @@ if ( $illrequest_id = $params->{illrequest_id} ) { } } -if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$patron->_result->categorycode->can_place_ill_in_opac ) { +my $can_patron_place_ill_in_opac = Koha::Illrequest->can_patron_place_ill_in_opac($patron); +if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$can_patron_place_ill_in_opac ) { print $query->redirect('/cgi-bin/koha/errors/403.pl'); exit; } @@ -180,10 +181,10 @@ if ( $op eq 'list' ) { } $template->param( - can_place_ill_in_opac => $patron->_result->categorycode->can_place_ill_in_opac, - message => $params->{message}, - illrequestsview => 1, - op => $op + can_patron_place_ill_in_opac => $can_patron_place_ill_in_opac, + message => $params->{message}, + illrequestsview => 1, + op => $op ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.30.2