From b7b3409620b09da79fdc65a680b5ca5b7ccb245b Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 16 Jun 2020 14:01:39 +0200 Subject: [PATCH] Bug 25765: Replace LoginBranchname and LoginBranchcode with use of Branches template plugin The template plugin Branches contains a method GetLoggedInBranchcode that returns current branch code. This patch adds GetLoggedInBranchname to get current branch name. It is used to replace vars LoginBranchname and LoginBranchcode sent to all templates in C4/Auth.pm. In labels and patrons cards modules, I choose to remove a unseless display of current branch in a hint. In acqui/acqui-home.tt, I choose to remove a useless display of current branch and also because table of founds contains a filter on library. Test plan: Check pages source code to see branch code or name is correct. list of the pages: /cgi-bin/koha/acqui/acqui-home.pl /cgi-bin/koha/catalogue/detail.pl?biblionumber=XXX /cgi-bin/koha/circ/branchoverdues.pl /cgi-bin/koha/circ/set-library.pl /cgi-bin/koha/circ/offline.pl /cgi-bin/koha/labels/label-edit-batch.pl?op=new /cgi-bin/koha/labels/label-manage.pl /cgi-bin/koha/patroncards/edit-batch.pl /cgi-bin/koha/patroncards/manage.pl OPAC: /cgi-bin/koha/opac-detail.pl?biblionumber=XXX Signed-off-by: Victor Grousset/tuxayo --- C4/Auth.pm | 3 --- circ/set-library.pl | 3 +-- koha-tmpl/intranet-tmpl/prog/en/includes/header.inc | 8 ++++---- .../intranet-tmpl/prog/en/includes/members-toolbar.inc | 2 +- .../intranet-tmpl/prog/en/modules/acqui/acqui-home.tt | 2 +- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 2 +- .../intranet-tmpl/prog/en/modules/circ/branchoverdues.tt | 6 +++--- koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt | 3 ++- .../intranet-tmpl/prog/en/modules/circ/set-library.tt | 2 +- .../prog/en/modules/labels/label-edit-batch.tt | 1 - .../intranet-tmpl/prog/en/modules/labels/label-manage.tt | 1 - .../prog/en/modules/patroncards/edit-batch.tt | 1 - .../intranet-tmpl/prog/en/modules/patroncards/manage.tt | 1 - koha-tmpl/opac-tmpl/bootstrap/en/includes/bodytag.inc | 5 +++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 2 +- 15 files changed, 18 insertions(+), 24 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 6889c2532c..449cfecd7b 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -462,7 +462,6 @@ sub get_template_and_user { GoogleJackets => C4::Context->preference("GoogleJackets"), OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), - LoginBranchcode => ( C4::Context->userenv ? C4::Context->userenv->{"branch"} : undef ), LoginFirstname => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ), LoginSurname => C4::Context->userenv ? C4::Context->userenv->{"surname"} : "Inconnu", emailaddress => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef, @@ -490,7 +489,6 @@ sub get_template_and_user { IntranetNav => C4::Context->preference("IntranetNav"), IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), LibraryName => C4::Context->preference("LibraryName"), - LoginBranchname => ( C4::Context->userenv ? C4::Context->userenv->{"branchname"} : undef ), advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), @@ -558,7 +556,6 @@ sub get_template_and_user { opac_name => $opac_name, LibraryName => "" . C4::Context->preference("LibraryName"), LibraryNameTitle => "" . $LibraryNameTitle, - LoginBranchname => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "", OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), diff --git a/circ/set-library.pl b/circ/set-library.pl index 375a7f7809..35b013ca33 100755 --- a/circ/set-library.pl +++ b/circ/set-library.pl @@ -49,14 +49,13 @@ my @updated; if ( $branch and my $library = Koha::Libraries->find($branch) ) { if (! $userenv_branch or $userenv_branch ne $branch ) { my $branchname = $library->branchname; - $template->param(LoginBranchname => $branchname); # update template for new branch - $template->param(LoginBranchcode => $branch); # update template for new branch $session->param('branchname', $branchname); # update sesssion in DB $session->param('branch', $branch); # update sesssion in DB $session->flush(); push @updated, { updated_branch => 1, old_branch => $userenv_branch, + new_branch => $branch, }; } # else branch the same, no update } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc index 868b22a418..ef6cf61c70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -77,11 +77,11 @@ | [% IF ( AutoLocation ) %] - [% LoginBranchname | html %] + [% Branches.GetLoggedInBranchname | html %] [% ELSE %] - [% LoginBranchname | html %] + [% Branches.GetLoggedInBranchname | html %] [% Branches.GetLoggedInBranchcode | html %] [% END %] @@ -97,11 +97,11 @@
  • [% IF ( AutoLocation ) %] - [% LoginBranchname | html %] + [% Branches.GetLoggedInBranchname | html %] [% ELSE %] Location:
    - [% LoginBranchname | html %] + [% Branches.GetLoggedInBranchname | html %] [% Branches.GetLoggedInBranchcode | html %] [% END %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index c9cbea57bf..bebe5a143c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -120,7 +120,7 @@ - +