[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 16 Mar 2006 19:19:59 -0000


raeburn		Thu Mar 16 14:19:59 2006 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  DC's assumption of any CC role.  Improve readibility by replacing $1 and $2 in calls to &set_privileges with $domain and $coursenum.  Correct the setting of $env{request.role} to cc./$cdom/$cnum (instead of just cc).
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.145 loncom/auth/lonroles.pm:1.146
--- loncom/auth/lonroles.pm:1.145	Fri Jan  6 16:04:33 2006
+++ loncom/auth/lonroles.pm	Thu Mar 16 14:19:59 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.145 2006/01/06 21:04:33 albertel Exp $
+# $Id: lonroles.pm,v 1.146 2006/03/16 19:19:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -108,10 +108,10 @@
 # Check if user is a DC trying to enter a course and needs privs to be created
         if ($numdc > 0) {
             foreach my $envkey (keys %env) {
-                if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) {
-                    if ($dcroles{$1}) {
-                        my $cckey = 'user.role.cc./'.$1.'/'.$2;
-                        &check_privs($cckey,$then,$now);
+                if (my ($domain,$coursenum) =
+                                    ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-)) {
+                    if ($dcroles{$domain}) {
+                        &check_privs($domain,$coursenum,$then,$now);
                     }
                     last;
                 }
@@ -847,15 +847,16 @@
 }
 
 sub check_privs {
-    my ($cckey,$then,$now) = @_;
+    my ($cdom,$cnum,$then,$now) = @_;
+    my $cckey = 'user.role.cc./'.$cdom.'/'.$cnum; 
     if ($env{$cckey}) {
         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
         &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
-            &set_privileges($1,$2);
+            &set_privileges($cdom,$cnum);
         }
     } else {
-        &set_privileges($1,$2);
+        &set_privileges($cdom,$cnum);
     }
 }
 
@@ -1022,7 +1023,7 @@
                          $env{'user.home'},
                         "Role ".$role);
     &Apache::lonnet::appenv(
-                          'request.role'        => $role,
+                          'request.role'        => $spec,
                           'request.role.domain' => $dcdom,
                           'request.course.sec'  => '');
     my $tadv=0;