Bug 20968: Add hooks into cat-toolbar.inc to display buttons
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Wed, 20 Jun 2018 11:47:10 +0000 (12:47 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 2 Nov 2018 10:36:02 +0000 (10:36 +0000)
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 <s.graham4@herts.ac.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt

index fe59fa1..2707a81 100755 (executable)
@@ -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 });
index d179641..597c4f7 100644 (file)
@@ -139,6 +139,10 @@ CAN_user_serials_create_subscription ) %]
     <div class="btn-group"><a id="placehold" class="btn btn-default btn-sm" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber | html %]"><i class="fa fa-file-text-o"></i> Request article</a></div>
 [% END %]
 
+[% FOREACH p IN plugins %]
+       [% p.get_toolbar_button %]
+[% END %]
+
 </div>
 
     <!--Modal for Dublin Core-->
index a6c8a3d..547c329 100644 (file)
@@ -34,6 +34,7 @@
                                     <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">View tool plugins</a></li>
                                     <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=to_marc">View MARC conversion plugins</a></li>
                                     <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=opac_online_payment">View online payment plugins</a></li>
+                                    <li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=intranet_catalog_biblio_enhancements">View intranet catalog biblio enhancement plugins</a></li>
                                 </ul>
                             </div>
                         </div>
@@ -52,6 +53,8 @@
                                 <div class="dialog message">No plugins that can convert files to MARC records are installed</div>
                             [% ELSIF method == 'opac_online_payment' %]
                                 <div class="dialog message">No plugins that can process online payments via the public catalog are installed</div>
+                            [% ELSIF method == 'intranet_catalog_biblio_enhancements' %]
+                                <div class="dialog message">No plugins that can enhance the intranet catalog biblio records are installed</div>
                             [% ELSE %]
                                 <div class="dialog message">Unknown plugin type <i>[% method | html %]</i></div>
                             [% END %]