[LON-CAPA-cvs] cvs: loncom /auth loncacc.pm /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Thu, 30 Sep 2010 16:42:33 -0000


raeburn		Thu Sep 30 16:42:33 2010 EDT

  Modified files:              
    /loncom/auth	loncacc.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Bug 6373.
    - Do not change request.role, request.role.domain, request.course.sec
      when DC assumes ad hoc co-author role via "Edit resource" in a course.
  
  
Index: loncom/auth/loncacc.pm
diff -u loncom/auth/loncacc.pm:1.50 loncom/auth/loncacc.pm:1.51
--- loncom/auth/loncacc.pm:1.50	Wed Oct  7 14:47:48 2009
+++ loncom/auth/loncacc.pm	Thu Sep 30 16:42:30 2010
@@ -2,7 +2,7 @@
 # Cookie Based Access Handler for Construction Area
 # (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer)
 #
-# $Id: loncacc.pm,v 1.50 2009/10/07 14:47:48 raeburn Exp $
+# $Id: loncacc.pm,v 1.51 2010/09/30 16:42:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -126,9 +126,14 @@
         unless ($blocked{'domcoord.author'} eq 'blocked') {
             if (grep(/^$ownerdomain$/,@possibledomains)) {
                 if ($setpriv) {
+                    my $refresh=$env{'user.refresh.time'};
+                    if (!$refresh) {
+                        $refresh = $then;
+                    }
                     my $now = time;
                     &Apache::lonnet::check_adhoc_privs($ownerdomain,$ownername,
-                                                       $then,$now,'ca');
+                                                       $then,$refresh,$now,'ca',
+                                                       'constructaccess');
                 }
                 return($ownername,$ownerdomain);
             }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1087 loncom/lonnet/perl/lonnet.pm:1.1088
--- loncom/lonnet/perl/lonnet.pm:1.1087	Thu Sep 30 14:08:51 2010
+++ loncom/lonnet/perl/lonnet.pm	Thu Sep 30 16:42:33 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1087 2010/09/30 14:08:51 raeburn Exp $
+# $Id: lonnet.pm,v 1.1088 2010/09/30 16:42:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4287,22 +4287,22 @@
 }
 
 sub check_adhoc_privs {
-    my ($cdom,$cnum,$then,$refresh,$now,$checkrole) = @_;
+    my ($cdom,$cnum,$then,$refresh,$now,$checkrole,$caller) = @_;
     my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum;
     if ($env{$cckey}) {
         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
         &role_status($cckey,$then,$refresh,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
-            &set_adhoc_privileges($cdom,$cnum,$checkrole);
+            &set_adhoc_privileges($cdom,$cnum,$checkrole,$caller);
         }
     } else {
-        &set_adhoc_privileges($cdom,$cnum,$checkrole);
+        &set_adhoc_privileges($cdom,$cnum,$checkrole,$caller);
     }
 }
 
 sub set_adhoc_privileges {
 # role can be cc or ca
-    my ($dcdom,$pickedcourse,$role) = @_;
+    my ($dcdom,$pickedcourse,$role,$caller) = @_;
     my $area = '/'.$dcdom.'/'.$pickedcourse;
     my $spec = $role.'.'.$area;
     my %userroles = &set_arearole($role,$area,'','',$env{'user.domain'},
@@ -4312,14 +4312,16 @@
     my ($author,$adv)= &set_userprivs(\%userroles,\%ccrole);
     &appenv(\%userroles,[$role,'cm']);
     &log($env{'user.domain'},$env{'user.name'},$env{'user.home'},"Role ".$role);
-    &appenv( {'request.role'        => $spec,
-              'request.role.domain' => $dcdom,
-              'request.course.sec'  => ''
-             }
-           );
-    my $tadv=0;
-    if (&allowed('adv') eq 'F') { $tadv=1; }
-    &appenv({'request.role.adv'    => $tadv});
+    unless ($caller eq 'constructaccess' && $env{'request.course.id'}) {
+        &appenv( {'request.role'        => $spec,
+                  'request.role.domain' => $dcdom,
+                  'request.course.sec'  => ''
+                 }
+               );
+        my $tadv=0;
+        if (&allowed('adv') eq 'F') { $tadv=1; }
+        &appenv({'request.role.adv'    => $tadv});
+    }
 }
 
 # --------------------------------------------------------------- get interface