diff options
author | ivan <ivan> | 2009-02-17 02:28:48 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-02-17 02:28:48 +0000 |
commit | d7b1a575ccef91f704b1573c431235441d52e47d (patch) | |
tree | 69ae1551039a77ded47c36d162ee2ef83cc85ddd | |
parent | 74190e6834c47c73b7f073fb1de444e572180333 (diff) |
per-user preference for turning on profiling display when DBIx::Profile is loaded, RT#4830
-rw-r--r-- | FS/FS/Mason.pm | 84 | ||||
-rw-r--r-- | httemplate/autohandler | 5 | ||||
-rw-r--r-- | httemplate/pref/pref-process.html | 3 | ||||
-rw-r--r-- | httemplate/pref/pref.html | 4 |
4 files changed, 66 insertions, 30 deletions
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index e0f58b814..ee777a485 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -233,20 +233,35 @@ Initializes the Mason environment, loads all Freeside and RT libraries, etc. use vars qw($m); # false laziness w/below - if ( defined(@DBIx::Profile::ISA) ) { #profiling redirect - - my $page = - qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!. - '<BR><BR><PRE>'. - ( UNIVERSAL::can(dbh, 'sprintProfile') - ? encode_entities(dbh->sprintProfile()) - : 'DBIx::Profile missing sprintProfile method;'. - 'unpatched or too old?' ). - #"\n\n". &sprintAutoProfile(). '</PRE>'. - "\n\n". '</PRE>'. - '</BODY></HTML>'; - dbh->{'private_profile'} = {}; - return $page; + if ( defined(@DBIx::Profile::ISA) ) { + + if ( $FS::CurrentUser::CurrentUser->option('show_db_profile') ) { + + #profiling redirect + + my $page = + qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!. + '<BR><BR><PRE>'. + ( UNIVERSAL::can(dbh, 'sprintProfile') + ? encode_entities(dbh->sprintProfile()) + : 'DBIx::Profile missing sprintProfile method;'. + 'unpatched or too old?' ). + #"\n\n". &sprintAutoProfile(). '</PRE>'. + "\n\n". '</PRE>'. + '</BODY></HTML>'; + + + dbh->{'private_profile'} = {}; + return $page; + + } else { + + #clear db profile, but normal redirect + dbh->{'private_profile'} = {}; + $m->redirect($location); + ''; + + } } else { #normal redirect @@ -272,20 +287,33 @@ Initializes the Mason environment, loads all Freeside and RT libraries, etc. use vars qw($m); $m->clear_buffer; #false laziness w/above - if ( defined(@DBIx::Profile::ISA) ) { #profiling redirect - - $m->print( - qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!. - '<BR><BR><PRE>'. - ( UNIVERSAL::can(dbh, 'sprintProfile') - ? encode_entities(dbh->sprintProfile()) - : 'DBIx::Profile missing sprintProfile method;'. - 'unpatched or too old?' ). - #"\n\n". &sprintAutoProfile(). '</PRE>'. - "\n\n". '</PRE>'. - '</BODY></HTML>' - ); - dbh->{'private_profile'} = {}; + if ( defined(@DBIx::Profile::ISA) ) { + + if ( $FS::CurrentUser::CurrentUser->option('show_db_profile') ) { + + #profiling redirect + + $m->print( + qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!. + '<BR><BR><PRE>'. + ( UNIVERSAL::can(dbh, 'sprintProfile') + ? encode_entities(dbh->sprintProfile()) + : 'DBIx::Profile missing sprintProfile method;'. + 'unpatched or too old?' ). + #"\n\n". &sprintAutoProfile(). '</PRE>'. + "\n\n". '</PRE>'. + '</BODY></HTML>' + ); + + dbh->{'private_profile'} = {}; + + } else { + + #clear db profile, but normal redirect + dbh->{'private_profile'} = {}; + $m->redirect($location); + + } } else { #normal redirect diff --git a/httemplate/autohandler b/httemplate/autohandler index bdea50534..ee37934cf 100644 --- a/httemplate/autohandler +++ b/httemplate/autohandler @@ -7,7 +7,10 @@ my $profile = ''; if ( UNIVERSAL::can(dbh, 'sprintProfile') ) { - if ( lc($r->content_type) eq 'text/html' ) { + if ( lc($r->content_type) eq 'text/html' + && $FS::CurrentUser::CurrentUser->option('show_db_profile') + ) + { ## barely worth it, just in case someone tries to use profiling on a ## non-RT install diff --git a/httemplate/pref/pref-process.html b/httemplate/pref/pref-process.html index 09eb71a7e..466218947 100644 --- a/httemplate/pref/pref-process.html +++ b/httemplate/pref/pref-process.html @@ -30,9 +30,10 @@ % my %param = $access_user->options; % % #XXX autogen -% my @paramlist = qw( menu_position show_pkgnum +% my @paramlist = qw( menu_position % email_address % vonage-fromnumber vonage-username vonage-password +% show_pkgnum show_db_profile % height width availHeight availWidth colorDepth % ); % diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html index 4007bb9f1..44b844891 100644 --- a/httemplate/pref/pref.html +++ b/httemplate/pref/pref.html @@ -64,6 +64,10 @@ Development <TH>Show internal package numbers: </TH> <TD><INPUT TYPE="checkbox" NAME="show_pkgnum" VALUE="1" <% $curuser->option('show_pkgnum') ? 'CHECKED' : '' %>></TD> </TR> + <TR> + <TH>Show database profiling (when available): </TH> + <TD><INPUT TYPE="checkbox" NAME="show_db_profile" VALUE="1" <% $curuser->option('show_db_profile') ? 'CHECKED' : '' %>></TD> + </TR> </TABLE> <BR> |