diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 51a2df93a3..05932dac68 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -43,8 +43,7 @@ sub GetLoggedInBranchcode { sub GetLoggedInBranchname { my ($self) = @_; - my $code = $self->GetLoggedInBranchcode; - return $code ? $self->GetName($code) : q{}; + return C4::Context->userenv ? C4::Context->userenv->{'branchname'} : q{}; } sub GetURL { diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t index 17a41b7fe6..f6141d9345 100644 --- a/t/db_dependent/Template/Plugin/Branches.t +++ b/t/db_dependent/Template/Plugin/Branches.t @@ -71,7 +71,7 @@ subtest 'all() tests' => sub { is($plugin->GetLoggedInBranchcode(), '', 'no active library code if there is no active user session'); is($plugin->GetLoggedInBranchname(), '', 'no active library name if there is no active user session'); - t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY' }); + t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY', branchname => 'My sweet library' }); is($plugin->GetLoggedInBranchcode(), 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library code'); is($plugin->GetLoggedInBranchname(), 'My sweet library', 'GetLoggedInBranchname() returns active library name');