Skip to content

Commit

Permalink
Check if a pickup location is blocked by a patron category library li…
Browse files Browse the repository at this point in the history
…mitations (#34)

Some libraries do not want specific branches to ever be available to
certain patron categories. It is possible to 'hide' patron categories
from particular library branches. The inverse is also possible - hide
specific branches, as pickup locations, for a patron category using
library limitations.

Sponsored-by: Auckland University of Technology, New Zealand
  • Loading branch information
alexklbuckley authored Jun 6, 2024
1 parent 6c32574 commit 9de305d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Koha/Plugin/Fi/KohaSuomi/DI/Koha/Availability/Checks/Item.pm
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,19 @@ Checks if pickup location is allowed. $context_cache is a hash ref used to store
sub _pickup_location_allowed {
my ($self, $location, $patron, $context_cache) = @_;

# Skip pickup locations if those branches are not allowed in the patron
# category library limitations
if ( !defined $context_cache->{patron_category_library_limitation}->{$location} ) {
my $category = Koha::Patron::Categories->find($patron->categorycode);
if ( $category->library_limits ) {
if ( grep /^$location\z/, $category->library_limits->get_column('branchcode') ) {
return $context_cache->{patron_category_library_limitation}->{$location} = 1;
} else {
return $context_cache->{patron_category_library_limitation}->{$location} = 0;
}
}
}

if (!defined $context_cache->{can_place_hold_if_available_at_pickup}) {
my $can_place = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
unless ($can_place || !$patron) {
Expand Down

0 comments on commit 9de305d

Please sign in to comment.