From 1698c36a8ee9cf3de2ad4d87b8c2fade0910d4ab 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 Signed-off-by: Victor Grousset/tuxayo Signed-off-by: David Cook Signed-off-by: Jonathan Druart --- 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 32bd6438fc..a2398db7e7 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -399,6 +399,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 b759d152b3..bc344c2076 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -505,6 +505,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.39.5