add addl_comp_root.pl and addl_handler_use.pl config files, RT#4743
authorivan <ivan>
Tue, 22 Sep 2009 03:09:28 +0000 (03:09 +0000)
committerivan <ivan>
Tue, 22 Sep 2009 03:09:28 +0000 (03:09 +0000)
Makefile
htetc/handler.pl

index e48e449..f39cfce 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -164,6 +164,7 @@ install-docs: docs
        cp htetc/handler.pl ${MASON_HANDLER}
          perl -p -i -e "\
            s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
+           s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
            s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
            s'%%%MASONDATA%%%'${MASONDATA}'g;\
          " ${MASON_HANDLER}
index 6721bec..6cf7895 100644 (file)
@@ -4,6 +4,7 @@ package HTML::Mason;
 
 use strict;
 use vars qw($r);
+use File::Slurp qw( slurp );
 use HTML::Mason 1.27; #http://www.masonhq.com/?ApacheModPerl2Redirect
 use HTML::Mason::Interp;
 use HTML::Mason::Compiler::ToObject;
@@ -32,6 +33,26 @@ if ( %%%RT_ENABLED%%% ) {
  die $@ if $@;
 }
 
+# Some hooks supporting strange legacy ways people have added stuff on
+
+my @addl_comp_root = ();
+my $addl_comp_root_file = '%%%FREESIDE_CONF%%%/addl_comp_root.pl';
+if ( -e $addl_comp_root_file ) {
+  my $text = slurp( $addl_comp_root_file );
+  my @addl = eval $text;
+  if ( @addl && ! $@ ) {
+    @addl_comp_root = @addl;
+  } elsif ($@) {
+    warn "error parsing $addl_comp_root_file: $@\n";
+  }
+}
+
+$FS::Mason::addl_handler_use = '';
+my $addl_handler_use_file = '%%%FREESIDE_CONF%%%/addl_handler_use.pl';
+if ( -e $addl_handler_use_file ) {
+  $FS::Mason::addl_handler_use = slurp( $addl_handler_use_file );
+}
+
 # Create Mason objects
 
 my %interp = (
@@ -43,6 +64,7 @@ my %interp = (
   comp_root            => [
                             [ 'freeside' => '%%%FREESIDE_DOCUMENT_ROOT%%%'    ],
                             [ 'rt'       => '%%%FREESIDE_DOCUMENT_ROOT%%%/rt' ],
+                            @addl_comp_root,
                           ],
 );
 
@@ -217,6 +239,11 @@ sub handler
       use FS::reason;
       use FS::cust_main_note;
 
+      if ( $FS::Mason::addl_handler_use ) {
+        eval $FS::Mason::addl_handler_use;
+        die $@ if $@;
+      }
+
       if ( %%%RT_ENABLED%%% ) {
         eval '
           use RT::Tickets;