From f672b840e593d05c4e6055854267e31fe5adc911 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 14 Oct 2022 06:43:38 +0000 Subject: [PATCH] Bug 31784: Replace some singleBranchMode occurrences Speaks for itself. Test plan: Run t/Koha.t. Check if OPAC shows Library or Libraries in masthead, depending on number of public branches. Login, place a hold. Verify things work as expected. Note: MARC21 XSLT does not care about singleBranchMode. Signed-off-by: Marcel de Rooy Signed-off-by: David Nind Signed-off-by: Katrin Fischer --- C4/Auth.pm | 4 +++- C4/XSLT.pm | 2 +- opac/opac-reserve.pl | 2 +- t/Koha.t | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a006baa8d8..2edb5b0ffd 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -457,6 +457,7 @@ sub get_template_and_user { my $minPasswordLength = C4::Context->preference('minPasswordLength'); $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3; + my $singleLibraryMode = Koha::Libraries->singleLibraryMode; $template->param( EnhancedMessagingPreferences => C4::Context->preference('EnhancedMessagingPreferences'), GoogleJackets => C4::Context->preference("GoogleJackets"), @@ -469,7 +470,8 @@ sub get_template_and_user { hide_marc => C4::Context->preference("hide_marc"), item_level_itypes => C4::Context->preference('item-level_itypes'), patronimages => C4::Context->preference("patronimages"), - singleBranchMode => ( Koha::Libraries->search->count == 1 ), + singleBranchMode => $singleLibraryMode, #TODO one day our templates will only contain Library, and this can be removed + singleLibraryMode => $singleLibraryMode, noItemTypeImages => C4::Context->preference("noItemTypeImages"), marcflavour => C4::Context->preference("marcflavour"), OPACBaseURL => C4::Context->preference('OPACBaseURL'), diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 8c2b4c1bcd..feec005349 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -107,7 +107,7 @@ sub get_xslt_sysprefs { # singleBranchMode was a system preference, but no longer is # we can retain it here for compatibility - my $singleBranchMode = Koha::Libraries->search->count == 1 ? 1 : 0; + my $singleBranchMode = Koha::Libraries->singleLibraryMode; $sysxml .= "$singleBranchMode\n"; $sysxml .= "\n"; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index ec3d6adcb8..8e271dd605 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -226,7 +226,7 @@ if ( $query->param('place_reserve') ) { my $canreserve = 0; - my $singleBranchMode = Koha::Libraries->search->count == 1; + my $singleBranchMode = Koha::Libraries->singleLibraryMode; if ( $singleBranchMode || ! C4::Context->preference("OPACAllowUserToChooseBranch") ) { # single branch mode or disabled user choosing $branch = $patron->branchcode; diff --git a/t/Koha.t b/t/Koha.t index 6c12ec8061..a8851d0288 100755 --- a/t/Koha.t +++ b/t/Koha.t @@ -113,12 +113,12 @@ is( C4::Koha::GetNormalizedOCLCNumber(), undef, 'GetNormalizedOCLCNumber should subtest 'getFacets() tests' => sub { plan tests => 5; - is ( Koha::Libraries->search->count, 1, 'There should be only 1 library (singleBranchMode on)' ); + is ( Koha::Libraries->search->count, 1, 'There should be only 1 library' ); my $facets = C4::Koha::getFacets(); is( scalar( grep { defined $_->{idx} && $_->{idx} eq 'location' } @$facets ), 1, - 'location facet present with singleBranchMode on (bug 10078)' + 'location facet present with one library (bug 10078)' ); $libraries = [ @@ -126,13 +126,13 @@ subtest 'getFacets() tests' => sub { ['ZZZ_test', 'my branchname XXX'], ]; fixtures($libraries); - is ( Koha::Libraries->search->count, 3, 'There should be only more than 1 library (singleBranchMode off)' ); + is ( Koha::Libraries->search->count, 3, 'There should be only more than 1 library' ); $facets = C4::Koha::getFacets(); is( scalar( grep { defined $_->{idx} && $_->{idx} eq 'location' } @$facets ), 1, - 'location facet present with singleBranchMode off (bug 10078)' + 'location facet present with >1 library (bug 10078)' ); }; -- 2.30.2