Bugzilla – Attachment 183199 Details for
Bug 40101
Add `Koha::Patron->can_place_holds`
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40101: Make opac-reserve.pl use `$patron->can_place_holds()`
Bug-40101-Make-opac-reservepl-use-patron-canplaceh.patch (text/plain), 4.04 KB, created by
Andrew Fuerste-Henry
on 2025-06-12 12:37:20 UTC
(
hide
)
Description:
Bug 40101: Make opac-reserve.pl use `$patron->can_place_holds()`
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2025-06-12 12:37:20 UTC
Size:
4.04 KB
patch
obsolete
>From 83c844ce1af97f8376d3d24962b0148f67a5d1b8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 9 Jun 2025 15:15:03 -0300 >Subject: [PATCH] Bug 40101: Make opac-reserve.pl use > `$patron->can_place_holds()` > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org> >--- > opac/opac-reserve.pl | 78 ++++++++++++++++---------------------------- > 1 file changed, 28 insertions(+), 50 deletions(-) > >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 7ffd8e08ac1..6db213f2985 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -39,6 +39,7 @@ use Koha::Items; > use Koha::ItemTypes; > use Koha::Checkouts; > use Koha::Libraries; >+use Koha::Logger; > use Koha::Patrons; > use List::MoreUtils qw( uniq ); > >@@ -112,65 +113,42 @@ if ( $#biblionumbers < 0 && $op ne 'cud-place_reserve' ) { > # Here we check that the borrower can actually make reserves Stage 1. > # > # >-my $noreserves = 0; >-if ( $category->effective_BlockExpiredPatronOpacActions_contains('hold') ) { >- if ( $patron->is_expired ) { > >- # cannot reserve, their card has expired and the rules set mean this is not allowed >- $noreserves = 1; >- $template->param( message => 1, expired_patron => 1 ); >- } >-} >- >-my $maxoutstanding = C4::Context->preference("maxoutstanding"); >-my $amountoutstanding = $patron->account->balance; >-if ( $amountoutstanding && ( $amountoutstanding > $maxoutstanding ) ) { >- my $amount = sprintf "%.02f", $amountoutstanding; >- $template->param( message => 1 ); >- $noreserves = 1; >- $template->param( too_much_oweing => $amount ); >-} >- >-if ( $patron->gonenoaddress && ( $patron->gonenoaddress == 1 ) ) { >- $noreserves = 1; >- $template->param( >- message => 1, >- GNA => 1 >- ); >-} >+my $can_place_holds = $patron->can_place_holds( { no_short_circuit => 1 } ); > >-if ( $patron->lost && ( $patron->lost == 1 ) ) { >- $noreserves = 1; >- $template->param( >- message => 1, >- lost => 1 >- ); >-} >+if ( !$can_place_holds ) { > >-if ( $patron->is_debarred ) { >- $noreserves = 1; >- $template->param( >- message => 1, >- debarred => 1, >- debarred_comment => $patron->debarredcomment, >- debarred_date => $patron->debarred, >- ); >-} >- >-my $holds = $patron->holds; >-my $reserves_count = $holds->count; >-$template->param( RESERVES => $holds->unblessed ); >-if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) { > $template->param( message => 1 ); >- $noreserves = 1; >- $template->param( too_many_reserves => $holds->count ); >-} > >-if ($noreserves) { >+ my $messages = $can_place_holds->messages(); >+ foreach my $msg ( @{$messages} ) { >+ if ( $msg->message eq 'expired' ) { >+ $template->param( expired_patron => 1 ); >+ } elsif ( $msg->message eq 'debt_limit' ) { >+ $template->param( too_much_oweing => sprintf( "%.02f", $msg->{payload}->{total_outstanding} ) ); >+ } elsif ( $msg->message eq 'bad_address' ) { >+ $template->param( GNA => 1 ); >+ } elsif ( $msg->message eq 'card_lost' ) { >+ $template->param( lost => 1 ); >+ } elsif ( $msg->message eq 'restricted' ) { >+ $template->param( >+ debarred => 1, >+ debarred_comment => $patron->debarredcomment, >+ debarred_date => $patron->debarred, >+ ); >+ } elsif ( $msg->message eq 'hold_limit' ) { >+ $template->param( too_many_reserves => $msg->{payload}->{total_holds} ); >+ } else { >+ Koha::Logger->get->warn( sprintf( "Unhandled 'can_place_holds' error code: %s", $msg->message ) ); >+ } >+ } >+ > output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; > exit; > } > >+my $reserves_count = $patron->holds->count; >+ > # pass the pickup branch along.... > my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || ''; > $template->param( branch => $branch ); >-- >2.39.5
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 40101
:
183104
|
183105
|
183106
|
183197
|
183198
|
183199
|
183204
|
183242
|
183243
|
183244
|
183488
|
183489
|
183490