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

raeburn raeburn@source.lon-capa.org
Thu, 24 Feb 2011 23:42:19 -0000


raeburn		Thu Feb 24 23:42:19 2011 EDT

  Modified files:              
    /loncom/auth	loncacc.pm 
  Log:
  - Bug 5932. Roles Screen usability improvements
    - When checking for DC access, or adhoc CA provs for DCs,
      use time of last role update check instead of log-in time.
  
  
Index: loncom/auth/loncacc.pm
diff -u loncom/auth/loncacc.pm:1.51 loncom/auth/loncacc.pm:1.52
--- loncom/auth/loncacc.pm:1.51	Thu Sep 30 16:42:30 2010
+++ loncom/auth/loncacc.pm	Thu Feb 24 23:42:18 2011
@@ -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.51 2010/09/30 16:42:30 raeburn Exp $
+# $Id: loncacc.pm,v 1.52 2011/02/24 23:42:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -119,8 +119,12 @@
     }
 
     my $then=$env{'user.login.time'};
+    my $update==$env{'user.updateroles.time'};
+    if (!$update) {
+        $update = $then;
+    }
     my %dcroles = ();
-    if (&is_active_dc($ownerdomain,$then)) {
+    if (&is_active_dc($ownerdomain,$update)) {
         my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],
                                          $ownerdomain,$ownername);
         unless ($blocked{'domcoord.author'} eq 'blocked') {
@@ -128,11 +132,11 @@
                 if ($setpriv) {
                     my $refresh=$env{'user.refresh.time'};
                     if (!$refresh) {
-                        $refresh = $then;
+                        $refresh = $update;
                     }
                     my $now = time;
                     &Apache::lonnet::check_adhoc_privs($ownerdomain,$ownername,
-                                                       $then,$refresh,$now,'ca',
+                                                       $update,$refresh,$now,'ca',
                                                        'constructaccess');
                 }
                 return($ownername,$ownerdomain);
@@ -143,15 +147,15 @@
 }
 
 sub is_active_dc {
-    my ($ownerdomain,$then) = @_;
+    my ($ownerdomain,$update) = @_;
     my $livedc;
     if ($env{'user.adv'}) {
         my $domrole = $env{'user.role.dc./'.$ownerdomain.'/'};
         if ($domrole) {
             my ($tstart,$tend)=split(/\./,$domrole);
             $livedc = 1;
-            if ($tstart && $tstart>$then) { undef($livedc); }
-            if ($tend   && $tend  <$then) { undef($livedc); }
+            if ($tstart && $tstart>$update) { undef($livedc); }
+            if ($tend   && $tend  <$update) { undef($livedc); }
         }
     }
     return $livedc;