From 03129f718f48be24b99d561d1c699977959fab2a Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 13 Oct 2022 14:49:31 +0200 Subject: [PATCH] Bug 31775: Show single library Test plan: Check both cases: one library (public accessible) and more libraries (public accessible). In the latter case click on one of these libraries too. Signed-off-by: Marcel de Rooy Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- opac/opac-library.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/opac/opac-library.pl b/opac/opac-library.pl index fda1956278..24611a1980 100755 --- a/opac/opac-library.pl +++ b/opac/opac-library.pl @@ -21,6 +21,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); +use C4::Context; use C4::Output qw( output_html_with_http_headers ); use Koha::Libraries; @@ -37,21 +38,20 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -my $found; -if ($branchcode) { - my $library = Koha::Libraries->find($branchcode); - if ( $library && $library->public ) { - $found++; - $template->param( library => $library ); - } +my $library; +if( $template->{VARS}->{singleBranchMode} ) { + $library = Koha::Libraries->search({ public => 1 })->next; +} elsif( $branchcode ) { + $library = Koha::Libraries->search({ branchcode => $branchcode, public => 1 })->next; } -unless ($found) { +if( $library ) { + $template->param( library => $library ); +} else { my $libraries = Koha::Libraries->search( { public => 1 }, { order_by => ['branchname'] } ); - $template->param( libraries => $libraries, - branchcode => $branchcode, + branchcode => C4::Context->userenv ? C4::Context->userenv->{branch} : q{}, ); } -- 2.39.5