--- loncom/lonnet/perl/lonnet.pm 2023/11/18 14:33:07 1.1519 +++ loncom/lonnet/perl/lonnet.pm 2023/12/28 18:14:09 1.1522 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1519 2023/11/18 14:33:07 raeburn Exp $ +# $Id: lonnet.pm,v 1.1522 2023/12/28 18:14:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2757,8 +2757,7 @@ sub get_domain_defaults { 'selfenrollment','coursecategories', 'ssl','autoenroll','trust', 'helpsettings','wafproxy', - 'ltisec','toolsec','domexttool', - 'exttool','privacy'],$domain); + 'ltisec','toolsec','privacy'],$domain); my @coursetypes = ('official','unofficial','community','textbook','placement'); if (ref($domconfig{'defaults'}) eq 'HASH') { $domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; @@ -2784,7 +2783,7 @@ sub get_domain_defaults { } else { $domdefaults{'defaultquota'} = $domconfig{'quotas'}; } - my @usertools = ('aboutme','blog','webdav','portfolio'); + my @usertools = ('aboutme','blog','webdav','portfolio','portaccess'); foreach my $item (@usertools) { if (ref($domconfig{'quotas'}{$item}) eq 'HASH') { $domdefaults{$item} = $domconfig{'quotas'}{$item}; @@ -2854,6 +2853,11 @@ sub get_domain_defaults { } else { $domdefaults{$type.'exttool'} = 0; } + if (ref($domconfig{'coursedefaults'}{'crsauthor'}) eq 'HASH') { + $domdefaults{$type.'crsauthor'} = $domconfig{'coursedefaults'}{'crsauthor'}{$type}; + } else { + $domdefaults{$type.'crsauthor'} = 1; + } } if (ref($domconfig{'coursedefaults'}{'canclone'}) eq 'HASH') { if (ref($domconfig{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') { @@ -7984,7 +7988,7 @@ sub 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)) { my $current_perms = &get_portfile_permissions($udom,$unum); @@ -7993,11 +7997,19 @@ sub get_portfolio_access { $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; if (ref($access_hash) eq 'HASH') { foreach my $key (keys(%{$access_hash})) { my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); + next if (($scope ne 'ip') && ($portaccess == 0)); if ($start > $now) { next; } @@ -8019,6 +8031,8 @@ sub get_portfolio_access { push(@groups,$key); } elsif ($scope eq 'ip') { push(@ips,$key); + } elsif ($scope eq 'userip') { + push(@userips,$key); } } if ($public) { @@ -8036,6 +8050,19 @@ sub get_portfolio_access { 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) { + return 'ok'; + } } if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { if ($guest) { @@ -9216,6 +9243,22 @@ sub constructaccess { if (($ownername eq $env{'course.'.$env{'request.course.id'}.'.num'}) && ($ownerdomain eq $env{'course.'.$env{'request.course.id'}.'.domain'})) { if (&allowed('mdc',$env{'request.course.id'})) { + return if ($env{'course.'.$env{'request.course.id'}.'.internal.crsauthor'} eq '0'); + unless ($env{'course.'.$env{'request.course.id'}.'.internal.crsauthor'}) { + my %domdefs = &get_domain_defaults($ownerdomain); + my $type = lc($env{'course.'.$env{'request.course.id'}.'.type'}); + unless (($type eq 'community') || ($type eq 'placement')) { + $type = 'unofficial'; + if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'} ne '') { + $type = 'official'; + } elsif ($env{'course.'.$env{'request.course.id'}.'internal.textbook'} ne '') { + $type = 'textbook'; + } else { + $type = 'unofficial'; + } + } + return if ($domdefs{$type.'crsauthor'} eq '0'); + } $ownerhome = $env{'course.'.$env{'request.course.id'}.'.home'}; return ($ownername,$ownerdomain,$ownerhome); }