Bugzilla – Attachment 121526 Details for
Bug 25408
CanBookBeReserved & CanItemBeReserved should check "opacitemholds" policy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & CanItemBeReserved
Bug-25408-Add-opacitemholds-checks-in-CanBookBeRes.patch (text/plain), 6.80 KB, created by
Arthur Suzuki
on 2021-06-01 09:58:50 UTC
(
hide
)
Description:
Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & CanItemBeReserved
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2021-06-01 09:58:50 UTC
Size:
6.80 KB
patch
obsolete
>From ef85487387fa33798bcee96e36e07b0bf91b2d9e Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Thu, 7 May 2020 12:33:46 +0200 >Subject: [PATCH] Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & > CanItemBeReserved > >The rule "opacitemholds" seemed not to be controlled in some cases. >This patch adds a control for this issuingrule in such a way it is checked across all interfaces (staff, opac, api) >Added error message when trying to hold on the record and opacitemhold is set to "Force" to item-level hold > >To test: >0 - Apply patches >1 - Set rule to "Don't allow" item specific holds on opac >2 - Attempt to place hold on staff side >3 - Hold is still allowed >4 - Attempt to place hold from opac or api >5 - Hold is not allowed >6 - Change rule to 'force' >7 - Item-level hold can be placed in all interfaces >8 - Record-level hold cannot be placed in all interfaces > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > C4/Reserves.pm | 14 ++++++++++++-- > .../prog/en/modules/reserve/request.tt | 6 ++++-- > reserve/placerequest.pl | 2 +- > reserve/request.pl | 4 ++++ > 4 files changed, 21 insertions(+), 5 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 8941d4f72c..83b63545b3 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -335,9 +335,14 @@ sub CanBookBeReserved{ > } > > my $canReserve = { status => '' }; >+ my ($rights,$item); >+ > foreach my $itemnumber (@itemnumbers) { > $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params ); >+ my $opacitemholds = $canReserve->{rights}->{opacitemholds} // 'Y'; >+ return { status => 'recordHoldNotAllowed' } if $opacitemholds eq 'F'; > return { status => 'OK' } if $canReserve->{status} eq 'OK'; >+ return { status => 'OK' } if $canReserve->{status} eq 'recordHoldsOnly'; > } > return $canReserve; > } >@@ -445,10 +450,11 @@ sub CanItemBeReserved { > categorycode => $borrower->{'categorycode'}, > itemtype => $item->effective_itemtype, > branchcode => $branchcode, >- rules => ['holds_per_record','holds_per_day'] >+ rules => ['holds_per_record','holds_per_day','opacitemholds'] > }); > my $holds_per_record = $rights->{holds_per_record} // 1; > my $holds_per_day = $rights->{holds_per_day}; >+ my $opacitemholds = $rights->{opacitemholds} // 'Y'; > > my $search_params = { > borrowernumber => $borrowernumber, >@@ -585,7 +591,11 @@ sub CanItemBeReserved { > } > } > >- return { status => 'OK' }; >+ if ( $opacitemholds eq "N" && C4::Context->interface eq 'opac') { >+ return { status => "recordHoldsOnly", right => $rights }; >+ } >+ >+ return { status => 'OK', rights => $rights }; > } > > =head2 CanReserveBeCanceledFromOpac >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 023049f011..6888717cc4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -333,7 +333,7 @@ > </div> > [% END %] > >- [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %] >+ [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted || recordHoldNotAllowed ) %] > <div class="dialog alert"> > > [% UNLESS ( multi_hold ) %] >@@ -355,6 +355,8 @@ > <li> <strong>No items are available</strong> to be placed on hold.</li> > [% ELSIF ( maxreserves ) %] > <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> has too many holds.</li> >+ [% ELSIF ( recordHoldNotAllowed ) %] >+ <li><strong>Record holds not allowed : </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> cannot put a record-level hold on this ressource.</li> > [% END # /IF exceeded_maxreserves %] > </ul> > [% ELSE # UNLESS multi_hold %] >@@ -531,7 +533,7 @@ > [% IF ( patron.borrowernumber ) %] > [% IF ( override_required ) %] > <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button> >- [% ELSIF ( none_available ) %] >+ [% ELSIF ( none_available || recordHoldNotAllowed ) %] > <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button> > [% ELSE %] > <button type="submit" class="btn btn-default">Place hold</button> >diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl >index 05b5c7f3c9..f8581c9417 100755 >--- a/reserve/placerequest.pl >+++ b/reserve/placerequest.pl >@@ -145,7 +145,7 @@ if ( $type eq 'str8' && $borrower ) { > } else { > # place a request on 1st available > for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) { >- if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) { >+ if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber, undef, { context => 'staff' })->{status} eq 'OK' ) { > AddReserve( > { > branchcode => $branch, >diff --git a/reserve/request.pl b/reserve/request.pl >index 7637692c99..d9ec0c9ca0 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -337,6 +337,10 @@ foreach my $biblionumber (@biblionumbers) { > $template->param( $canReserve->{status} => 1); > $biblioloopiter{ $canReserve->{status} } = 1; > } >+ elsif ( $canReserve->{status} eq 'recordHoldNotAllowed' ) { >+ $template->param( $canReserve->{status} => 1 ); >+ $biblioloopiter{ $canReserve->{status} } = 1; >+ } > else { > $biblioloopiter{ $canReserve->{status} } = 1; > } >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25408
:
104488
|
104496
|
105988
|
105989
|
105990
|
106413
|
106414
|
106521
|
106535
|
106536
|
106537
|
107777
|
107778
|
107779
|
107780
|
111681
|
111682
|
111693
|
111696
|
111716
|
111717
|
111718
|
111719
|
111720
|
111721
|
115125
|
115126
|
115127
|
115128
|
115129
|
115130
|
121524
|
121525
|
121526
|
121527
|
121528
|
121530
|
128505
|
130180
|
130181
|
132658
|
132660
|
132661
|
164680
|
164681
|
164682
|
164684
|
164685
|
164686
|
164693
|
164694
|
164878
|
164879
|
165111
|
165112
|
165442
|
165443
|
165444
|
165445