Diff for /loncom/auth/lonacc.pm between versions 1.77 and 1.79

version 1.77, 2006/04/13 20:47:39 version 1.79, 2006/06/16 22:37:29
Line 135  sub get_posted_cgi { Line 135  sub get_posted_cgi {
     $r->headers_in->unset('Content-length');      $r->headers_in->unset('Content-length');
 }  }
   
   sub portfolio_access {
       my ($udom,$unum,$file_name,$group) = @_;
       my $current_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum);
       my %access_controls = &Apache::lonnet::get_access_controls(
                                                $current_perms,$group,$file_name);
       my ($public);
       my $now = time;
       my $access_hash = $access_controls{$file_name};
       if (ref($access_hash) eq 'HASH') {
           foreach my $key (keys(%{$access_hash})) {
               my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
               if ($start > $now) {
                   next;
               }
               if ($end && $end<$now) {
                   next;
               }
               if ($scope eq 'public') {
                   $public = $key;
                   last;
               }
           }
           if ($public) {
               return 'ok';
           }
       }
       return;
   }
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
Line 150  sub handler { Line 178  sub handler {
         $handle=~s/\W//g;          $handle=~s/\W//g;
     }      }
               
       my ($sso_login);
     if ($r->user       if ($r->user 
  && (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq '') ) {   && (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq '') ) {
    $sso_login = 1;
  my $domain = $r->dir_config('lonDefDomain');   my $domain = $r->dir_config('lonDefDomain');
  my $home=&Apache::lonnet::homeserver($r->user,$domain);   my $home=&Apache::lonnet::homeserver($r->user,$domain);
  if ($home !~ /(con_lost|no_such_host)/) {   if ($home !~ /(con_lost|no_such_host)/) {
Line 161  sub handler { Line 191  sub handler {
  }   }
     }      }
   
       if ($sso_login) {
    &Apache::lonnet::appenv('request.sso.login' => 1);
       }
   
     if ($r->dir_config("lonBalancer") eq 'yes') {      if ($r->dir_config("lonBalancer") eq 'yes') {
  $r->set_handlers('PerlResponseHandler'=>   $r->set_handlers('PerlResponseHandler'=>
  [\&Apache::switchserver::handler]);   [\&Apache::switchserver::handler]);
Line 191  sub handler { Line 225  sub handler {
     &Apache::lonacc::get_posted_cgi($r);      &Apache::lonacc::get_posted_cgi($r);
   
 # ---------------------------------------------------------------- Check access  # ---------------------------------------------------------------- Check access
               my $now = time;
               if ($requrl =~ m#/+uploaded/([^/]+)/([^/]+)/portfolio(/.+)$#) {
                   my $result = &portfolio_access($1,$2,$3);
                   if ($result eq 'ok') {
                       return OK;
                   }
               } elsif ($requrl =~ m#/+uploaded/([^/]+)/([^/]+)/groups/([^/]+)/portfolio/(.+)$#) {
                   my $result = &portfolio_access($1,$2,$4.'/'.$3,$3);
                   if ($result eq 'ok') {
                       return OK;
                   }
               }
             if ($requrl!~/^\/adm|public|prtspool\//) {              if ($requrl!~/^\/adm|public|prtspool\//) {
  my $access=&Apache::lonnet::allowed('bre',$requrl);   my $access=&Apache::lonnet::allowed('bre',$requrl);
                 if ($access eq '1') {                  if ($access eq '1') {
Line 304  sub handler { Line 349  sub handler {
     if ($requrl=~m|^/+adm/+help/+|) {      if ($requrl=~m|^/+adm/+help/+|) {
  return OK;   return OK;
     }      }
   # ------------------------------------- See if this is a viewable portfolio file
       if ($requrl =~ m#/+uploaded/([^/]+)/([^/]+)/portfolio(/.+)$#) {
           my $result = &portfolio_access($1,$2,$3);
           if ($result eq 'ok') {
               return OK;
           }
       } elsif ($requrl =~ m#/+uploaded/([^/]+)/([^/]+)/groups/([^/]+)/portfolio/(.+)$#) {
           my $result = &portfolio_access($1,$2,$4.'/'.$3,$3);
           if ($result eq 'ok') {
               return OK;
           }
       }
 # -------------------------------------------------------------- Not authorized  # -------------------------------------------------------------- Not authorized
     $requrl=~/\.(\w+)$/;      $requrl=~/\.(\w+)$/;
 #    if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||  #    if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||

Removed from v.1.77  
changed lines
  Added in v.1.79


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>