From 10211f840185de527e8b1ea1d9eab61feba426d1 Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Wed, 31 Jul 2024 21:28:41 +0000 Subject: [PATCH] Bug 35434: (follow-up) Added canreservefromotherbranches When IndependentBranches is enabled, canreservefromotherbranches set to don't allow is also required to prevent non-superlibrarians from placing holds in other libraries. Signed-off-by: David Nind --- Koha/Item.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 60144f96d0..2713e73dad 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1032,7 +1032,15 @@ is not passed. sub pickup_locations { my ( $self, $params ) = @_; - return Koha::Libraries->search( { branchcode => $self->holdingbranch } ) if C4::Context->preference("IndependentBranches") && !C4::Context->IsSuperLibrarian(); + if ( C4::Context->preference("IndependentBranches") + and !C4::Context->preference("canreservefromotherbranches") ) + { + my $userenv = C4::Context->userenv; + unless ( C4::Context->IsSuperLibrarian ) { + return Koha::Libraries->new()->empty if ( $self->homebranch ne $userenv->{branch} ); + return Koha::Libraries->search( { branchcode => $self->homebranch } ); + } + } Koha::Exceptions::MissingParameter->throw( parameter => 'patron' ) unless exists $params->{patron}; -- 2.34.1