Bug 20415: add Koha.ArePluginsEnabled Template Toolkit method
authorFridolin Somers <fridolin.somers@biblibre.com>
Thu, 19 Mar 2020 14:01:13 +0000 (17:01 +0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 26 Mar 2020 11:41:54 +0000 (11:41 +0000)
In order to remove UseKohaPlugins syspref, adds to Koha Template Toolkit
plugin a method ArePluginsEnabled().

Test plan:
1) Set syspref UseKohaPlugins enabled
2) Set config enable_plugins=1
3) Check you see "Tool plugins" in "Tools" home page and menu
4) Check you see "Manage plugins" in "Koha administration" home page
5) Check you see "Report plugins" in "Reports" home page and menu
6) Set config enable_plugins=0
7) Check you don't see in 3) 4) 5)
8) Run prove t/Koha_Template_Plugin_Koha.t

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Template/Plugin/Koha.pm
koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-disabled.tt
koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt
t/Koha_Template_Plugin_Koha.t

index 0532a04..87b6f5f 100644 (file)
@@ -58,4 +58,8 @@ sub Version {
     };
 }
 
+sub ArePluginsEnabled {
+    return C4::Context->config('enable_plugins');
+}
+
 1;
index e79f2db..d63b3e9 100644 (file)
@@ -1,3 +1,5 @@
+[% USE Koha %]
+
 <div id="navmenu">
     <div id="navmenulist">
 
@@ -26,7 +28,7 @@
                 <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>
             </ul>
 
-        [% IF UseKohaPlugins %]
+        [% IF Koha.ArePluginsEnabled() %]
             <h5>Report plugins</h5>
             <ul>
                 <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=report">Report plugins</a></li>
index 877e68f..3df0409 100644 (file)
 </ul>
 [% END %]
 [% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_news
-  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( UseKohaPlugins && CAN_user_plugins_tool )
+  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool )
   || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
 <h5>Additional tools</h5>
 <ul>
     [% IF ( CAN_user_tools_edit_quotes ) %]
        <li><a href="/cgi-bin/koha/tools/quotes.pl">Quote editor</a></li>
     [% END %]
-    [% IF ( UseKohaPlugins && CAN_user_plugins_tool ) %]
+    [% IF ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) %]
         <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></li>
     [% END %]
     [% IF ( CAN_user_tools_upload_general_files ) %]
index 3b2a3fe..b17d140 100644 (file)
@@ -19,7 +19,7 @@
             <div class="col-sm-6 col-sm-offset-3 col-md-6 col-md-offset-3">
                 <h1>Plugins disabled!</h1>
 
-                <p>To enable Koha plugins, the system preference UseKohaPlugins must be enabled, and the flag enable_plugins must be set in the Koha configuration file</p>
+                <p>To enable Koha plugins, the flag enable_plugins must be set in the Koha configuration file</p>
             </div>
         </div>
 
index e4901bb..e7edc4e 100644 (file)
@@ -55,7 +55,7 @@
             <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>
       </ul>
 
-        [% IF UseKohaPlugins %]
+        [% IF Koha.ArePluginsEnabled() %]
             <h2>Report plugins</h2>
             <ul>
                 <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=report">Report plugins</a></li>
index 7b1bf98..b4e7816 100644 (file)
@@ -84,7 +84,7 @@
 
 <div class="col-sm-4 col-sm-push-4">
 [% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_news
-  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( UseKohaPlugins && CAN_user_plugins_tool )
+  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool )
   || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
 <h3>Additional tools</h3>
 [% END %]
     <dd>Quote editor for Quote-of-the-day feature in OPAC</dd>
     [% END %]
 
-    [% IF ( UseKohaPlugins && CAN_user_plugins_tool ) %]
+    [% IF ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) %]
     <dt><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">Tool plugins</a></dt>
     <dd>Use tool plugins</dd>
     [% END %]
index e0e5ed2..5cba73b 100644 (file)
@@ -17,8 +17,9 @@
 
 use Modern::Perl;
 
-use Test::More tests => 3;
+use Test::More tests => 4;
 use Test::MockModule;
+use t::lib::Mocks;
 
 use String::Random;
 
@@ -76,3 +77,14 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub {
 
 };
 
+subtest "Koha::Template::Plugin::Koha::ArePluginsEnabled tests" => sub {
+
+    plan tests => 2;
+
+    t::lib::Mocks::mock_config( 'enable_plugins', 1 );
+    is(Koha::Template::Plugin::Koha::ArePluginsEnabled(), 1, "Correct ArePluginsEnabled is yes");
+
+    t::lib::Mocks::mock_config( 'enable_plugins', 0 );
+    is(Koha::Template::Plugin::Koha::ArePluginsEnabled(), 0, "Correct ArePluginsEnabled is no");
+
+};