per-user preference for turning on profiling display when DBIx::Profile is loaded...
[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 $wrapper = new Text::Wrapper( columns => 80 );
21     my $text = dbh->sprintProfile();
22     #my $text = $wrapper->wrap( dbh->sprintProfile() );
23     $text =~ s/^/                                                          /mg;
24     
25     $profile = '<PRE>'.
26                encode_entities( $text ).
27                #"\n\n". &sprintAutoProfile(). '</PRE>';
28                "\n\n".                        '</PRE>';
29   } 
30
31   dbh->{'private_profile'} = {};
32 }
33
34 s/(<\/BODY>[\s\n]*<\/HTML>[\s\n]*)$/$profile$1/i;
35 </%filter>
36 <%cleanup>
37    dbh->commit();
38 </%cleanup>