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

raeburn raeburn@source.lon-capa.org
Sat, 02 Jan 2010 18:28:11 -0000


raeburn		Sat Jan  2 18:28:11 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/auth	lonroles.pm 
  Log:
  - Backport 1.232.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.231.4.2 loncom/auth/lonroles.pm:1.231.4.3
--- loncom/auth/lonroles.pm:1.231.4.2	Fri Aug 14 12:41:34 2009
+++ loncom/auth/lonroles.pm	Sat Jan  2 18:28:11 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.231.4.2 2009/08/14 12:41:34 raeburn Exp $
+# $Id: lonroles.pm,v 1.231.4.3 2010/01/02 18:28:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -226,7 +226,7 @@
             # Check if user is CC trying to select a course role
             if ($env{'form.switchrole'}) {
                 if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
-                    &adhoc_course_role($then);
+                    &adhoc_course_role($refresh,$then);
                 }
             }
 	    my %temp=('logout_'.$env{'request.course.id'} => time);
@@ -1372,21 +1372,21 @@
 }
 
 sub adhoc_course_role {
-    my ($then) = @_; 
+    my ($refresh,$then) = @_;
     my ($cdom,$cnum);
     $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-    if (&check_forcc($cdom,$cnum,$then)) {
+    if (&check_forcc($cdom,$cnum,$refresh,$then)) {
         my $setprivs;
         if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
             $setprivs = 1;
         } else {
             my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
-            if (($start && ($start>$then || $start == -1)) ||
+            if (($start && ($start>$refresh || $start == -1)) ||
                 ($end && $end<$then)) {
                 $setprivs = 1;
             }
-        } 
+        }
         if ($setprivs) {
             if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
                 my $role = $1;
@@ -1416,7 +1416,7 @@
                 }
                 &Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area);
                 &Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups);
-                my $adhocstart = $then-1;
+                my $adhocstart = $refresh-1;
                 $userroles{'user.role.'.$spec} = $adhocstart.'.';
                 &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
             }
@@ -1426,7 +1426,7 @@
 }
 
 sub check_forcc {
-    my ($cdom,$cnum,$then) = @_;
+    my ($cdom,$cnum,$refresh,$then) = @_;
     my $is_cc;
     if ($cdom ne '' && $cnum ne '') {
         if (&Apache::lonnet::is_course($cdom,$cnum)) {
@@ -1434,7 +1434,7 @@
             if (defined($env{$envkey})) {
                 $is_cc = 1;
                 my ($tstart,$tend)=split(/\./,$env{$envkey});
-                if ($tstart && $tstart>$then) { $is_cc = 0; }
+                if ($tstart && $tstart>$refresh) { $is_cc = 0; }
                 if ($tend   && $tend  <$then) { $is_cc = 0; }
             }
         }