From 7a8c5f8f31c63f700fe63d212b83361af169cf94 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 31 Mar 2023 05:12:48 +0100 Subject: [PATCH] Bug 18203: Add per borrower category restrictions on placing ILL requests Default value for canplaceillopac is 1 Patron in a category that cannot place ill can still visit illlist and illview --- Koha/Schema/Result/Category.pm | 15 ++++++++-- admin/categories.pl | 3 ++ .../data/mysql/atomicupdate/bug_18203.pl | 17 +++++++++++ installer/data/mysql/kohastructure.sql | 1 + .../prog/en/modules/admin/categories.tt | 29 +++++++++++++++++++ .../bootstrap/en/modules/opac-illrequests.tt | 20 ++++++++----- opac/opac-illrequests.pl | 11 +++++-- 7 files changed, 83 insertions(+), 13 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_18203.pl diff --git a/Koha/Schema/Result/Category.pm b/Koha/Schema/Result/Category.pm index d6281bf36a8..8a3ef2bdf73 100644 --- a/Koha/Schema/Result/Category.pm +++ b/Koha/Schema/Result/Category.pm @@ -162,6 +162,14 @@ Default privacy setting for this patron category produce a warning for this patron category if this item has previously been checked out to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'. +=head2 canplaceillopac + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +can this patron category place interlibrary loan requests + =head2 can_be_guarantee data_type: 'tinyint' @@ -259,6 +267,8 @@ __PACKAGE__->add_columns( is_nullable => 0, size => 7, }, + "canplaceillopac", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "can_be_guarantee", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "reset_password", @@ -378,8 +388,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-08 17:35:26 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B89OgAY/KnJbQaHpu5Xdfg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-31 03:27:07 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YYc52oTevOT+WXnDsG2mrQ sub koha_object_class { 'Koha::Patron::Category'; @@ -389,6 +399,7 @@ sub koha_objects_class { } __PACKAGE__->add_columns( + '+canplaceillopac' => { is_boolean => 1 }, '+can_be_guarantee' => { is_boolean => 1 }, '+exclude_from_local_holds_priority' => { is_boolean => 1 }, '+require_strong_password' => { is_boolean => 1 }, diff --git a/admin/categories.pl b/admin/categories.pl index 53c4182b47c..6a335b9737d 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/installer/data/mysql/atomicupdate/bug_18203.pl b/installer/data/mysql/atomicupdate/bug_18203.pl new file mode 100755 index 00000000000..68a2145739e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_18203.pl @@ -0,0 +1,17 @@ +use Modern::Perl; + +return { + bug_number => "18203", + description => "Add per borrower category restrictions on ILL placement", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + unless ( column_exists('categories', 'canplaceillopac') ) { + $dbh->do(q{ + ALTER TABLE `categories` + ADD COLUMN `canplaceillopac` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'can this patron category place interlibrary loan requests' + AFTER `checkprevcheckout`; + }); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a3faa37d794..4a5cdc41f0c 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1676,6 +1676,7 @@ CREATE TABLE `categories` ( `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL DEFAULT -1 COMMENT 'wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions', `default_privacy` enum('default','never','forever') NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category', `checkprevcheckout` varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.', + `canplaceillopac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'can this patron category place interlibrary loan requests', `can_be_guarantee` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'if patrons of this category can be guarantees', `reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,', `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC', 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 5f56479aec4..6ddc2a0c35b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -405,6 +405,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 e619707451e..5c8e436e430 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -56,9 +56,15 @@ 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'; +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( @@ -154,9 +160,7 @@ if ( $op eq 'list' ) { } } - $params->{cardnumber} = Koha::Patrons->find({ - borrowernumber => $loggedinuser - })->cardnumber; + $params->{cardnumber} = $patron->cardnumber; $params->{opac} = 1; my $backend_result = $request->backend_create($params); if ($backend_result->{stage} eq 'copyrightclearance') { @@ -181,6 +185,7 @@ if ( $op eq 'list' ) { } $template->param( + canplaceillopac => $patron->_result->categorycode->canplaceillopac, message => $params->{message}, illrequestsview => 1, method => $op -- 2.30.2