[LON-CAPA-cvs] cvs: loncom /cgi lonauthcgi.pm /interface domainprefs.pm lonpreferences.pm

raeburn raeburn@source.lon-capa.org
Thu, 08 Oct 2009 22:37:40 -0000


raeburn		Thu Oct  8 22:37:40 2009 EDT

  Modified files:              
    /loncom/interface	lonpreferences.pm domainprefs.pm 
    /loncom/cgi	lonauthcgi.pm 
  Log:
  - Show/Hide Toggle Debug link in User Preferences now set via Domain Configuration (in place of hard-coded developer usernames).
  
  
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.173 loncom/interface/lonpreferences.pm:1.174
--- loncom/interface/lonpreferences.pm:1.173	Thu Oct  8 19:54:37 2009
+++ loncom/interface/lonpreferences.pm	Thu Oct  8 22:37:33 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.173 2009/10/08 19:54:37 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.174 2009/10/08 22:37:33 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();
 
 #
@@ -1990,9 +1991,9 @@
 	});
 
     }
-    if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) {
+    if (&can_toggle_debug()) {
 push(@{ $menu[4]->{items} }, {
-	linktext => 'Toggle Debug Messages (Current:'.$env{'user.debug'}.')',
+	linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'),
 	url => '/adm/preferences?action=debugtoggle',
 	permission => 'F',
 	#help => '',
@@ -2091,7 +2092,9 @@
     }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
         &verify_and_change_coursepage($r);
     }elsif($env{'form.action'} eq 'debugtoggle'){
-        &toggle_debug();
+        if (&can_toggle_debug()) {
+            &toggle_debug();
+        }
 	&print_main_menu($r);
     }
 
@@ -2114,5 +2117,16 @@
     }
 }
 
+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__
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.112 loncom/interface/domainprefs.pm:1.113
--- loncom/interface/domainprefs.pm:1.112	Tue Oct  6 21:54:50 2009
+++ loncom/interface/domainprefs.pm	Thu Oct  8 22:37:33 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.112 2009/10/06 21:54:50 raeburn Exp $
+# $Id: domainprefs.pm,v 1.113 2009/10/08 22:37:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2721,7 +2721,7 @@
 sub serverstatus_pages {
     return ('userstatus','lonstatus','loncron','server-status','codeversions',
             'clusterstatus','metadata_keywords','metadata_harvest',
-            'takeoffline','takeonline','showenv');
+            'takeoffline','takeonline','showenv','toggledebug');
 }
 
 sub coursecategories_javascript {
Index: loncom/cgi/lonauthcgi.pm
diff -u loncom/cgi/lonauthcgi.pm:1.4 loncom/cgi/lonauthcgi.pm:1.5
--- loncom/cgi/lonauthcgi.pm:1.4	Fri Aug 21 23:14:06 2009
+++ loncom/cgi/lonauthcgi.pm	Thu Oct  8 22:37:39 2009
@@ -1,7 +1,7 @@
 #
 # LON-CAPA authorization for cgi-bin scripts
 #
-# $Id: lonauthcgi.pm,v 1.4 2009/08/21 23:14:06 raeburn Exp $
+# $Id: lonauthcgi.pm,v 1.5 2009/10/08 22:37:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -271,6 +271,7 @@
                    'takeoffline'       => 'Offline - replace Log-in page',
                    'takeonline'        => 'Online - restore Log-in page',
                    'showenv'           => "Show user environment",
+                   'toggledebug'       => "Toggle debug messages",
                  );
     return \%titles;
 }