Bug 20383: Hide link to plugin management if plugins are not enabled
authorOwen Leonard <oleonard@myacpl.org>
Tue, 13 Mar 2018 10:15:31 +0000 (10:15 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 24 Apr 2018 13:13:21 +0000 (15:13 +0200)
This patch adds a check in admin-home.pl to see whether plugins are
enabled. If plugins are disabled, the link to plugins management is
hidden even if the user has plugin management permission.

To test, view the administration home page with plugins enabled and
disabled via the enable_plugins flag in the Koha configuration file.
Also test using users with different plugins permissions:

- Plugins enabled
  - CAN_user_plugins = 1
    -> Plugins link appears
  - CAN_user_plugins = 0
    -> Plugins link hidden

- Plugins disabled
  - CAN_user_plugins = 1,
  - CAN_user_plugins = 0
    -> Plugins link hidden

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 8450d2020bdfd524ebd20f0de8d278497fce0759)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

admin/admin-home.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt

index 08c6ed1..156df0c 100755 (executable)
@@ -21,8 +21,12 @@ use warnings;
 use CGI qw ( -utf8 );
 use C4::Auth;
 use C4::Output;
+use Koha::Plugins;
 
 my $query = new CGI;
+
+my $plugins_enabled = C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins");
+
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
         template_name   => "admin/admin-home.tt",
@@ -34,4 +38,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
+$template->param( plugins_enabled => $plugins_enabled, );
+
 output_html_with_http_headers $query, $cookie, $template->output;
index 0d43e6f..e6108e7 100644 (file)
@@ -56,7 +56,7 @@
                     <dt><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></dt>
                     <dd>Define cities and towns that your patrons live in.</dd>
                 </dl>
-                [% IF CAN_user_plugins %]
+                [% IF CAN_user_plugins && plugins_enabled %]
                     <h3>Plugins</h3>
                     <dl>
                         <dt><a href="/cgi-bin/koha/plugins/plugins-home.pl">Manage plugins</a></dt>