Skip to content

Commit

Permalink
Item13560: Add the ability to enable plugins
Browse files Browse the repository at this point in the history
When importing new plugins, it is handy to have the option to enable
discovered plugins that are missing from the configuration.

If the ENABLE argument is omitted, the {Enabled} setting will be left
undefined.
  • Loading branch information
gac410 committed Aug 27, 2015
1 parent c7240f3 commit 2804659
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
21 changes: 21 additions & 0 deletions core/lib/Foswiki/Configure/Wizards/Plugins.pm
Expand Up @@ -13,6 +13,7 @@ use strict;
use warnings;

use Assert;
use Foswiki;

use Foswiki::Configure::Load ();

Expand All @@ -39,6 +40,18 @@ sub check_current_value {
sub import {
my ( $this, $reporter, $spec ) = @_;

my $enable;

my $args = $this->param('args');
while ( my ( $opt, $val ) = each %$args ) {
if ( $opt eq 'ENABLE' ) {
$enable = Foswiki::isTrue($val);
next;
}
$reporter->ERROR("Unknown parameter ($opt)");
return '';
}

my $changes = 0; # Set if repair applicable.

# Inspect @INC to find plugins
Expand Down Expand Up @@ -74,6 +87,12 @@ sub import {
_setModule( $spec, $reporter, $pluginName,
"Foswiki::Plugins::$pluginName" );
}
if ( !defined $Foswiki::cfg{Plugins}{$pluginName}{Enabled}
&& defined $enable )
{
$changes++;
_setEnable( $spec, $reporter, $pluginName, $enable );
}

# only add the first instance of any plugin, as only
# the first can get loaded from @INC.
Expand Down Expand Up @@ -116,6 +135,8 @@ sub import {
);
$changes++;
_setModule( $spec, $reporter, $pluginName, $pluginModule );
_setEnable( $spec, $reporter, $pluginName, $enable )
if ( defined $enable );
}

foreach my $ext ( Foswiki::Configure::Load::specChanged() ) {
Expand Down
23 changes: 16 additions & 7 deletions core/tools/configure
Expand Up @@ -614,7 +614,7 @@ The following wizards are shipped with the Foswiki distribution:
Implements method B<autoconfigure>.
Probes the email servers to determine the protocols and methods implemented by the server and set the required configuration.
Use with the B<-save> option to save changes discovered by AutoConfigure.
Use with the B<-save> option to save changes discovered by AutoConfigure.
* {WebMasterEmail} must always be set.
Expand Down Expand Up @@ -673,15 +673,24 @@ Examples:
Implements method B<import>. (This is the default)
Examines the Plugins and Extensions configuration. Detects if a save is required to import new or changed .spec files.
Sets any missing {Module} definitions.
Sets any missing {Module} definitions. Named arguments are used to pass parameters to the installer.
Example: Import new settings after installation of an extension using unzip
=over 4
=item -args B<ENABLE>=0/1
$ configure -save -wizard Plugins
Set to 1 to enable the extension. Note that if the C<{Plugins}{someplugin}{Enabled}> is already defined, it will not be changed.
Unless this argument is provided to specify a default, the C<{Enabled}> setting will be left undefined.
=back
Example: Import new settings after installation of an extension using unzip. Enable any discovered plugins.
$ configure -save -wizard Plugins -args ENABLE=1
=item B<SendTestEmail>
Implements method B<send>.
Implements method B<send>.
Sends a test email to the {WebMasterEmail} address. Requires email be configured. Used to test the email configuration before enabling email.
Expand All @@ -691,7 +700,7 @@ Example:
=item B<SMIMECertificate>
Needs documentation.
Needs documentation.
=item B<SSLCertificates>
Expand All @@ -701,5 +710,5 @@ Needs documentation.
Not currently operational
=back
=back

0 comments on commit 2804659

Please sign in to comment.