From 8dc094e0e7373cc1a8e5a02dc4343c76fa940bb3 Mon Sep 17 00:00:00 2001 From: David Cook <dcook@prosentient.com.au> Date: Thu, 18 Aug 2022 04:07:36 +0000 Subject: [PATCH] Bug 31380: Add plugin hook for choosing Mojolicious or CGI script controller This change checks for a "use_mojolicious" method in the plugin in order to determine whether it should use a Mojolicious controller or a CGI script controller. Note that the check is for the existence of the method, so it is backwards compatible with all existing Koha Plugins. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> --- .../intranet-tmpl/prog/en/modules/plugins/plugins-home.tt | 7 ++++--- .../intranet-tmpl/prog/en/modules/tools/tools-home.tt | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt index c43c5fb2ee..ba877072fd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt @@ -177,21 +177,22 @@ Actions <b class="caret"></b> </a> <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="pluginactions[% plugin.class | html %]"> + [% plugin_link = '/cgi-bin/koha/plugins/run.pl'; IF ( plugin.can('use_mojolicious') ); plugin_link = '/cgi-bin/koha/staff/plugins/run'; END; %] [% IF ( CAN_user_plugins_report ) %] [% IF plugin.can('report') %] - <li><a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=report"><i class="fa fa-table fa-fw"></i> Run report</a></li> + <li><a href="[% plugin_link | $raw %]?class=[% plugin.class | uri %]&method=report"><i class="fa fa-table fa-fw"></i> Run report</a></li> [% END %] [% END %] [% IF ( CAN_user_plugins_tool ) %] [% IF plugin.can('tool') %] - <li><a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=tool"><i class="fa fa-wrench fa-fw"></i> Run tool</a></li> + <li><a href="[% plugin_link | $raw %]?class=[% plugin.class | uri %]&method=tool"><i class="fa fa-wrench fa-fw"></i> Run tool</a></li> [% END %] [% END %] [% IF ( CAN_user_plugins_configure ) %] [% IF plugin.can('configure') %] - <li><a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=configure"><i class="fa fa-cog fa-fw"></i> Configure</a></li> + <li><a href="[% plugin_link | $raw %]?class=[% plugin.class | uri %]&method=configure"><i class="fa fa-cog fa-fw"></i> Configure</a></li> [% END %] [% END %] [% IF ( CAN_user_plugins_manage ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 2ebca53c9e..2429a632a5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -1,3 +1,4 @@ +[% USE raw %] [% USE Koha %] [% USE Branches %] [% USE Registers %] @@ -143,7 +144,8 @@ <ul> [% FOREACH plugin IN tool_plugins %] <li class="plugin_link"> - <a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=tool"> + [% plugin_link = '/cgi-bin/koha/plugins/run.pl'; IF ( plugin.can('use_mojolicious') ); plugin_link = '/cgi-bin/koha/staff/plugins/run'; END; %] + <a href="[% plugin_link | $raw %]?class=[% plugin.class | uri %]&method=tool"> <span class="plugin_name">[% plugin.metadata.name | html %]</span> </a> </li> -- 2.30.2