This commit was generated by cvs2svn to compensate for changes in r9232,
[freeside.git] / httemplate / autohandler
1 % $m->call_next;
2 <%init>
3   dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
4 </%init>
5 <%filter>
6
7 my $profile = '';
8 if ( UNIVERSAL::can(dbh, 'sprintProfile') ) {
9
10   if ( lc($r->content_type) eq 'text/html'
11        && $FS::CurrentUser::CurrentUser->option('show_db_profile')
12      )
13   {
14
15     ## barely worth it, just in case someone tries to use profiling on a
16     ## non-RT install
17     #eval "use Text::Wrapper;";
18     #die $@ if $@;
19
20     my $text = dbh->sprintProfile();
21     #$text =~ s/^/                                                          /mg;
22
23     $profile = '<PRE>'.  encode_entities( $text ). "\n\n". '</PRE>';
24
25   }
26
27   #well, could do this without sprintProfile, but definiately don't want it on
28   #unless DBIx::Profile is loaded
29   if ( $FS::CurrentUser::CurrentUser->option('save_db_profile') ) {
30     #my $file = %%%FREESIDE_LOG%%%; #substitute here?  maybe get from FS.pm?
31     my $file = '/usr/local/etc/freeside/'; #bah
32     $file .= "dbix_profile.$$.". time;
33     dbh->setLogFile($file);
34     dbh->printProfile();
35   }
36
37   dbh->{'private_profile'} = {};
38 }
39
40 s/(<\/BODY>[\s\n]*<\/HTML>[\s\n]*)$/$profile$1/i;
41 </%filter>
42 <%cleanup>
43    dbh->commit();
44 </%cleanup>