From f1eea26b988f141479fbb909517eec15d265bb9a 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 --- catalogue/detail.pl | 15 +++++++++++++++ koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc | 4 ++++ .../intranet-tmpl/prog/en/modules/plugins/plugins-home.tt | 3 +++ 3 files changed, 22 insertions(+) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 1c6b234651..a3c8090da5 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -22,6 +22,7 @@ use CGI qw ( -utf8 ); use HTML::Entities; use C4::Acquisition qw( GetHistory ); use C4::Auth; +use C4::Context; use C4::Koha; use C4::Serials; #uses getsubscriptionfrom biblionumber use C4::Output; @@ -46,6 +47,7 @@ use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; use Koha::Virtualshelves; +use Koha::Plugins; my $query = CGI->new(); @@ -61,6 +63,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 781b79714d..212d7e78cb 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 ) %]
Request article
[% 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 ee9c1a0d4c..0539864d13 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 @@ -33,6 +33,7 @@
  • View tool plugins
  • View MARC conversion plugins
  • View online payment plugins
  • +
  • View intranet catalog biblio enhancement plugins
  • @@ -51,6 +52,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 %]
    [% END %] -- 2.11.0