Bugzilla – Attachment 64972 Details for
Bug 17829
Move GetMember to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17829: followup for request.pl
Bug-17829-followup-for-requestpl.patch (text/plain), 8.81 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-07-10 15:23:52 UTC
(
hide
)
Description:
Bug 17829: followup for request.pl
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-07-10 15:23:52 UTC
Size:
8.81 KB
patch
obsolete
>From c53313a247e7090377ef9edb1c9fe3ddbedd0fc9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 5 Apr 2017 14:05:07 -0300 >Subject: [PATCH] Bug 17829: followup for request.pl > >This script is really ugly and need to be rewritten completely to >separate the different action. >$patron is not always defined, we need to take it into account. >Note that this patch is mainly indentation changes. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > reserve/request.pl | 128 ++++++++++++++++++++++++++++------------------------- > 1 file changed, 67 insertions(+), 61 deletions(-) > >diff --git a/reserve/request.pl b/reserve/request.pl >index b0c3329..15ad54a 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -215,29 +215,31 @@ foreach my $biblionumber (@biblionumbers) { > > my $dat = GetBiblioData($biblionumber); > >- my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber ); >- $canReserve //= ''; >- if ( $canReserve eq 'OK' ) { >+ my $force_hold_level; >+ if ( $patron ) { >+ { # CanBookBeReserved >+ my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber ); >+ $canReserve //= ''; >+ if ( $canReserve eq 'OK' ) { > >- #All is OK and we can continue >- } >- elsif ( $canReserve eq 'tooManyReserves' ) { >- $exceeded_maxreserves = 1; >- } >- elsif ( $canReserve eq 'tooManyHoldsForThisRecord' ) { >- $exceeded_holds_per_record = 1; >- $biblioloopiter{$canReserve} = 1; >- } >- elsif ( $canReserve eq 'ageRestricted' ) { >- $template->param( $canReserve => 1 ); >- $biblioloopiter{$canReserve} = 1; >- } >- else { >- $biblioloopiter{$canReserve} = 1; >- } >+ #All is OK and we can continue >+ } >+ elsif ( $canReserve eq 'tooManyReserves' ) { >+ $exceeded_maxreserves = 1; >+ } >+ elsif ( $canReserve eq 'tooManyHoldsForThisRecord' ) { >+ $exceeded_holds_per_record = 1; >+ $biblioloopiter{$canReserve} = 1; >+ } >+ elsif ( $canReserve eq 'ageRestricted' ) { >+ $template->param( $canReserve => 1 ); >+ $biblioloopiter{$canReserve} = 1; >+ } >+ else { >+ $biblioloopiter{$canReserve} = 1; >+ } >+ } > >- my $force_hold_level; >- if ( $patron->borrowernumber ) { > # For multiple holds per record, if a patron has previously placed a hold, > # the patron can only place more holds of the same type. That is, if the > # patron placed a record level hold, all the holds the patron places must >@@ -261,15 +263,17 @@ foreach my $biblionumber (@biblionumbers) { > $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record; > $template->param( max_holds_for_record => $max_holds_for_record ); > $template->param( remaining_holds_for_record => $remaining_holds_for_record ); >- } > >- # Check to see if patron is allowed to place holds on records where the >- # patron already has an item from that record checked out >- my $alreadypossession; >- if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') >- && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) ) >- { >- $template->param( alreadypossession => $alreadypossession, ); >+ { # alreadypossession >+ # Check to see if patron is allowed to place holds on records where the >+ # patron already has an item from that record checked out >+ my $alreadypossession; >+ if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') >+ && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) ) >+ { >+ $template->param( alreadypossession => $alreadypossession, ); >+ } >+ } > } > > >@@ -392,13 +396,13 @@ foreach my $biblionumber (@biblionumbers) { > # checking reserve > my $holds = Koha::Items->find( $itemnumber )->current_holds; > if ( my $first_hold = $holds->next ) { >- my $patron = Koha::Patrons->find( $first_hold->borrowernumber ); >+ my $p = Koha::Patrons->find( $first_hold->borrowernumber ); > > $item->{backgroundcolor} = 'reserved'; > $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template >- $item->{ReservedForBorrowernumber} = $first_hold->borrowernumber; >- $item->{ReservedForSurname} = $patron->surname; >- $item->{ReservedForFirstname} = $patron->firstname; >+ $item->{ReservedForBorrowernumber} = $p->borrowernumber; >+ $item->{ReservedForSurname} = $p->surname; >+ $item->{ReservedForFirstname} = $p->firstname; > $item->{ExpectedAtLibrary} = $first_hold->branchcode; > $item->{waitingdate} = $first_hold->waitingdate; > } >@@ -451,41 +455,43 @@ foreach my $biblionumber (@biblionumbers) { > } > } > >- my $patron_unblessed = $patron->unblessed; >- my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed); >+ if ( $patron ) { >+ my $patron_unblessed = $patron->unblessed; >+ my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed); > >- my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} ); >+ my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} ); > >- $item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; >+ $item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; > >- my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber ); >- $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' ); >+ my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber ); >+ $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' ); > >- $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed); >+ $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed); > >- if ( >- !$item->{cantreserve} >- && !$exceeded_maxreserves >- && IsAvailableForItemLevelRequest($item, $patron_unblessed) >- && $can_item_be_reserved eq 'OK' >- ) >- { >- $item->{available} = 1; >- $num_available++; >+ if ( >+ !$item->{cantreserve} >+ && !$exceeded_maxreserves >+ && IsAvailableForItemLevelRequest($item, $patron_unblessed) >+ && $can_item_be_reserved eq 'OK' >+ ) >+ { >+ $item->{available} = 1; >+ $num_available++; > >- push( @available_itemtypes, $item->{itype} ); >- } >- elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { >- # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules >- $item->{override} = 1; >- $num_override++; >- } >+ push( @available_itemtypes, $item->{itype} ); >+ } >+ elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { >+ # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules >+ $item->{override} = 1; >+ $num_override++; >+ } > >- # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked >+ # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked > >- # Show serial enumeration when needed >- if ($item->{enumchron}) { >- $itemdata_enumchron = 1; >+ # Show serial enumeration when needed >+ if ($item->{enumchron}) { >+ $itemdata_enumchron = 1; >+ } > } > > push @{ $biblioitem->{itemloop} }, $item; >@@ -611,7 +617,7 @@ foreach my $biblionumber (@biblionumbers) { > holdsview => 1, > C4::Search::enabled_staff_search_views, > ); >- if ( $patron ) { # FIXME This test seems very useless >+ if ( $patron ) { > $template->param( borrower_branchcode => $patron->branchcode ); > } > >-- >2.7.4
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 17829
:
64872
|
64873
|
64971
| 64972 |
64973
|
64976
|
65002
|
65213
|
65286
|
65549
|
65778
|
66360
|
68634