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

www lon-capa-cvs-allow@mail.lon-capa.org
Wed, 14 May 2008 18:21:41 -0000


www		Wed May 14 14:21:41 2008 EDT

  Modified files:              
    /loncom/interface	lonpreferences.pm 
  Log:
  Work on bug #5613 - opt out of domain coordinator access
  
  
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.118 loncom/interface/lonpreferences.pm:1.119
--- loncom/interface/lonpreferences.pm:1.118	Mon May 12 19:47:43 2008
+++ loncom/interface/lonpreferences.pm	Wed May 14 14:21:40 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.118 2008/05/12 23:47:43 www Exp $
+# $Id: lonpreferences.pm,v 1.119 2008/05/14 18:21:40 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -609,6 +609,52 @@
     $r->print(&mt('Registering clickers: [_1]',$newclickers));
 }
 
+################################################################
+#               Domcoord Access Subroutines                    #
+################################################################
+
+sub domcoordchanger {
+    my $r = shift;
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %userenv = &Apache::lonnet::get
+        ('environment',['domcoord.author','domcoord.cc']);
+    my $constchecked='';
+    my $courseschecked='';
+    if ($userenv{'domcoord.author'} eq 'blocked') {
+       $constchecked='checked="checked"';
+    }
+    if ($userenv{'domcoord.cc'} eq 'blocked') {
+       $courseschecked='checked="checked"';
+    }
+    my $text=&mt('By default, the Domain Coordinator can enter your courses and construction space.');
+    my $construction=&mt('Block access to construction space');
+    my $courses=&mt('Block access to courses');
+    my $change=&mt('Change');
+    $r->print(<<ENDSCREEN);
+<form name="prefs" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="verify_and_change_domcoord" />
+$text<br />
+<label><input type="checkbox" name="construction" $constchecked />$construction</label><br />
+<label><input type="checkbox" name="courses" $courseschecked />$courses</label><br />
+<input type="submit" value="$change" />
+</form>
+ENDSCREEN
+}
+
+sub verify_and_change_domcoord {
+    my $r = shift;
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %domcoord=('domcoord.author' => '','domcoord.cc' => '');
+    if ($env{'form.construction'}) { $domcoord{'domcoord.author'}='blocked'; }
+    if ($env{'form.courses'}) { $domcoord{'domcoord.cc'}='blocked'; }
+    &Apache::lonnet::put('environment',\%domcoord);
+    &Apache::lonnet::appenv({'environment.domcoord.author' => $domcoord{'domcoord.author'},
+                             'environment.domcoord.cc' => $domcoord{'domcoord.cc'}});
+    $r->print(&mt('Registering Domain Coordinator access restrictions.'));
+}
+
 #################################################################
 ##                      Lock Subroutines                        #
 #################################################################
@@ -1871,6 +1917,23 @@
                             text => 'Register Clicker'},
                       printmenu => 'yes',
                       }));
+   if ($env{'user.adv'}) {
+      push (@Options,({ action   => 'changedomcoord',
+                        linktext => 'Restrict Domain Coordinator Access',
+                        href     => '/adm/preferences',
+                        subroutine => \&domcoordchanger,
+                        breadcrumb =>
+                            { href => '/adm/preferences?action=changedomcoord',
+                              text => 'Restrict Domain Coordinator Access'},
+                      },
+                      { action   => 'verify_and_change_domcoord',
+                        subroutine => \&verify_and_change_domcoord,
+                        breadcrumb =>
+                            { href => '/adm/preferences?action=changedomcoord',
+                              text => 'Restrict Domain Coordinator Access'},
+                        printmenu => 'yes',
+                      }));
+    }
 
     push (@Options,({ action   => 'lockwarning',
                       subroutine => \&lockwarning,
@@ -1906,7 +1969,7 @@
                        }));
     }
 
-    if ($env{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle|raeburn)$/) {
+    if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) {
         push (@Options,({ action => 'debugtoggle',
                           printmenu => 'yes',
                           subroutine => \&toggle_debug,