From e99b286065972d5e186e1c474b939c90676649f6 Mon Sep 17 00:00:00 2001
From: David Cook <dcook@prosentient.com.au>
Date: Thu, 24 Dec 2020 00:07:04 +0000
Subject: [PATCH] Bug 27031: Use Koha.Preference() more often in header.inc and
 js_includes.inc

This patch uses the Koha.Preference() macro more often in key includes.
(In the longer term, it will help reduce dependency in problematic C4::Auth code.)

Test plan:
0. Apply patch
1. Go to http://localhost:8081/cgi-bin/koha/mainpage.pl
2. Note "Cart" link in nav bar
3. Click "Cart" and note "Your cart is currently empty" text
4. Click "More" and note "Course Reserves" in dropdown menu
5. Go to http://localhost:8081/cgi-bin/koha/catalogue/search.pl?q=test
6. Click "Select all" above search results
7. Click "Add to cart"
8. Note "Cart" now has 3 displaying next to it
9. Click "Cart"
10. Note there are three titles in the cart
11. Click "Empty and close" and click "OK" to confirm
12. Note "Cart (0)" now appears in the top nav
13. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=IntranetNav
14. Save the following content in the system preference: <li><a href="/index.html">New Home</a></li>
15. Refresh the page
16. Note "New Home" appears in the top nav between "Cart" and "More"

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
 koha-tmpl/intranet-tmpl/prog/en/includes/header.inc      | 8 ++++----
 koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
index 1b453b874f..12deaa80ee 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
@@ -23,12 +23,12 @@
                     <li><a href="/cgi-bin/koha/catalogue/itemsearch.pl">Item search</a></li>[% END %]
                 </ul>
             </li>
-            [% IF ( intranetbookbag ) %]
+            [% IF ( Koha.Preference('intranetbookbag') ) %]
                 <li>
                     <a href="#" id="cartmenulink"><i class="fa fa-shopping-cart"></i>Cart<span id="basketcount"></span></a>
                 </li>
             [% END %]
-            [% IntranetNav | $raw %]
+            [% Koha.Preference('IntranetNav') | $raw %]
             <li class="dropdown">
                 <a href="/cgi-bin/koha/mainpage.pl" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
                 <ul class="dropdown-menu dropdown-menu-right">
@@ -46,7 +46,7 @@
                     [% IF ( CAN_user_serials ) %]
                         <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
                     [% END %]
-                    [% IF ( UseCourseReserves ) %]
+                    [% IF ( Koha.Preference('UseCourseReserves') ) %]
                         <li><a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a></li>
                     [% END %]
                     [% IF ( CAN_user_reports ) %]
@@ -205,6 +205,6 @@
         </ul>
 
     [% IF Koha.Preference('showLastPatron') %][% INCLUDE 'last-borrower.inc' %][% END %]
-    [% IF ( intranetbookbag ) %]<div id="cartDetails">Your cart is empty.</div>[% END %]
+    [% IF ( Koha.Preference('intranetbookbag') ) %]<div id="cartDetails">Your cart is empty.</div>[% END %]
 
 </nav>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
index b354113549..b832eec518 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
@@ -2,6 +2,7 @@
 [% USE Asset %]
 [% USE AudioAlerts %]
 [% USE To %]
+[% USE Koha %]
 [%# Prevent XFS attacks -%]
 [% UNLESS popup %]
     <script>
@@ -36,7 +37,7 @@
 [% END %]
 
 <!-- js_includes.inc -->
-[% IF ( virtualshelves || intranetbookbag ) %]
+[% IF ( Koha.Preference('virtualshelves') || Koha.Preference('intranetbookbag') ) %]
     [% Asset.js("js/basket.js") | $raw %]
 [% END %]
 
-- 
2.11.0