Bugzilla – Attachment 70106 Details for
Bug 19301
Move C4::Reserves::OnShelfHoldsAllowed to the Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19301: Move C4::Reserves::OnShelfHoldsAllowed to get_onshelfholds_policy
Bug-19301-Move-C4ReservesOnShelfHoldsAllowed-to-ge.patch (text/plain), 6.44 KB, created by
Marcel de Rooy
on 2017-12-22 09:34:01 UTC
(
hide
)
Description:
Bug 19301: Move C4::Reserves::OnShelfHoldsAllowed to get_onshelfholds_policy
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-12-22 09:34:01 UTC
Size:
6.44 KB
patch
obsolete
>From 66b8f31fef2a23ff2ae8a4c42704af169164dccf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 11 Sep 2017 16:02:19 -0300 >Subject: [PATCH] Bug 19301: Move C4::Reserves::OnShelfHoldsAllowed to > get_onshelfholds_policy >Content-Type: text/plain; charset=utf-8 > >Following the pattern introduced by bug 19300, we are going to move the >OnShelfHoldsAllowed logic to Koha::IssuingRules->get_onshelfholds_policy > >Test plan: >Make sure the onshelfholds policy is correct when placing a hold > >Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Reserves.pm | 8 +++++--- > Koha/IssuingRules.pm | 15 +++++++++++++++ > opac/opac-ISBDdetail.pl | 5 ++++- > opac/opac-MARCdetail.pl | 3 ++- > opac/opac-detail.pl | 3 ++- > opac/opac-shelves.pl | 3 ++- > 6 files changed, 30 insertions(+), 7 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 2a131e2..71e63aa 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1101,10 +1101,12 @@ sub IsAvailableForItemLevelRequest { > # FIXME - a lot of places in the code do this > # or something similar - need to be > # consolidated >- my $itype = _get_itype($item); >+ my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); >+ my $item_object = Koha::Items->find( $item->{itemnumber } ); >+ my $itemtype = $item_object->effective_itemtype; > my $notforloan_per_itemtype > = $dbh->selectrow_array("SELECT notforloan FROM itemtypes WHERE itemtype = ?", >- undef, $itype); >+ undef, $itemtype); > > return 0 if > $notforloan_per_itemtype || >@@ -1113,7 +1115,7 @@ sub IsAvailableForItemLevelRequest { > $item->{withdrawn} || > ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems')); > >- my $on_shelf_holds = _OnShelfHoldsAllowed($itype,$borrower->{categorycode},$item->{holdingbranch}); >+ my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item_object, patron => $patron } ); > > if ( $on_shelf_holds == 1 ) { > return 1; >diff --git a/Koha/IssuingRules.pm b/Koha/IssuingRules.pm >index f3da6e2..ff40c1c 100644 >--- a/Koha/IssuingRules.pm >+++ b/Koha/IssuingRules.pm >@@ -100,6 +100,21 @@ sub get_opacitemholds_policy { > return $issuing_rule ? $issuing_rule->opacitemholds : undef; > } > >+sub get_onshelfholds_policy { >+ my ( $class, $params ) = @_; >+ my $item = $params->{item}; >+ my $itemtype = $item->effective_itemtype; >+ my $patron = $params->{patron}; >+ my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( >+ { >+ ( $patron ? ( categorycode => $patron->categorycode ) : () ), >+ itemtype => $itemtype, >+ branchcode => $item->holdingbranch >+ } >+ ); >+ return $issuing_rule ? $issuing_rule->onshelfholds : undef; >+} >+ > =head3 type > > =cut >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index d9447cc..41be3eb 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -52,6 +52,8 @@ use C4::Reserves; > use C4::Acquisition; > use C4::Serials; # uses getsubscriptionfrom biblionumber > use C4::Koha; >+use Koha::IssuingRules; >+use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; > use Koha::RecordProcessor; >@@ -169,6 +171,7 @@ my $res = GetISBDView({ > my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; > my $patron = Koha::Patrons->find( $loggedinuser ); > for my $itm (@items) { >+ my $item = Koha::Items->find( $itm->{itemnumber} ); > $norequests = 0 > if $norequests > && !$itm->{'withdrawn'} >@@ -177,7 +180,7 @@ for my $itm (@items) { > && !$itemtypes->{$itm->{'itype'}}->{notforloan} > && $itm->{'itemnumber'}; > >- $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, ( $patron ? $patron->unblessed : {} ) ) >+ $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; > } > >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index 90b2974..4c1735c 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -132,7 +132,8 @@ if(my $cart_list = $query->cookie("bib_list")){ > my $allow_onshelf_holds; > my $patron = Koha::Patrons->find( $loggedinuser ); > for my $itm (@all_items) { >- $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, ( $patron ? $patron->unblessed : {} ) ); >+ my $items = Koha::Items->find( $itm->{itemnumber} ); >+ $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); > last if $allow_onshelf_holds; > } > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index b217a03..941f125 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -661,6 +661,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) { > } else { > my $patron = Koha::Patrons->find( $borrowernumber ); > for my $itm (@items) { >+ my $item = Koha::Items->find( $itm->{itemnumber} ); > $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; > $itm->{priority} = $priority{ $itm->{itemnumber} }; > $norequests = 0 >@@ -671,7 +672,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) { > && !$itemtypes->{$itm->{'itype'}}->{notforloan} > && $itm->{'itemnumber'}; > >- $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, ( $patron ? $patron->unblessed : {} ) ) >+ $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; > > # get collection code description, too >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index 1feaf57..b2799ea 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -31,6 +31,7 @@ use C4::XSLT; > > use Koha::Biblios; > use Koha::Biblioitems; >+use Koha::IssuingRules; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; >@@ -319,7 +320,7 @@ if ( $op eq 'view' ) { > > my $items = $biblio->items; > while ( my $item = $items->next ) { >- $this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($item->unblessed, $patron); >+ $this_item->{allow_onshelf_holds} = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); > last if $this_item->{allow_onshelf_holds}; > } > >-- >2.1.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 19301
:
67122
|
67123
|
67420
|
67421
|
69846
|
69847
| 70106 |
70107
|
70108
|
70109