From 49a5008c12df079367850d0e70992c40b076419a Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 24 Feb 2021 10:48:10 +1300 Subject: [PATCH] Bug 21249: (follow-up) Implement SearchLibraryLimit for individual library before this patch, the limit only applies to groups of libraries --- catalogue/search.pl | 19 +++++++++++++++++++ opac/opac-search.pl | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/catalogue/search.pl b/catalogue/search.pl index 4446ca944b..a9a840f7bb 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -395,6 +395,25 @@ if ( $params->{'multibranchlimit'} ) { } } +for ( my $i=0; $i<@limits; $i++ ) { + if ( $limits[$i] =~ /^branch:/ ) { + my $branchfield = C4::Context->preference('SearchLimitLibrary'); + if ( $branchfield eq "homebranch" ) { + $limits[$i] =~ s/branch/homebranch/; + } + elsif ( $branchfield eq "holdingbranch" ) { + $limits[$i] =~ s/branch/holdingbranch/; + } + else { + my $homebranchlimit = $limits[$i]; + my $holdingbranchlimit = $limits[$i]; + $homebranchlimit =~ s/branch/homebranch/; + $holdingbranchlimit =~ s/branch/holdingbranch/; + $limits[$i] = "$homebranchlimit or $holdingbranchlimit"; + } + } +} + my $available; foreach my $limit(@limits) { if ($limit =~/available/) { diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 0643dfc15e..6fb25e9f12 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -516,6 +516,25 @@ if ( $params->{'multibranchlimit'} || ( $branch_group_limit && $branch_group_lim } } +for ( my $i=0; $i<@limits; $i++ ) { + if ( $limits[$i] =~ /^branch:/ ) { + my $branchfield = C4::Context->preference('SearchLimitLibrary'); + if ( $branchfield eq "homebranch" ) { + $limits[$i] =~ s/branch/homebranch/; + } + elsif ( $branchfield eq "holdingbranch" ) { + $limits[$i] =~ s/branch/holdingbranch/; + } + else { + my $homebranchlimit = $limits[$i]; + my $holdingbranchlimit = $limits[$i]; + $homebranchlimit =~ s/branch/homebranch/; + $holdingbranchlimit =~ s/branch/holdingbranch/; + $limits[$i] = "$homebranchlimit or $holdingbranchlimit"; + } + } +} + my $available; foreach my $limit(@limits) { if ($limit =~/available/) { -- 2.11.0