Browse Source

Bug 15879: Allow multiple plugin directories to be defined in koha-conf.xml

It would be very useful to be able to define multiple plugin directories
in the Koha conf file. This would allow for ease of plugin development
so that each plugin installed can live in its own git repository. For
compatibility, the first plugindir instance defined should be the one
used for uploading plugins via the web interface.

Test Plan:
1) Apply this patch
2) Define a second pluginsdir line in your koha-conf.xml
3) Clone the kitchen sink plugin to this new path like this:
   git clone https://github.com/bywatersolutions/koha-plugin-kitchen-sink.git /path/to/new/plugins/dir
4) Restart memcached if you are running it
5) The Kitchen Sink plugin should now appear in your list of plugins!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
I rebased it against master and tested it on a kohadevbox

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
17.05.x
Kyle Hall 7 years ago
parent
commit
ea6a11ec82
  1. 4
      Koha/Plugins.pm
  2. 16
      Koha/Plugins/Handler.pm
  3. 1
      plugins/plugins-upload.pl

4
Koha/Plugins.pm

@ -27,7 +27,9 @@ use C4::Context;
use C4::Output;
BEGIN {
push @INC, C4::Context->config("pluginsdir");
my $pluginsdir = C4::Context->config("pluginsdir");
my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
push( @INC, @pluginsdir );
pop @INC if $INC[-1] eq '.';
}

16
Koha/Plugins/Handler.pm

@ -26,8 +26,10 @@ use Module::Load::Conditional qw(can_load);
use C4::Context;
BEGIN {
push @INC, C4::Context->config("pluginsdir");
pop @INC if $INC[-1] eq '.' ;
my $pluginsdir = C4::Context->config("pluginsdir");
my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
push( @INC, @pluginsdir );
pop @INC if $INC[-1] eq '.' ;
}
=head1 NAME
@ -83,8 +85,14 @@ sub delete {
return unless ( C4::Context->config("enable_plugins") || $args->{'enable_plugins'} );
my $plugin_class = $args->{'class'};
my $plugin_dir = C4::Context->config("pluginsdir");
my $plugin_path = "$plugin_dir/" . join( '/', split( '::', $args->{'class'} ) );
my $plugin_path = $plugin_class;
$plugin_path =~ s/::/\//g; # Take class name, transform :: to / to get path
$plugin_path =~ s/$/.pm/; # Add .pm to the end
require $plugin_path; # Require the plugin to have it's path listed in INC
$plugin_path =
$INC{$plugin_path}; # Get the full true path to the plugin from INC
$plugin_path =~ s/.pm//; # Remove the .pm from the end
Koha::Plugins::Handler->run({
class => $plugin_class,

1
plugins/plugins-upload.pl

@ -56,6 +56,7 @@ my %errors;
if ($plugins_enabled) {
if ( ( $op eq 'Upload' ) && $uploadfile ) {
my $plugins_dir = C4::Context->config("pluginsdir");
$plugins_dir = ref($plugins_dir) eq 'ARRAY' ? $plugins_dir->[0] : $plugins_dir;
my $dirname = File::Temp::tempdir( CLEANUP => 1 );
$debug and warn "dirname = $dirname";

Loading…
Cancel
Save