fix self-service fallout from RT 3.8, RT#6640
authorivan <ivan>
Thu, 21 Jan 2010 01:25:22 +0000 (01:25 +0000)
committerivan <ivan>
Thu, 21 Jan 2010 01:25:22 +0000 (01:25 +0000)
FS/FS/ClientAPI.pm
FS/FS/Mason.pm
FS/bin/freeside-selfservice-server

index 902f58b..1677fcc 100644 (file)
@@ -1,29 +1,34 @@
 package FS::ClientAPI;
 
 use strict;
-use vars qw(%handler $domain $DEBUG);
+use base 'Exporter';
+use vars qw( @EXPORT_OK %handler $domain $DEBUG );
+
+@EXPORT_OK = qw( load_clientapi_modules );
 
 $DEBUG = 0;
 
 %handler = ();
 
-#find modules
-foreach my $INC ( @INC ) {
-  my $glob = "$INC/FS/ClientAPI/*.pm";
-  warn "FS::ClientAPI: searching $glob" if $DEBUG;
-  foreach my $file ( glob($glob) ) {
-    $file =~ /\/(\w+)\.pm$/ or do {
-      warn "unrecognized ClientAPI file: $file";
-      next
-    };
-    my $mod = $1;
-    warn "using FS::ClientAPI::$mod" if $DEBUG;
-    eval "use FS::ClientAPI::$mod;";
-    die "error using FS::ClientAPI::$mod: $@" if $@;
+sub load_clientapi_modules {
+
+  #find modules
+  foreach my $INC ( @INC ) {
+    my $glob = "$INC/FS/ClientAPI/*.pm";
+    warn "FS::ClientAPI: searching $glob" if $DEBUG;
+    foreach my $file ( glob($glob) ) {
+      $file =~ /\/(\w+)\.pm$/ or do {
+        warn "unrecognized ClientAPI file: $file";
+        next
+      };
+      my $mod = $1;
+      warn "using FS::ClientAPI::$mod" if $DEBUG;
+      eval "use FS::ClientAPI::$mod;";
+      die "error using FS::ClientAPI::$mod: $@" if $@;
+    }
   }
-}
 
-#---
+}
 
 sub dispatch {
   my ( $self, $name ) = ( shift, shift );
index c5b68f5..7e9827c 100644 (file)
@@ -388,12 +388,17 @@ if ( -e $addl_handler_use_file ) {
 
 =over 4
 
-=item mason_interps [ MODE ]
+=item mason_interps [ MODE [ OPTION => VALUE ... ] ]
 
 Returns a list consisting of two HTML::Mason::Interp objects, the first for
 Freeside pages, and the second for RT pages.
 
-#MODE can be 'apache' or 'standalone'.  If not specified, defaults to 'apache'.
+MODE can be 'apache' or 'standalone'.  If not specified, defaults to 'apache'.
+
+Options and values can be passed following mode.  Currently available options
+are:
+
+I<outbuf> should be set to a scalar reference in standalone mode.
 
 =cut
 
@@ -406,7 +411,7 @@ sub mason_interps {
   my $request_class = 'FS::Mason::Request';
 
   #not entirely sure it belongs here, but what the hey
-  if ( %%%RT_ENABLED%%% ) {
+  if ( %%%RT_ENABLED%%% && $mode ne 'standalone' ) {
     RT::LoadConfig();
   }
 
index f72d0ab..1c2086e 100644 (file)
@@ -13,7 +13,7 @@ use Storable 2.09 qw(nstore_fd fd_retrieve);
 use Net::SSH qw(sshopen2);
 use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
 use FS::UID qw(adminsuidsetup forksuidsetup);
-use FS::ClientAPI;
+use FS::ClientAPI qw( load_clientapi_modules );
 use FS::ClientAPI_SessionCache;
 use FS::Record qw( qsearch qsearchs );
 
@@ -52,6 +52,8 @@ drop_root();
 
 $ENV{HOME} = (getpwuid($>))[7]; #for ssh
 
+load_clientapi_modules;
+
 adminsuidsetup $user;
 
 #logfile("/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc); #MACHINE