From b7d7111821c16ce9a5c40e175a10dcf32abeab27 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 22 Feb 2016 14:25:18 +0000 Subject: [PATCH] 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! --- Koha/Plugins.pm | 4 +++- Koha/Plugins/Handler.pm | 4 +++- plugins/plugins-upload.pl | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 9e2d4eb..d07aa4a 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -26,7 +26,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 ); } =head1 NAME diff --git a/Koha/Plugins/Handler.pm b/Koha/Plugins/Handler.pm index 187560d..a24e562 100644 --- a/Koha/Plugins/Handler.pm +++ b/Koha/Plugins/Handler.pm @@ -26,7 +26,9 @@ use Module::Load::Conditional qw(can_load); use C4::Context; BEGIN { - push @INC, C4::Context->config("pluginsdir"); + my $pluginsdir = C4::Context->config("pluginsdir"); + my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; + push( @INC, @pluginsdir ); } =head1 NAME diff --git a/plugins/plugins-upload.pl b/plugins/plugins-upload.pl index 853b2ac..1e315f9 100755 --- a/plugins/plugins-upload.pl +++ b/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"; -- 2.1.4