summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile36
-rw-r--r--htetc/handler.pl96
-rw-r--r--rt/FREESIDE_MODIFIED2
-rw-r--r--rt/etc/RT_SiteConfig.pm12
-rw-r--r--rt/sbin/rt-setup-database4
-rw-r--r--rt/sbin/rt-setup-database.in7
6 files changed, 147 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index e5ef70d6c..70e588218 100644
--- a/Makefile
+++ b/Makefile
@@ -56,10 +56,18 @@ SELFSERVICE_USER = fs_selfservice
SELFSERVICE_MACHINES = localhost
# SELFSERVICE_MACHINES = web1.example.com web2.example.com
+#RT_ENABLED = 0
+RT_ENABLED = 1
+RT_DOMAIN = example.com
+RT_TIMEZONE = 'US/Pacific';
+#RT_TIMEZONE = 'US/Eastern';
+
#---
#not changable yet
FREESIDE_CONF = /usr/local/etc/freeside
+#rt/config.layout.in
+RT_PATH = /opt/rt3
VERSION=1.5.0pre4
TAG=freeside_1_5_0pre4
@@ -125,6 +133,7 @@ install-docs: docs
[ "${TEMPLATE}" = "mason" ] && \
perl -p -i -e "\
s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
+ s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
" ${MASON_HANDLER} || true
[ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
[ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true
@@ -148,7 +157,7 @@ install-init:
s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
" ${INIT_FILE}
-install: install-perl-modules install-docs install-init
+install: install-perl-modules install-docs install-init install-rt
deploy: install
${HTTPD_RESTART}
@@ -191,20 +200,35 @@ configure-rt:
s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
s'%%%MASONDATA%%%'${MASONDATA}'g;\
" config.layout; \
- ./configure --with-layout=Freeside\
+ ./configure --enable-layout=Freeside\
--with-db-type=Pg \
+ --with-db-dba=${DB_USER} \
--with-db-database=freeside \
--with-db-rt-user=${DB_USER} \
--with-db-rt-pass=${DB_PASSWORD} \
--with-web-user=freeside \
- --with-web-group=www
+ --with-web-group=freeside \
+ --with-rt-group=freeside
create-rt: configure-rt
cd rt; make install
- rt/sbin/rt-setup-database --action schema
- rt/sbin/rt-setup-database --action insert_initial
- rt/sbin/rt-setup-database --action insert --datafile rt/etc/initialdata
+ echo -e "${DB_PASSWORD}\n\\d sessions"\
+ | psql -UW ${DB_USER} freeside 2>&1\
+ | grep '^Did not find'\
+ && rt/sbin/rt-setup-database --dba '${DB_USER}' \
+ --dba-password '${DB_PASSWORD}' \
+ --action schema \
+ || true
+ rt/sbin/rt-setup-database --action insert_initial \
+ && rt/sbin/rt-setup-database --action insert --datafile ${RT_PATH}/etc/initialdata \
+ || true
+ perl -p -i -e "\
+ s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
+ s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
+ " ${RT_PATH}/etc/RT_SiteConfig.pm
+install-rt:
+ [ ${RT_ENABLED} ] && cd rt; make install
clean:
rm -rf aspdocs masondocs
diff --git a/htetc/handler.pl b/htetc/handler.pl
index b81606a0a..d425c2270 100644
--- a/htetc/handler.pl
+++ b/htetc/handler.pl
@@ -35,12 +35,37 @@ use strict;
# data_dir=>'/usr/local/etc/freeside/masondata',
# out_mode=>'stream',
# );
+
+use vars qw($r);
+
+if ( %%%RT_ENABLED%%% ) {
+ eval '
+ use lib ("/opt/rt3/local/lib", "/opt/rt3/lib");
+ use RT;
+ use vars qw($Nobody $SystemUser);
+ RT::LoadConfig();
+ ';
+ die $@ if $@;
+
+
+}
+
+
my $ah = new HTML::Mason::ApacheHandler (
#interp => $interp,
#auto_send_headers => 0,
- comp_root=>'%%%FREESIDE_DOCUMENT_ROOT%%%',
+ comp_root=> [
+ [ 'freeside' => '%%%FREESIDE_DOCUMENT_ROOT%%%' ],
+ [ 'rt' => '%%%FREESIDE_DOCUMENT_ROOT%%%/rt' ],
+ ],
data_dir=>'/usr/local/etc/freeside/masondata',
#out_mode=>'stream',
+
+ #RT
+ args_method => 'CGI',
+ default_escape_flags => 'h',
+ allow_globals => [qw(%session)],
+ #autoflush => 1,
);
# Activate the following if running httpd as root (the normal case).
@@ -50,7 +75,7 @@ my $ah = new HTML::Mason::ApacheHandler (
sub handler
{
- my ($r) = @_;
+ ($r) = @_;
# If you plan to intermix images in the same directory as
# components, activate the following to prevent Mason from
@@ -62,7 +87,8 @@ sub handler
{ package HTML::Mason::Commands;
use strict;
use vars qw( $cgi $p );
- use CGI 2.47;
+ use vars qw( %session );
+ use CGI 2.47 qw(-private_tempfiles);
#use CGI::Carp qw(fatalsToBrowser);
use Date::Format;
use Date::Parse;
@@ -125,6 +151,32 @@ sub handler
use FS::export_svc;
use FS::msgcat;
+ if ( %%%RT_ENABLED%%% ) {
+ eval '
+ use RT::Tickets;
+ use RT::Transactions;
+ use RT::Users;
+ use RT::CurrentUser;
+ use RT::Templates;
+ use RT::Queues;
+ use RT::ScripActions;
+ use RT::ScripConditions;
+ use RT::Scrips;
+ use RT::Groups;
+ use RT::GroupMembers;
+ use RT::CustomFields;
+ use RT::CustomFieldValues;
+ use RT::TicketCustomFieldValues;
+
+ use RT::Interface::Web;
+ use MIME::Entity;
+ use Text::Wrapper;
+ use CGI::Cookie;
+ use Time::ParseDate;
+ ';
+ die $@ if $@;
+ }
+
*CGI::redirect = sub {
my( $self, $location ) = @_;
use vars qw($m);
@@ -205,7 +257,43 @@ sub handler
# $r->send_http_header;
- my $status = $ah->handle_request($r);
+ #$ah->interp->remove_escape('h');
+
+ if ( $r->filename =~ /\/rt\// ) { #RT
+ #warn "processing RT file". $r->filename. "; escaping for RT\n";
+
+ # MasonX::Request::ExtendedCompRoot
+ #$ah->interp->comp_root( '/rt'. $ah->interp->comp_root() );
+
+ $ah->interp->set_escape( h => \&RT::Interface::Web::EscapeUTF8 );
+
+ local $SIG{__WARN__};
+ local $SIG{__DIE__};
+
+ RT::Init();
+
+ # We don't need to handle non-text items
+ return -1 if defined( $r->content_type ) && $r->content_type !~ m|^text/|io;
+
+ } else {
+ $ah->interp->set_escape( 'h' => sub { ${$_[0]}; } );
+ }
+
+ my %session;
+ my $status;
+ eval { $status = $ah->handle_request($r); };
+#!!
+# if ( $@ ) {
+# $RT::Logger->crit($@);
+# }
+
+ undef %session;
+
+#!!
+# if ($RT::Handle->TransactionDepth) {
+# $RT::Handle->ForceRollback;
+# $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") ;
+# }
$status;
}
diff --git a/rt/FREESIDE_MODIFIED b/rt/FREESIDE_MODIFIED
index cab7db3cf..84a9f5ea9 100644
--- a/rt/FREESIDE_MODIFIED
+++ b/rt/FREESIDE_MODIFIED
@@ -1,3 +1,5 @@
sbin/rt-setup-database
+sbin/rt-setup-database.in
config.layout
config.layout.in
+etc/RT_SiteConfig.pm
diff --git a/rt/etc/RT_SiteConfig.pm b/rt/etc/RT_SiteConfig.pm
index 0afc6045c..572a2baf6 100644
--- a/rt/etc/RT_SiteConfig.pm
+++ b/rt/etc/RT_SiteConfig.pm
@@ -1 +1,13 @@
+$RT::rtname = '%%%RT_DOMAIN%%%';
+$RT::Organization = '%%%RT_DOMAIN%%%';
+
+$RT::Timezone = '%%%RT_TIMEZONE%%%';
+
+$RT::WebBaseURL = '';
+$RT::WebPath = '/freeside/rt';
+
+$RT::WebExternalAuth = 1;
+$RT::WebFallbackToInternal = 1; #no
+$RT::WebExternalAuto = 1;
+
1;
diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database
index 83e08270a..434e68671 100644
--- a/rt/sbin/rt-setup-database
+++ b/rt/sbin/rt-setup-database
@@ -592,6 +592,10 @@ $0: Set up RT's database
--action init Initialize the database
drop Drop the database.
This will ERASE ALL YOUR DATA
+ insert_initial
+ Insert RT's core system objects
+ insert_initial
+ Insert RT's core system objects
insert Insert data into RT's database.
By default, will use RT's installation data.
To use a local or supplementary datafile, specify it
diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in
index 9e990e5b8..f37c69dc7 100644
--- a/rt/sbin/rt-setup-database.in
+++ b/rt/sbin/rt-setup-database.in
@@ -110,6 +110,9 @@ elsif ( $args{'action'} eq 'drop' ) {
}
drop_db();
}
+elsif ( $args{'action'} eq 'insert_initial' ) {
+ insert_initial_data();
+}
elsif ( $args{'action'} eq 'insert' ) {
insert_data( $args{'datafile'} );
}
@@ -589,6 +592,10 @@ $0: Set up RT's database
--action init Initialize the database
drop Drop the database.
This will ERASE ALL YOUR DATA
+ insert_initial
+ Insert RT's core system objects
+ insert_initial
+ Insert RT's core system objects
insert Insert data into RT's database.
By default, will use RT's installation data.
To use a local or supplementary datafile, specify it