[Rt-commit] r9696 - in rt/branches/3.7-EXPERIMENTAL: . etc lib
lib/RT/Interface/Web
jesse at bestpractical.com
jesse at bestpractical.com
Sun Nov 18 21:06:30 EST 2007
Author: jesse
Date: Sun Nov 18 21:06:30 2007
New Revision: 9696
Added:
rt/branches/3.7-EXPERIMENTAL/lib/RT/Plugin.pm
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/Makefile.in
rt/branches/3.7-EXPERIMENTAL/etc/RT_SiteConfig.pm
rt/branches/3.7-EXPERIMENTAL/lib/RT.pm.in
rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web/Handler.pm
Log:
r72125 at pinglin: jesse | 2007-11-18 19:01:46 -0600
* Initial support for being able to enable and disable RT Plugins.
Modified: rt/branches/3.7-EXPERIMENTAL/Makefile.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/Makefile.in (original)
+++ rt/branches/3.7-EXPERIMENTAL/Makefile.in Sun Nov 18 21:06:30 2007
@@ -102,6 +102,7 @@
RT_VAR_PATH = @RT_VAR_PATH@
RT_DOC_PATH = @RT_DOC_PATH@
RT_LOCAL_PATH = @RT_LOCAL_PATH@
+RT_LOCAL_PLUGIN_PATH = @RT_LOCAL_PATH@/plugins
LOCAL_ETC_PATH = @LOCAL_ETC_PATH@
LOCAL_LIB_PATH = @LOCAL_LIB_PATH@
LOCAL_LEXICON_PATH = @LOCAL_LEXICON_PATH@
@@ -338,6 +339,7 @@
mkdir -p $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
mkdir -p $(DESTDIR)/$(LOCAL_ETC_PATH)
mkdir -p $(DESTDIR)/$(LOCAL_LIB_PATH)
+ mkdir -p $(DESTDIR)/$(LOCAL_PLUGIN_PATH)
mkdir -p $(DESTDIR)/$(LOCAL_LEXICON_PATH)
# }}}
Modified: rt/branches/3.7-EXPERIMENTAL/etc/RT_SiteConfig.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/etc/RT_SiteConfig.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/etc/RT_SiteConfig.pm Sun Nov 18 21:06:30 2007
@@ -15,4 +15,5 @@
# perl -c /path/to/your/etc/RT_SiteConfig.pm
Set( $rtname, 'example.com');
+Set(@Plugins,(qw(Extension-QuickDelete)));
1;
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT.pm.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT.pm.in (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT.pm.in Sun Nov 18 21:06:30 2007
@@ -64,7 +64,10 @@
our $VarPath = '@RT_VAR_PATH@';
our $LocalPath = '@RT_LOCAL_PATH@';
our $LocalEtcPath = '@LOCAL_ETC_PATH@';
+our $LocalLibPath = '@LOCAL_LIB_PATH@';
our $LocalLexiconPath = '@LOCAL_LEXICON_PATH@';
+our $LocalPluginPath = $LocalPath."/plugins";
+
# $MasonComponentRoot is where your rt instance keeps its mason html files
@@ -141,6 +144,7 @@
InitSystemObjects();
InitClasses();
InitLogging();
+ InitPlugins();
}
=head2 ConnectToDatabase
@@ -499,10 +503,66 @@
sub Nobody { return $Nobody }
+=head2 Plugins
+
+Returns a listref of all Plugins currently configured for this RT instance.
+You can define plugins by adding them to the @Plugins list in your RT_SiteConfig
+
+=cut
+
+our @PLUGINS = ();
+sub Plugins {
+ my $self = shift;
+ @PLUGINS = $self->InitPlugins unless (@PLUGINS);
+ return \@PLUGINS;
+}
+
+=head2 InitPlugins
+
+Initialze all Plugins found in the RT configuration file, setting up their lib and HTML::Mason component roots.
+
+=cut
+
+sub InitPlugins {
+ my $self = shift;
+ my @plugins;
+ use RT::Plugin;
+ foreach my $plugin (RT->Config->Get('Plugins')) {
+ next unless $plugin;
+ my $plugindir = $plugin;
+ $plugindir =~ s/::/-/g;
+ unless (-d $RT::LocalPluginPath."/$plugindir") {
+ $RT::Logger->crit("Plugin $plugindir not found in $RT::LocalPluginPath");
+ }
+
+ # Splice the plugin's lib dir into @INC;
+ my @tmp_inc;
+
+
+ for (@INC){
+ if
+ ( $_ eq $RT::LocalLibPath) {
+ push @tmp_inc, $_, $RT::LocalPluginPath . "/$plugindir";
+ } else {
+ push @tmp_inc, $_;
+ }
+ }
+
+ @INC = @tmp_inc;
+ $plugin->require;
+ die $UNIVERSAL::require::ERROR if ($UNIVERSAL::require::ERROR);
+ push @plugins, RT::Plugin->new(name =>$plugin);
+ }
+ return @plugins;
+
+}
+
+
+
=head1 BUGS
-Please report them to rt-bugs at fsck.com, if you know what's broken and have at least
-some idea of what needs to be fixed.
+Please report them to rt-bugs at bestpractical.com, if you know what's
+broken and have at least some idea of what needs to be fixed.
If you're not sure what's going on, report them rt-devel at lists.bestpractical.com.
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web/Handler.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web/Handler.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web/Handler.pm Sun Nov 18 21:06:30 2007
@@ -64,6 +64,7 @@
sub DefaultHandlerArgs { (
comp_root => [
[ local => $RT::MasonLocalComponentRoot ],
+ (map {[ "plugin-".$_->Name => $_->ComponentRoot ]} @{RT->Plugins}),
[ standard => $RT::MasonComponentRoot ]
],
default_escape_flags => 'h',
Added: rt/branches/3.7-EXPERIMENTAL/lib/RT/Plugin.pm
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Plugin.pm Sun Nov 18 21:06:30 2007
@@ -0,0 +1,71 @@
+use warnings;
+use strict;
+
+package RT::Plugin;
+use File::ShareDir;
+
+=head1 NAME
+
+RT::Plugin
+
+=head1 METHODS
+
+=head2 new
+
+Instantiate a new RT::Plugin object. Takes a paramhash. currently the only key it cares about is 'name', the name of this plugin.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $args ={@_};
+ my $self = bless $args, $class;
+ return $self;
+}
+
+
+=head2 Name
+
+Returns a human-readable name for this plugin.
+
+=cut
+
+sub Name {
+ my $self = shift;
+ return $self->{name};
+}
+
+sub _BasePath {
+ my $self = shift;
+ my $base = $self->{'name'};
+ $base =~ s/::/-/g;
+
+ return $RT::LocalPluginPath."/".$base;
+
+}
+
+=head2 ComponentRoot
+
+Returns the directory this plugin has installed its HTML::Mason templates into
+
+=cut
+
+sub ComponentRoot {
+ my $self = shift;
+
+ return $self->_BasePath."/html";
+}
+
+=head2 PoDir
+
+Returns the directory this plugin has installed its message catalogs into.
+
+=cut
+
+sub PoDir {
+ my $self = shift;
+ return $self->_BasePath."/po";
+
+}
+
+1;
More information about the Rt-commit
mailing list