Skip to content

Commit

Permalink
Item12158: Link to disabled plugins
Browse files Browse the repository at this point in the history
And also add a reason that the plugin was disabled.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@15607 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Oct 17, 2012
1 parent 222b872 commit 2ac273f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 23 additions & 1 deletion core/lib/Foswiki/Plugin.pm
Expand Up @@ -105,6 +105,7 @@ sub finish {
undef $this->{module};
undef $this->{errors};
undef $this->{disabled};
undef $this->{reason};
undef $this->{no_topic};
undef $this->{description};
undef $this->{session};
Expand All @@ -124,6 +125,9 @@ sub load {
"$p could not be loaded. Errors were:\n$@\n----"
);
$this->{disabled} = 1;
$this->{reason} =
$this->{session}->i18n->maketext(
'Error encountered loading the plugin. See errors below.');
return;
}
else {
Expand All @@ -136,6 +140,10 @@ sub load {
"$this->{name} could not be loaded. No \$Foswiki::cfg{Plugins}{$this->{name}}{Module} defined - re-run configure\n---"
);
$this->{disabled} = 1;
$this->{reason} =
$this->{session}->i18n->maketext(
'Plugin module was not defined. Check configuration. See errors below.'
);
return;
}

Expand Down Expand Up @@ -169,6 +177,9 @@ sub load {
if ( !defined(&$sub) ) {
push( @{ $this->{errors} }, $sub . ' is not defined' );
$this->{disabled} = 1;
$this->{reason} =
$this->{session}
->i18n->maketext('initPlugin was not defined. See errors below.');
return;
}

Expand All @@ -180,6 +191,9 @@ sub load {
if ($error) {
push( @{ $this->{errors} }, $sub . ' failed: ' . $error );
$this->{disabled} = 1;
$this->{reason} =
$this->{session}
->i18n->maketext('earlyInitPlugin failed. See errors below.');
return;
}
}
Expand Down Expand Up @@ -257,6 +271,9 @@ MESSAGE
}
push( @{ $this->{errors} }, $exception );
$this->{disabled} = 1;
$this->{reason} =
$this->{session}->i18n->maketext(
'Plugin module did not return true. See errors below.');
return;
}

Expand Down Expand Up @@ -319,7 +336,12 @@ sub getDescription {
$this->{description} = $prefs->getPreference($pref) || '';
}
if ( $this->{disabled} ) {
return ' !' . $this->{name} . ': (disabled)';
my $reason = '';
if ( $this->{reason} ) {
$reason =
CGI::span( { class => 'foswikiAlert' }, ' ' . $this->{reason} );
}
return ' ' . $this->{name} . ': (disabled)' . $reason;
}

my $release = $this->getRelease();
Expand Down
3 changes: 3 additions & 0 deletions core/lib/Foswiki/Plugins.pm
Expand Up @@ -258,6 +258,9 @@ sub enable {
foreach my $plugin ( @{ $this->{plugins} } ) {
if ( $disabled{ $plugin->{name} } ) {
$plugin->{disabled} = 1;
$plugin->{reason} =
$this->{session}
->i18n->maketext('See the DISABLEDPLUGINS preference setting.');
push(
@{ $plugin->{errors} },
$plugin->{name} . ' has been disabled'
Expand Down

0 comments on commit 2ac273f

Please sign in to comment.