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)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 29 Nov 2018 10:11:25 +0000 (11:11 +0100)
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>
(cherry picked from commit 741f17e916a3f64d71b55fd87065136307e3bae7)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 2c7724f3bf10949454d4fe09702c0366ae41ad8d)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.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 5dea78e..0e8405e 100755 (executable)
@@ -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 });
index 5833978..a32f51d 100644 (file)
@@ -138,6 +138,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 %]"><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 b2d43d2..09c2d01 100644 (file)
@@ -41,6 +41,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>
@@ -59,6 +60,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 %]</i></div>
                             [% END %]