Bug 25765: Replace LoginBranchname and LoginBranchcode with use of Branches template...
authorFridolin Somers <fridolin.somers@biblibre.com>
Tue, 16 Jun 2020 12:01:39 +0000 (14:01 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 23 Jul 2020 09:17:27 +0000 (11:17 +0200)
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>

15 files changed:
C4/Auth.pm
circ/set-library.pl
koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchoverdues.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt
koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt
koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt
koha-tmpl/opac-tmpl/bootstrap/en/includes/bodytag.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt

index 6889c25..449cfec 100644 (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"),
index 375a7f7..35b013c 100755 (executable)
@@ -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 {
index 868b22a..ef6cf61 100644 (file)
                         <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 %]
                     <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>
index c9cbea5..bebe5a1 100644 (file)
                     </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>
index 83dc7e3..b64911f 100644 (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">
index efbf34f..3315883 100644 (file)
 <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>
index 37744f6..2fe5e87 100644 (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">
index a46d4e7..012033c 100644 (file)
@@ -1,5 +1,6 @@
 [% USE raw %]
 [% USE Asset %]
+[% USE Branches %]
 [% SET footerjs = 1 %]
 <!DOCTYPE html>
 [% IF (AllowOfflineCirculation) %]
 
         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();
index 325b17e..14784e7 100644 (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 %]
index 24b3de3..4be8437 100644 (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;">
index 08c5e5d..86e8fa2 100644 (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' ) %]
index 459f7d8..e786485 100644 (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;">
index 2df180a..87ab308 100644 (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>
index ab56ed5..8730eb5 100644 (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 %]
index 99eefc3..9e89dea 100644 (file)
                         [% 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) %]