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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 21 Jul 2006 16:07:49 -0000


albertel		Fri Jul 21 12:07:49 2006 EDT

  Modified files:              
    /loncom/auth	lonacc.pm 
  Log:
  - reenabling acccess to portfiles when grading
  
  
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.87 loncom/auth/lonacc.pm:1.88
--- loncom/auth/lonacc.pm:1.87	Mon Jul 17 15:49:14 2006
+++ loncom/auth/lonacc.pm	Fri Jul 21 12:07:48 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.87 2006/07/17 19:49:14 albertel Exp $
+# $Id: lonacc.pm,v 1.88 2006/07/21 16:07:48 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -139,15 +139,21 @@
 
 sub portfolio_access {
     my ($r,$requrl) = @_;
+    my $access=&Apache::lonnet::allowed('bre',$requrl);
+    if ($access eq '2' || $access eq 'F') {
+	return OK;
+    }
     my (undef,$udom,$unum,$file_name,$group) = &parse_portfolio_url($requrl);
     my $result = &get_portfolio_access($udom,$unum,$file_name,$group);
+    &Apache::lonnet::logthis("got pa of $result");
     if ($result eq 'ok') {
 	return OK;
     } elsif ($result =~ /^[^:]+:guest_/) {
+	&Apache::lonnet::logthis("doign pac $result");
 	&passphrase_access_checker($r,$result,$requrl);
 	return OK;
     }
-    return FORBIDDEN;
+    return undef;
 }
 
 sub get_portfolio_access {
@@ -193,9 +199,8 @@
         } else {
             if (@domains > 0) {
                 foreach my $domkey (@domains) {
-                    my %content = &Apache::lonnet::parse_access_controls($$access_hash{$domkey});
-                    if (ref($content{'dom'}) eq 'ARRAY') {
-                        if (grep(/^\Q$env{'user.domain'}\E$/,@{$content{'dom'}})) {
+                    if (ref($access_hash->{$domkey}{'dom'}) eq 'ARRAY') {
+                        if (grep(/^\Q$env{'user.domain'}\E$/,@{$access_hash->{$domkey}{'dom'}})) {
                             return 'ok';
                         }
                     }
@@ -203,8 +208,7 @@
             }
             if (@users > 0) {
                 foreach my $userkey (@users) {
-                    my %content = &Apache::lonnet::parse_access_controls($$access_hash{$userkey});
-                    if (exists($content{'users'}{$env{'user.name'}.':'.$env{'user.domain'}})) {
+                    if (exists($access_hash->{$userkey}{'users'}{$env{'user.name'}.':'.$env{'user.domain'}})) {
                         return 'ok';
                     }
                 }
@@ -243,7 +247,7 @@
                     return;
                 }
                 foreach my $key (@courses_and_groups) {
-                    my %content = &Apache::lonnet::parse_access_controls($$access_hash{$key});
+                    my %content = %{$$access_hash{$key}};
                     my $cnum = $content{'number'};
                     my $cdom = $content{'domain'};
                     my $cid = $cdom.'_'.$cnum;
@@ -427,7 +431,8 @@
 # ---------------------------------------------------------------- Check access
             my $now = time;
 	    if (&is_portfolio_url($requrl)) {
-		return &portfolio_access($r,$requrl);
+		my $result = &portfolio_access($r,$requrl);
+		if (defined($result)) { return $result; }
 	    }
             if ($requrl!~/^\/adm|public|prtspool\//) {
 		my $access=&Apache::lonnet::allowed('bre',$requrl);
@@ -519,7 +524,7 @@
         } else { 
             $r->log_reason("Cookie $handle not valid", $r->filename); 
         }
-    }
+	}
 
 # -------------------------------------------- See if this is a public resource
     if ($requrl=~m|^/public/|
@@ -543,7 +548,8 @@
     }
 # ------------------------------------- See if this is a viewable portfolio file
     if (&is_portfolio_url($requrl)) {
-	return &portfolio_access($r,$requrl);
+	my $result = &portfolio_access($r,$requrl);
+	if (defined($result)) { return $result; }
     }
 
 # -------------------------------------------------------------- Not authorized