Bug 21096: Do not display loggedinusername in template
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 25 Jul 2018 15:25:58 +0000 (12:25 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 30 Aug 2018 13:40:31 +0000 (13:40 +0000)
This patch is a little fix for a much bigger hidden issues.

The original issue:
1. Set the firstname and surname values of a paontr to utf-8 characters
("wide characters"), for instance 月月
2. Use this patron to login at the staff interface
=> In the header the logged in patron's info (concat of firstname and
surname) are displayed correctly
3. Hit whatever link
=> In the header the info are now displayed incorrectly
("ææ")

What happens?
After that the user loggin, loggedinusername is set with the value from
the DB (borrowers.userid)
On next hits it is picked from the session (which contains the decoded
utf8 value, see first lines of C4::Context->set_userenv)
From C4::Auth::checkauth:
834             $s_userid = $session->param('id') // ''

The quick fix is to use the logged_in_user variable in the template, but
it seems that issues may occurred if external authentication is used
(ldap, shib, cas). Could someone test this?

Test plan:
Make sure the original issue is fixed

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/Auth.pm
koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt

index f0f3eb8..8fd9728 100644 (file)
@@ -261,7 +261,7 @@ sub get_template_and_user {
         }
 
         # user info
-        $template->param( loggedinusername   => $user ); # FIXME Should be replaced with something like patron-title.inc
+        $template->param( loggedinusername   => $user ); # OBSOLETE - Do not reuse this in template, use logged_in_user.userid instead
         $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber
         $template->param( logged_in_user     => $patron );
         $template->param( sessionID          => $sessionID );
index 8b47028..7e3c178 100644 (file)
@@ -59,7 +59,7 @@
                         <i class="fa fa-user"></i>
                     </span>
                     <span id="logged-in-info-full">
-                        <span class="loggedinusername">[% loggedinusername | html %]</span>
+                        <span class="loggedinusername">[% logged_in_user.userid | html %]</span>
                         <span class="separator">|</span>
                         [% IF ( AutoLocation ) %]
                             <brand>
@@ -82,7 +82,7 @@
 
                     <li class="loggedin-menu-label">
                         Logged in as:<br />
-                        <span class="loggedinusername">[% loggedinusername | html %]</span>
+                        <span class="loggedinusername">[% logged_in_user.userid | html %]</span>
                     </li>
                     <li class="loggedin-menu-label">
                         [% IF ( AutoLocation ) %]
index a2ac542..7f302ac 100644 (file)
@@ -88,7 +88,7 @@
 
 [% UNLESS no_orders_to_display %]
 <div id="acqui_receive_summary">
-<p><strong>Invoice number:</strong> [% invoice | html %] <strong>Received by:</strong> [% loggedinusername | html %] <strong>On:</strong> [% datereceived | $KohaDates %]</p>
+<p><strong>Invoice number:</strong> [% invoice | html %] <strong>Received by:</strong> [% logged_in_user.userid | html %]<strong>On:</strong> [% datereceived | $KohaDates %]</p>
 </div>
 [% UNLESS (invoiceclosedate) %]
   <div id="acqui_receive_search">
index be7c326..3bd92c2 100644 (file)
         }
 
         function synchronize() {
-            kohadb.saveSetting("userid", "[% loggedinusername | html %]");
+            kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]");
             kohadb.saveSetting("branchcode", "[% LoginBranchcode | html %]");
             showSyncInfo();
             [% UNLESS (AllowOfflineCirculation) %]
index cfb1e7c..4bfa1fa 100644 (file)
@@ -62,7 +62,7 @@
                     </li>
 
                     <li>
-                        <span class="label">Owner: </span>[% loggedinusername | html %]
+                        <span class="label">Owner: </span>[% logged_in_user.userid | html %]
                     </li>
                 </ol>
 
index 846cbc3..7f1586c 100644 (file)
@@ -31,7 +31,7 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
                 [% ELSE %]
                         <input type="hidden" name="op" value="addsubscription" />
                 [% END %]
-                <input type="hidden" name="user" value="[% loggedinusername | html %]" />
+                <input type="hidden" name="user" value="[% logged_in_user.userid | html %]" />
                 <input type="hidden" name="irreg_check" value="0" />
 
                 <div id="page_1">
index d213c7e..b89db76 100644 (file)
             <li>
                 <span class="label">Owner: </span>
                 [% IF op == 'add_form' %]
-                    <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% loggedinusername | html %]</li>
+                    <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
                 [% ELSE %]
                     [% IF owner %]
                         <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber | html %]" />[% owner.firstname _ ' ' _ owner.surname | html %]
                     [% ELSE %]
-                        <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% loggedinusername | html %]
+                        <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
                     [% END %]
                 [% END %]
             </li>