[LON-CAPA-cvs] cvs: loncom(GCI_2) /interface lonpreferences.pm

raeburn raeburn@source.lon-capa.org
Mon, 07 Dec 2009 00:04:11 -0000


raeburn		Mon Dec  7 00:04:11 2009 EDT

  Modified files:              (Branch: GCI_2)
    /loncom/interface	lonpreferences.pm 
  Log:
  - Backport 1.174.
  
  
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.125.8.3 loncom/interface/lonpreferences.pm:1.125.8.4
--- loncom/interface/lonpreferences.pm:1.125.8.3	Thu Nov 19 15:41:59 2009
+++ loncom/interface/lonpreferences.pm	Mon Dec  7 00:04:10 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.125.8.3 2009/11/19 15:41:59 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.125.8.4 2009/12/07 00:04:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,6 +42,7 @@
 use Apache::lonhtmlcommon();
 use Apache::lonlocal;
 use Apache::lonnet;
+use LONCAPA::lonauthcgi();
 use LONCAPA();
 
 #
@@ -2043,7 +2044,7 @@
                        }));
     }
 
-    if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) {
+    if (&can_toggle_debug()) {
         push (@Options,({ action => 'debugtoggle',
                           printmenu => 'yes',
                           subroutine => \&toggle_debug,
@@ -2075,13 +2076,11 @@
 	   || ($printmenu eq 'not_on_error' && !$error) )
 	 && (!$env{'form.returnurl'})) {
         my $optionlist = '<table cellpadding="5">';
-        if ($env{'user.name'} =~ 
-                         /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/
-            ) {
+        if (&can_toggle_debug()) {
             push (@Options,({ action => 'debugtoggle',
                               linktext => 'Toggle Debug Messages',
-                              text => 'Current Debug status is -'.
-                                  $env{'user.debug'}.'-.',
+                              text => 'Current Debug status is: '.
+                                      ($env{'user.debug'} ? 'on' : 'off'),
                               href => '/adm/preferences',
                               printmenu => 'yes',
                               subroutine => \&toggle_debug,
@@ -2123,12 +2122,24 @@
 }
 
 sub toggle_debug {
-    if ($env{'user.debug'}) {
+    if (&can_toggle_debug()) {
         &Apache::lonnet::delenv('user.debug');
     } else {
         &Apache::lonnet::appenv({'user.debug' => 1});
     }
 }
 
+sub can_toggle_debug {
+    my $can_toggle = 0;
+    my $page = 'toggledebug';
+    if (&LONCAPA::lonauthcgi::can_view($page)) {
+        $can_toggle = 1;
+    } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
+        $can_toggle = 1;
+    }
+    return $can_toggle;
+}
+
+
 1;
 __END__