From a1e930f7586e7d3f0a7f6e282ee5a32c2e297f04 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 26 Mar 2020 13:49:57 +0000 Subject: [PATCH] Bug 24201: (follow-up) Use GetLoggedInDeskName This patch updates the templates to use the new TT plugin instead of adding additional variables to the already crouded get_template_and_user. Signed-off-by: Andrew Fuerste-Henry --- C4/Auth.pm | 3 --- Koha/Template/Plugin/Desks.pm | 16 ++++++++++++++++ koha-tmpl/intranet-tmpl/prog/en/includes/header.inc | 10 +++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 35b794c3a5..e8af5389af 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -462,7 +462,6 @@ sub get_template_and_user { OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), LoginBranchcode => ( C4::Context->userenv ? C4::Context->userenv->{"branch"} : undef ), - LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : 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, @@ -491,7 +490,6 @@ sub get_template_and_user { IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), LibraryName => C4::Context->preference("LibraryName"), LoginBranchname => ( C4::Context->userenv ? C4::Context->userenv->{"branchname"} : undef ), - LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ), advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), @@ -560,7 +558,6 @@ sub get_template_and_user { LibraryName => "" . C4::Context->preference("LibraryName"), LibraryNameTitle => "" . $LibraryNameTitle, LoginBranchname => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "", - LoginDeskname => C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : "", OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), diff --git a/Koha/Template/Plugin/Desks.pm b/Koha/Template/Plugin/Desks.pm index 99fe2329e3..a3be8c365f 100644 --- a/Koha/Template/Plugin/Desks.pm +++ b/Koha/Template/Plugin/Desks.pm @@ -67,6 +67,22 @@ sub GetLoggedInDeskId { ''; } +=head3 GetLoggedInDeskName + +[% Desks.GetLoggedInDeskName %] + +Return the desk name that is attached to the session or empty string + +=cut + +sub GetLoggedInDeskName { + my ($self) = @_; + + return C4::Context->userenv ? + C4::Context->userenv->{'desk_name'} : + ''; +} + =head3 all [% Desks.all %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc index 2af835004c..37b16132c8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -89,10 +89,10 @@ [% IF (Desks.defined) %] | - [% IF ( LoginDeskname == '') %] + [% IF ( Desks.GetLoggedInDeskName == '' ) %] NO DESK SET [% ELSE %] - [% LoginDeskname | html %] + [% Desks.GetLoggedInDeskName | html %] [% Desks.GetLoggedInDeskId | html %] [% END %] @@ -119,10 +119,10 @@
  • Desk:
    - [% IF ( LoginDeskname == '' AND Desks.defined ) %] + [% IF ( Desks.GetLoggedInDeskName == '' AND Desks.defined ) %] NO DESK SET - [% ELSIF ( LoginDeskname != '' ) %] - [% LoginDeskname | html %] + [% ELSIF ( Desks.GetLoggedInDeskName != '' ) %] + [% Desks.GetLoggedInDeskName | html %] [% Desks.GetLoggedInDeskId | html %] [% END %]
  • -- 2.11.0