From ae1765c8027cef9b568cedd4df81f349a01c55b5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 14 Feb 2020 12:45:54 +0100 Subject: [PATCH] Bug 21746: Remove GetLoggedInBranchcode This method from the Branches TT plugin is not needed as we can use logged_in_user --- Koha/Template/Plugin/Branches.pm | 8 -------- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt | 2 +- t/db_dependent/Template/Plugin/Branches.t | 7 +------ 7 files changed, 6 insertions(+), 19 deletions(-) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 08dbcb5c1a..27512f6e01 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -37,14 +37,6 @@ sub GetName { return $b ? $b->{'branchname'} : q{}; } -sub GetLoggedInBranchcode { - my ($self) = @_; - - return C4::Context->userenv ? - C4::Context->userenv->{'branch'} : - ''; -} - sub GetURL { my ( $self, $branchcode ) = @_; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 1eeb19e3af..e01d17b3db 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -787,7 +787,7 @@ Hold placed on [% w.reservedate | $KohaDates %].
- [% IF ( w.branch.branchcode == Branches.GetLoggedInBranchcode() ) %][% ELSE %][% END %] + [% IF ( w.branch.branchcode == logged_in_user.branchcode ) %][% ELSE %][% END %] [% SET expires_on = w.expirationdate %] Waiting at [% w.branch.branchname | html %] [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt index e2257fc8e5..ead954802a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt @@ -136,7 +136,7 @@ [% FOREACH b IN Branches.all %] - [% IF b.branchcode == Branches.GetLoggedInBranchcode %] + [% IF b.branchcode == logged_in_user.library.branchcode %] [% ELSE %] diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t index be0d1134f9..61374e571c 100644 --- a/t/db_dependent/Template/Plugin/Branches.t +++ b/t/db_dependent/Template/Plugin/Branches.t @@ -39,7 +39,7 @@ my $builder = t::lib::TestBuilder->new; subtest 'all() tests' => sub { - plan tests => 16; + plan tests => 14; $schema->storage->txn_begin; @@ -68,12 +68,7 @@ subtest 'all() tests' => sub { $name = $plugin->GetName(undef); is($name, '', 'received empty string as name of NULL/undefined library code'); - $library = $plugin->GetLoggedInBranchcode(); - is($library, '', 'no active library if there is no active user session'); - t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY' }); - $library = $plugin->GetLoggedInBranchcode(); - is($library, 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library'); t::lib::Mocks::mock_preference( 'IndependentBranches', 0 ); my $libraries = $plugin->all(); -- 2.11.0