From 68b124dc0eae843bb4470ea62371e18135a398dd Mon Sep 17 00:00:00 2001 From: Emily-Rose Francoeur Date: Wed, 29 Nov 2023 10:42:54 -0500 Subject: [PATCH] Bug 35434: Prevent non-superlibrarians from placing holds in other libraries when using IndependentBranches When IndependentBranches is enabled and canreservefromotherbranches is set to don't allow, then non-superlibrarians should not be able to place holds for other libraries. Test plan: 1. Appy the patch. 2. In Koha administration > System preferences, set: - IndependentBranches: Yes - canreservefromotherbranches: Don't allow 3. In Koha administration > Circulation and fines rules, check that you have a rule for all patron categories and all item types, with unlimited holds. 4. Find (or create) a staff patron for a library other than Centerville: - Change the username and password so you can log in as the staff patron. - Add permissions to the staff patron (More > Set permissions): . Staff access, allows viewing of catalogue in staff interface . Add, modify and view patron information . Place and modify holds for patrons 5. Find (or create) a patron with the same home library as the staff patron in step 4. 6. Find (or create) a record with an item where the home and current library are the same as the staff patron in step 3 and the patron in step 5. 7. As a superlibrarian place a hold for the record from step 6 using the patron from step 5: - If placing a hold for the next available item, the "Pickup at" dropdown list should list all libraies. - If placing a hold on a specific item, the dropdown list for the "Allowed pickup locations" column for each item should also list all libraries. - After placing the hold, in the "Existing holds" table, the dropdown list for each hold in the "Pickup library" column should also list all libraries. 8. Log out from the staff interface and login with the staff patron from step 4. 9. Find the record from step 6 and place a hold using the patron from step 5 - the library dropdown list should be limited to the item's home library: - If placing a hold for the next available item, the "Pickup at" dropdown list should only list the item's home library. - If placing a hold on a specific item, the dropdown list for the "Allowed pickup locations" column for each item should also only list the item's home library. - After placing the hold, in the "Existing holds" table, the "Pickup library" column should now only show the item's home librayr, with no dropdown list. Signed-off-by: Anni Rajala Signed-off-by: baptiste Signed-off-by: David Nind --- Koha/Item.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/Item.pm b/Koha/Item.pm index e950118336..60144f96d0 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1032,6 +1032,8 @@ is not passed. sub pickup_locations { my ( $self, $params ) = @_; + return Koha::Libraries->search( { branchcode => $self->holdingbranch } ) if C4::Context->preference("IndependentBranches") && !C4::Context->IsSuperLibrarian(); + Koha::Exceptions::MissingParameter->throw( parameter => 'patron' ) unless exists $params->{patron}; -- 2.34.1