From 13720defdda83e00e2633051c14a887ffbe56ca0 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 12 Jul 2023 09:19:15 +0000 Subject: [PATCH] Bug 18203: Add per borrower category restrictions on placing ILL requests Test Plan: - Enable ILLModule sys pref and install any backend, or run bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) - Verify you can place new ILL requests in OPAC and Intranet - Apply patch - In borrower categories, verify there's a new column for 'can place ILL in opac' and is set to 'yes' by default - Edit your borrower's patron category and set 'can place ILL in opac' to 'No' - Verify you can no longer place new ILL requests in OPAC - Verify you also cannot place new ILL requests through URL: :8080/cgi-bin/koha/opac-illrequests.pl?method=create&backend=FreeForm Signed-off-by: Sam Lau Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- admin/categories.pl | 3 ++ .../prog/en/modules/admin/categories.tt | 30 +++++++++++++++++++ .../bootstrap/en/modules/opac-illrequests.tt | 20 ++++++++----- opac/opac-illrequests.pl | 11 +++++-- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/admin/categories.pl b/admin/categories.pl index 53c4182b47..6a335b9737 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -72,6 +72,7 @@ elsif ( $op eq 'add_validate' ) { my $category_type = $input->param('category_type'); my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions'); my $checkPrevCheckout = $input->param('checkprevcheckout'); + my $canplaceillopac = $input->param('canplaceillopac'); my $default_privacy = $input->param('default_privacy'); my $reset_password = $input->param('reset_password'); my $change_password = $input->param('change_password'); @@ -105,6 +106,7 @@ elsif ( $op eq 'add_validate' ) { $category->can_be_guarantee($can_be_guarantee); $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); $category->checkprevcheckout($checkPrevCheckout); + $category->canplaceillopac($canplaceillopac); $category->default_privacy($default_privacy); $category->reset_password($reset_password); $category->change_password($change_password); @@ -138,6 +140,7 @@ elsif ( $op eq 'add_validate' ) { can_be_guarantee => $can_be_guarantee, BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, checkprevcheckout => $checkPrevCheckout, + canplaceillopac => $canplaceillopac, default_privacy => $default_privacy, reset_password => $reset_password, change_password => $change_password, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index 9d006752dc..aff8ca18e5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -384,6 +384,23 @@ [% END %] + [% IF ( Koha.Preference('ILLModule') ) %] +
  • + + +
    + Choose whether patrons of this category can create new interlibrary loan requests. +
    +
  • + [% END %]
  • @@ -243,6 +246,7 @@ [% END %] Cancel + [% END %] [% ELSIF method == 'availability' %]

    Interlibrary loan item availability

    diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index b66c34677c..5a351edc9a 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -58,6 +58,7 @@ my $reduced = C4::Context->preference('ILLOpacbackends'); my $backends = Koha::Illrequest::Config->new->available_backends($reduced); my $backends_available = ( scalar @{$backends} > 0 ); $template->param( backends_available => $backends_available ); +my $patron = Koha::Patrons->find($loggedinuser); my $op = $params->{'method'} || 'list'; @@ -71,6 +72,11 @@ if ( $illrequest_id = $params->{illrequest_id} ) { } } +if ( ( $op eq 'create' || $op eq 'cancreq' || $op eq 'update' ) && !$patron->_result->categorycode->canplaceillopac ) { + print $query->redirect('/cgi-bin/koha/errors/403.pl'); + exit; +} + if ( $op eq 'list' ) { my $requests = Koha::Illrequests->search( @@ -140,9 +146,7 @@ if ( $op eq 'list' ) { exit; } - $params->{cardnumber} = Koha::Patrons->find({ - borrowernumber => $loggedinuser - })->cardnumber; + $params->{cardnumber} = $patron->cardnumber; $params->{opac} = 1; my $backend_result = $request->backend_create($params); @@ -175,6 +179,7 @@ if ( $op eq 'list' ) { } $template->param( + canplaceillopac => $patron->_result->categorycode->canplaceillopac, message => $params->{message}, illrequestsview => 1, method => $op -- 2.39.5