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 <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Fridolin Somers 2020-06-16 14:01:39 +02:00 committed by Jonathan Druart
parent 0fcd0fd270
commit cbd8655157
15 changed files with 18 additions and 24 deletions

View File

@ -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"),

View File

@ -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 {

View File

@ -77,11 +77,11 @@
<span class="separator">|</span>
[% IF ( AutoLocation ) %]
<brand>
[% LoginBranchname | html %]
[% Branches.GetLoggedInBranchname | html %]
</brand>
[% ELSE %]
<strong>
<span class="logged-in-branch-name">[% LoginBranchname | html %]</span>
<span class="logged-in-branch-name">[% Branches.GetLoggedInBranchname | html %]</span>
<span class="logged-in-branch-code content_hidden">[% Branches.GetLoggedInBranchcode | html %]</span>
</strong>
[% END %]
@ -97,11 +97,11 @@
<li class="loggedin-menu-label">
[% IF ( AutoLocation ) %]
<brand>
[% LoginBranchname | html %]
[% Branches.GetLoggedInBranchname | html %]
</brand>
[% ELSE %]
Location: <br />
<span class="logged-in-branch-name">[% LoginBranchname | html %]</span>
<span class="logged-in-branch-name">[% Branches.GetLoggedInBranchname | html %]</span>
<span class="logged-in-branch-code content_hidden">[% Branches.GetLoggedInBranchcode | html %]</span>
[% END %]
</li>

View File

@ -120,7 +120,7 @@
</div>
<input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input type="hidden" name="batch" value="[% batch | html %]" />
<input type="hidden" name="branchcode" value="[% LoginBranchcode | html %]" />
<input type="hidden" name="branchcode" value="[% Branches.GetLoggedInBranchcode | html %]" />
</div>
<div class="modal-footer">
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button>

View File

@ -64,7 +64,7 @@
[% IF ( loop_budget ) %]
<h3>All available funds[% IF LoginBranchname %] for [% LoginBranchname | html %][% END %]</h3>
<h3>All available funds</h3>
<div id="BudgetsAndFunds">
<table id="accounts">

View File

@ -174,7 +174,7 @@
<ul>
[% IF (SeparateHoldings) %]
<li>
<a href="#holdings">[% LoginBranchname | html %] holdings ([% itemloop.size() || 0 | html %])</a>
<a href="#holdings">[% Branches.GetLoggedInBranchname | html %] holdings ([% itemloop.size() || 0 | html %])</a>
</li>
<li>
<a href="#otherholdings">Other holdings ([% otheritemloop.size() || 0 | html %])</a>

View File

@ -1,14 +1,14 @@
[% USE Branches %]
[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Circulation &rsaquo; Overdues at [% LoginBranchname | html %]</title>
<title>Koha &rsaquo; Circulation &rsaquo; Overdues at [% Branches.GetLoggedInBranchname | html %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="circ_branchoverdues" class="circ">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'circ-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo; Overdues at [% LoginBranchname | html %]</div>
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo; Overdues at [% Branches.GetLoggedInBranchname | html %]</div>
<div class="main container-fluid">
<div class="row">
@ -19,7 +19,7 @@
[% END %]
<main>
<h1>Circulation: Overdues at [% LoginBranchname | html %]</h1>
<h1>Circulation: Overdues at [% Branches.GetLoggedInBranchname | html %]</h1>
<form name="selectlocation" action="branchoverdues.pl" method="post">
<label for="location">Shelving location selected: </label><select id="location" name="location">

View File

@ -1,5 +1,6 @@
[% USE raw %]
[% USE Asset %]
[% USE Branches %]
[% SET footerjs = 1 %]
<!DOCTYPE html>
[% IF (AllowOfflineCirculation) %]
@ -314,7 +315,7 @@
function synchronize() {
kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]");
kohadb.saveSetting("branchcode", "[% LoginBranchcode | html %]");
kohadb.saveSetting("branchcode", "[% Branches.GetLoggedInBranchcode | html %]");
showSyncInfo();
[% UNLESS (AllowOfflineCirculation) %]
reloadRecords();

View File

@ -36,7 +36,7 @@
Updated:<ul>
[% FOREACH update IN updated %]
[% IF ( update.updated_branch ) %]
<li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.LoginBranchcode or "?" | html %]</li>
<li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.new_branch or "?" | html %]</li>
[% ELSE %]
<li>ERROR - unknown</li>
[% END %]

View File

@ -57,7 +57,6 @@
[% END %]
<div id="manage-label-batches">
<div class="hint">Current library: [% LoginBranchname | html %]</div>
<form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
<div>
<fieldset class="rows" style="border-bottom: 0px; border: 0px;">

View File

@ -42,7 +42,6 @@
[% END %]
<div id="manage-label-layouts">
<div class="hint">Current library: [% LoginBranchname | html %]</div>
[% IF ( table_loop ) %]
<form name="layouts" action="/cgi-bin/koha/label-manage.pl?label_element=[% label_element | html %]">
[% IF ( label_element == 'layout' ) %]

View File

@ -38,7 +38,6 @@
[% INCLUDE 'patroncards-errors.inc' %]
<div id="manage-patroncard-batches">
<div class="hint">Current library: [% LoginBranchname | html %]</div>
<form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
<div>
<fieldset class="rows" style="border-bottom: 0px; border: 0px;">

View File

@ -45,7 +45,6 @@
[% INCLUDE 'patroncards-toolbar.inc' %]
[% INCLUDE 'patroncards-errors.inc' %]
<div id="manage-patroncards-layouts">
<div class="hint">Current library: [% LoginBranchname | html %]</div>
[% IF ( table_loop ) %]
<form name="layouts" action="/cgi-bin/koha/manage.pl?card_element=[% card_element | html %]">
<h2>Currently available [% PROCESS translate_card_element element=card_element_title FILTER lower %]</h2>

View File

@ -1,7 +1,8 @@
[% USE raw %]
[% USE Branches %]
[% SET classprop = 'class="' %]
[% IF LoginBranchcode.defined %]
[% classprop = classprop _ 'branch-' _ LoginBranchcode %]
[% IF Branches.GetLoggedInBranchcode %]
[% classprop = classprop _ 'branch-' _ Branches.GetLoggedInBranchcode %]
[% ELSE %]
[% classprop = classprop _ 'branch-default' %]
[% END %]

View File

@ -479,7 +479,7 @@
[% ELSE %]
<li id="tab_holdings">
[% END %]
[% BLOCK holding_tab_title %][% IF SeparateHoldings %]<span>[% LoginBranchname | html %] holdings</span>[% ELSE %][% IF specific_item %]<span>Item details</span>[% ELSE %]<span>Holdings</span>[% END %][% END %][% END %]
[% BLOCK holding_tab_title %][% IF SeparateHoldings %]<span>[% Branches.GetLoggedInBranchname | html %] holdings</span>[% ELSE %][% IF specific_item %]<span>Item details</span>[% ELSE %]<span>Holdings</span>[% END %][% END %][% END %]
<a href="#holdings">[% PROCESS holding_tab_title %] [% UNLESS too_many_items OR specific_item %][% ' ( ' _ (itemloop.size || 0) _ ' )' | html %][% END %]</a>
</li>
[% IF (SeparateHoldings) %]