From be91938409b3dc85803161a65f68d21b36fa6698 Mon Sep 17 00:00:00 2001 From: David Cook <dcook@prosentient.com.au> Date: Wed, 4 Jan 2023 01:21:34 +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. --- .../prog/en/modules/plugins/plugins-home.tt | 12 +++++++++--- .../prog/en/modules/tools/tools-home.tt | 9 ++++++++- 2 files changed, 17 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 fd55daf828..5b574c98df 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 @@ -136,6 +136,12 @@ </thead> [% FOREACH plugin IN plugins %] + [% + plugin_link = '/cgi-bin/koha/plugins/run.pl'; + IF ( plugin.can('use_mojolicious') ); + plugin_link = '/cgi-bin/koha/staff/plugins/run'; + END; + %] [% IF plugin.error %] <tr class="warn"> <td> @@ -187,19 +193,19 @@ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="pluginactions[% plugin.class | html %]"> [% 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 73508b2c64..bcd5de08ce 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 %] @@ -160,8 +161,14 @@ Use tool plugins <ul> [% FOREACH plugin IN tool_plugins %] + [% + plugin_link = '/cgi-bin/koha/plugins/run.pl'; + IF ( plugin.can('use_mojolicious') ); + plugin_link = '/cgi-bin/koha/staff/plugins/run'; + END; + %] <li class="plugin_link"> - <a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=tool"> + <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