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:
<staff_url>/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:
<opac_url>/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 <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Pedro Amorim 2024-03-28 12:52:29 +00:00 committed by Martin Renvoize
parent 5793d9107f
commit e7ddc86657
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
3 changed files with 34 additions and 7 deletions

View file

@ -2108,6 +2108,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);

View file

@ -117,7 +117,7 @@
<h1>Interlibrary loan requests</h1>
[% INCLUDE messages %]
[% IF can_place_ill_in_opac %]
[% IF can_patron_place_ill_in_opac %]
<div id="illrequests-create-button" class="dropdown btn-group">
[% IF backends.size > 1 %]
<button class="btn btn-primary dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
@ -240,7 +240,7 @@
</div>
[% END %]
</div>
[% IF can_place_ill_in_opac %]
[% IF can_patron_place_ill_in_opac %]
<fieldset class="action illrequest-actions">
<input type="hidden" name="illrequest_id" value="[% request.illrequest_id | html %]" />
<input type="hidden" name="op" value="cud-update" />

View file

@ -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 };