From a52c2d33700e616ad01b3e52208ce0f508bc101f 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 --- 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.30.2