From 60ba8f478de03d9641c01d0f069d1faa707c0b74 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) 1.5) Checkout FreeForm's reorganize_ILL branch: cd /kohadevbox/koha/Koha/Illbackends/FreeForm git checkout reorganize_ILL koha-plack --restart kohadev 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 Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- Koha/ILL/Request.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/ILL/Request.pm b/Koha/ILL/Request.pm index 49050abd90d..04c99863eed 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -2104,6 +2104,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 = $req->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 975c2a078e2..d8006b5775e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -117,7 +117,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 92f3e5e4f64..26be90a546b 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::ILL::Request->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; } @@ -181,10 +182,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.45.1