From c3d7cc119e178b33215e6dbf1561cdcda3fbc44c Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Wed, 20 Jun 2018 12:47:10 +0100 Subject: [PATCH] Bug 20968: Add hooks into cat-toolbar.inc to display buttons This commit adds hooks into cat-toolbar.inc to allow the display of arbitrary buttons as supplied by plugins within the intranet_catalog_biblio_enhancements class that provide the method get_toolbar_button To test: 1) Download the plugin from https://github.com/PTFS-Europe/cla-permissions-check-plugin 2) Follow the installation instructions from: https://github.com/PTFS-Europe/cla-permissions-check-plugin 3) TEST: Observe that the "CLA Check Permissions" button takes the user to the Check Permissions page and a modal displays containing the results of the query 4) Remove the API key from the plugin "Configuration" page 5) TEST: Ensure that the "CLA Check Permissions" button takes the user to the Check Permissions page and message displays informing the user that "Did not receive required request parameters" https://bugs.koha-community.org/show_bug.cgi?id=20968 Signed-off-by: Stephen Graham Signed-off-by: Kyle M Hall --- catalogue/detail.pl | 15 +++++++++++++++ .../prog/en/includes/cat-toolbar.inc | 4 ++++ .../prog/en/modules/plugins/plugins-home.tt | 3 +++ 3 files changed, 22 insertions(+) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index fe59fa12cc..2707a81d36 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -21,6 +21,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use HTML::Entities; use C4::Auth; +use C4::Context; use C4::Koha; use C4::Serials; #uses getsubscriptionfrom biblionumber use C4::Output; @@ -45,6 +46,7 @@ use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; use Koha::Virtualshelves; +use Koha::Plugins; my $query = CGI->new(); @@ -60,6 +62,19 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( } ); +# Determine if we should be offering any enhancement plugin buttons +if ( C4::Context->preference('UseKohaPlugins') && + C4::Context->config('enable_plugins') ) { + my @plugins = Koha::Plugins->new()->GetPlugins({ + method => 'intranet_catalog_biblio_enhancements' + }); + # Only pass plugins that can offer a toolbar button + @plugins = grep { $_->get_toolbar_button } @plugins; + $template->param( + plugins => \@plugins + ); +} + my $biblionumber = $query->param('biblionumber'); $biblionumber = HTML::Entities::encode($biblionumber); my $record = GetMarcBiblio({ biblionumber => $biblionumber }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index d5191e30fd..935f94feff 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -139,6 +139,10 @@ CAN_user_serials_create_subscription ) %] [% END %] +[% FOREACH p IN plugins %] + [% p.get_toolbar_button %] +[% END %] + 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 305f3eb473..73614404bd 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 @@ -34,6 +34,7 @@
  • View tool plugins
  • View MARC conversion plugins
  • View online payment plugins
  • +
  • View intranet catalog biblio enhancement plugins
  • @@ -52,6 +53,8 @@
    No plugins that can convert files to MARC records are installed
    [% ELSIF method == 'opac_online_payment' %]
    No plugins that can process online payments via the public catalog are installed
    + [% ELSIF method == 'intranet_catalog_biblio_enhancements' %] +
    No plugins that can enhance the intranet catalog biblio records are installed
    [% ELSE %]
    Unknown plugin type [% method | html %]
    [% END %] -- 2.17.1 (Apple Git-112)