--- loncom/interface/lonpreferences.pm 2009/10/08 21:15:19 1.125.4.6 +++ loncom/interface/lonpreferences.pm 2009/10/09 01:44:26 1.125.4.7 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.125.4.6 2009/10/08 21:15:19 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.125.4.7 2009/10/09 01:44:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,7 @@ use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonlocal; use Apache::lonnet; +use LONCAPA::lonauthcgi(); use LONCAPA(); # @@ -2072,13 +2073,11 @@ sub handler { || ($printmenu eq 'not_on_error' && !$error) ) && (!$env{'form.returnurl'})) { my $optionlist = ''; - 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'}.'-.', + ($env{'user.debug'} ? 'on' : 'off'), href => '/adm/preferences', printmenu => 'yes', subroutine => \&toggle_debug, @@ -2120,12 +2119,26 @@ sub handler { } sub toggle_debug { - if ($env{'user.debug'}) { - &Apache::lonnet::delenv('user.debug'); - } else { - &Apache::lonnet::appenv({'user.debug' => 1}); + if (&can_toggle_debug()) { + if ($env{'user.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__