Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.1172.2.146.2.22 and 1.1172.2.146.2.23

version 1.1172.2.146.2.22, 2024/08/25 17:44:07 version 1.1172.2.146.2.23, 2024/08/25 22:26:12
Line 2540  sub get_domain_defaults { Line 2540  sub get_domain_defaults {
         } else {          } else {
             $domdefaults{'defaultquota'} = $domconfig{'quotas'};              $domdefaults{'defaultquota'} = $domconfig{'quotas'};
         }          }
         my @usertools = ('aboutme','blog','webdav','portfolio');          my @usertools = ('aboutme','blog','webdav','portfolio','portaccess');
         foreach my $item (@usertools) {          foreach my $item (@usertools) {
             if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {              if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {
                 $domdefaults{$item} = $domconfig{'quotas'}{$item};                  $domdefaults{$item} = $domconfig{'quotas'}{$item};
Line 2556  sub get_domain_defaults { Line 2556  sub get_domain_defaults {
         }          }
     }      }
     if (ref($domconfig{'authordefaults'}) eq 'HASH') {      if (ref($domconfig{'authordefaults'}) eq 'HASH') {
         foreach my $item ('nocodemirror','copyright','sourceavail','domcoordacc','editors') {          foreach my $item ('nocodemirror','copyright','sourceavail','domcoordacc','editors','archive') {
             if ($item eq 'editors') {              if ($item eq 'editors') {
                 if (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') {                  if (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') {
                     $domdefaults{$item} = join(',',@{$domconfig{'authordefaults'}{'editors'}});                      $domdefaults{$item} = join(',',@{$domconfig{'authordefaults'}{'editors'}});
Line 5305  sub coauthorrolelog { Line 5305  sub coauthorrolelog {
     return;      return;
 }  }
   
   sub authorarchivelog {
       my ($hashref,$size,$filesdest,$action) = @_;
       my $lonprtdir = $Apache::lonnet::perlvar{'lonPrtDir'};
       my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
       $filesdest =~ s{^\Q$lonprtdir/\E}{};
       if ($filesdest =~ m{^($match_username)_($match_domain)_archive_(\d+_\d+_\d+(|[.\w]+))$}) {
           my ($auname,$audom,$id) = ($1,$2,$3);
           if (ref($hashref) eq 'HASH') {
               my $namespace = 'archivelog';
               my $dir;
               if ($hashref->{dir} =~ m{^\Q$londocroot/priv/$audom/$auname\E(.*)$}) {
                   $dir = $1;
               }
               my $delflag = 0;
               my %storehash = (
                                 id      => $id,
                                 dir     => $dir,
                                 files   => $hashref->{numfiles},
                                 subdirs => $hashref->{numdirs},
                                 bytes   => $hashref->{bytes},
                                 size    => $size,
                                 action  => $action,
                               );
               if ($action eq 'delete') {
                   $delflag = 1;
               }
               &write_log('author',$namespace,\%storehash,$delflag,$auname,
                          $audom,$auname,$audom);
           }
       }
       return;
   }
   
 sub get_course_adv_roles {  sub get_course_adv_roles {
     my ($cid,$codes) = @_;      my ($cid,$codes) = @_;
     $cid=$env{'request.course.id'} unless (defined($cid));      $cid=$env{'request.course.id'} unless (defined($cid));
Line 7784  sub portfolio_access { Line 7817  sub portfolio_access {
 }  }
   
 sub get_portfolio_access {  sub get_portfolio_access {
     my ($udom,$unum,$file_name,$group,$clientip,$access_hash) = @_;      my ($udom,$unum,$file_name,$group,$clientip,$access_hash,$portaccessref) = @_;
   
     if (!ref($access_hash)) {      if (!ref($access_hash)) {
  my $current_perms = &get_portfile_permissions($udom,$unum);   my $current_perms = &get_portfile_permissions($udom,$unum);
Line 7793  sub get_portfolio_access { Line 7826  sub get_portfolio_access {
  $access_hash = $access_controls{$file_name};   $access_hash = $access_controls{$file_name};
     }      }
   
     my ($public,$guest,@domains,@users,@courses,@groups,@ips);      my $portaccess;
       if (ref($portaccess) eq 'SCALAR') {
           $portaccess = $$portaccessref;
       } else {
           $portaccess = &usertools_access($unum,$udom,'portaccess',undef,'tools');
       }
   
       my ($public,$guest,@domains,@users,@courses,@groups,@ips,@userips);
     my $now = time;      my $now = time;
     if (ref($access_hash) eq 'HASH') {      if (ref($access_hash) eq 'HASH') {
         foreach my $key (keys(%{$access_hash})) {          foreach my $key (keys(%{$access_hash})) {
             my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);              my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
               next if (($scope ne 'ip') && ($portaccess == 0));
             if ($start > $now) {              if ($start > $now) {
                 next;                  next;
             }              }
Line 7819  sub get_portfolio_access { Line 7860  sub get_portfolio_access {
                 push(@groups,$key);                  push(@groups,$key);
             } elsif ($scope eq 'ip') {              } elsif ($scope eq 'ip') {
                 push(@ips,$key);                  push(@ips,$key);
               } elsif ($scope eq 'userip') {
                   push(@userips,$key);
             }              }
         }          }
         if ($public) {          if ($public) {
Line 7831  sub get_portfolio_access { Line 7874  sub get_portfolio_access {
                         $allowed = 1;                          $allowed = 1;
                         last;                          last;
                     }                      }
                   }
               }
               if ($allowed) {
                   return 'ok';
               }
           } elsif (@userips > 0) {
               my $allowed;
               foreach my $useripkey (@userips) {
                   if (ref($access_hash->{$useripkey}{'ip'}) eq 'ARRAY') {
                       if (&Apache::loncommon::check_ip_acc(join(',',@{$access_hash->{$useripkey}{'ip'}}),$clientip)) {
                           $allowed = 1;
                           last;
                       }
                 }                  }
             }              }
             if ($allowed) {              if ($allowed) {

Removed from v.1.1172.2.146.2.22  
changed lines
  Added in v.1.1172.2.146.2.23


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