per-user preference for turning on profiling display when DBIx::Profile is loaded...
authorivan <ivan>
Tue, 17 Feb 2009 02:28:48 +0000 (02:28 +0000)
committerivan <ivan>
Tue, 17 Feb 2009 02:28:48 +0000 (02:28 +0000)
FS/FS/Mason.pm
httemplate/autohandler
httemplate/pref/pref-process.html
httemplate/pref/pref.html

index e0f58b8..ee777a4 100644 (file)
@@ -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
 
index bdea505..ee37934 100644 (file)
@@ -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
index 09eb71a..4662189 100644 (file)
 % 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
 %                   );
 %
index 4007bb9..44b8448 100644 (file)
@@ -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>