version 1.1519, 2023/11/18 14:33:07
|
version 1.1528, 2024/06/14 18:49:42
|
Line 188 sub create_connection {
|
Line 188 sub create_connection {
|
Type => SOCK_STREAM, |
Type => SOCK_STREAM, |
Timeout => 10); |
Timeout => 10); |
return 0 if (!$client); |
return 0 if (!$client); |
print $client (join(':',$hostname,$lonid,&machine_ids($hostname),$loncaparevs{$lonid})."\n"); |
if ($loncaparevs{$lonid} =~ /^(\d+\.\d+\.[\w.]+)-\d+$/) { |
|
print $client (join(':',$hostname,$lonid,$1,&machine_ids($hostname))."\n"); |
|
} else { |
|
print $client (join(':',$hostname,$lonid,&machine_ids($hostname))."\n"); |
|
} |
my $result = <$client>; |
my $result = <$client>; |
chomp($result); |
chomp($result); |
return 1 if ($result eq 'done'); |
return 1 if ($result eq 'done'); |
Line 2757 sub get_domain_defaults {
|
Line 2761 sub get_domain_defaults {
|
'selfenrollment','coursecategories', |
'selfenrollment','coursecategories', |
'ssl','autoenroll','trust', |
'ssl','autoenroll','trust', |
'helpsettings','wafproxy', |
'helpsettings','wafproxy', |
'ltisec','toolsec','domexttool', |
'ltisec','toolsec','privacy'],$domain); |
'exttool','privacy'],$domain); |
|
my @coursetypes = ('official','unofficial','community','textbook','placement'); |
my @coursetypes = ('official','unofficial','community','textbook','placement'); |
if (ref($domconfig{'defaults'}) eq 'HASH') { |
if (ref($domconfig{'defaults'}) eq 'HASH') { |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
Line 2784 sub get_domain_defaults {
|
Line 2787 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 2803 sub get_domain_defaults {
|
Line 2806 sub get_domain_defaults {
|
$domdefaults{'requestauthor'} = $domconfig{'requestauthor'}; |
$domdefaults{'requestauthor'} = $domconfig{'requestauthor'}; |
} |
} |
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 2854 sub get_domain_defaults {
|
Line 2857 sub get_domain_defaults {
|
} else { |
} else { |
$domdefaults{$type.'exttool'} = 0; |
$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'}{'crseditors'}) eq 'ARRAY') { |
|
$domdefaults{'crseditors'}=join(',',@{$domconfig{'coursedefaults'}{'crseditors'}}); |
|
} |
} |
} |
if (ref($domconfig{'coursedefaults'}{'canclone'}) eq 'HASH') { |
if (ref($domconfig{'coursedefaults'}{'canclone'}) eq 'HASH') { |
if (ref($domconfig{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') { |
if (ref($domconfig{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') { |
Line 2971 sub get_domain_defaults {
|
Line 2982 sub get_domain_defaults {
|
$domdefaults{'ltiprivhosts'} = $domconfig{'ltisec'}{'private'}{'keys'}; |
$domdefaults{'ltiprivhosts'} = $domconfig{'ltisec'}{'private'}{'keys'}; |
} |
} |
} |
} |
|
if (ref($domconfig{'ltisec'}{'suggested'}) eq 'HASH') { |
|
my %suggestions = %{$domconfig{'ltisec'}{'suggested'}}; |
|
foreach my $item (keys(%{$domconfig{'ltisec'}{'suggested'}})) { |
|
unless (ref($domconfig{'ltisec'}{'suggested'}{$item}) eq 'HASH') { |
|
delete($suggestions{$item}); |
|
} |
|
} |
|
if (keys(%suggestions)) { |
|
$domdefaults{'linkprotsuggested'} = \%suggestions; |
|
} |
|
} |
} |
} |
if (ref($domconfig{'toolsec'}) eq 'HASH') { |
if (ref($domconfig{'toolsec'}) eq 'HASH') { |
if (ref($domconfig{'toolsec'}{'encrypt'}) eq 'HASH') { |
if (ref($domconfig{'toolsec'}{'encrypt'}) eq 'HASH') { |
Line 5605 sub coauthorrolelog {
|
Line 5627 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 6994 sub rolesinit {
|
Line 7049 sub rolesinit {
|
my %allroles=(); |
my %allroles=(); |
my %allgroups=(); |
my %allgroups=(); |
my %gotcoauconfig=(); |
my %gotcoauconfig=(); |
|
my %domdefaults=(); |
|
|
for my $area (grep { ! /^rolesdef_/ } keys(%rolesdump)) { |
for my $area (grep { ! /^rolesdef_/ } keys(%rolesdump)) { |
my $role = $rolesdump{$area}; |
my $role = $rolesdump{$area}; |
Line 7056 sub rolesinit {
|
Line 7112 sub rolesinit {
|
my $name = $item; |
my $name = $item; |
if ($item eq 'authoreditors') { |
if ($item eq 'authoreditors') { |
$name = 'editors'; |
$name = 'editors'; |
|
unless ($info{'authoreditors'}) { |
|
my %domdefs; |
|
if (ref($domdefaults{$audom}) eq 'HASH') { |
|
%domdefs = %{$domdefaults{$audom}}; |
|
} else { |
|
%domdefs = &get_domain_defaults($audom); |
|
$domdefaults{$audom} = \%domdefs; |
|
} |
|
if ($domdefs{$name} ne '') { |
|
$info{'authoreditors'} = $domdefs{$name}; |
|
} else { |
|
$info{'authoreditors'} = 'edit,xml'; |
|
} |
|
} |
} |
} |
$coauthorenv{"environment.internal.$name.$area"} = $info{$item}; |
$coauthorenv{"environment.internal.$name.$area"} = $info{$item}; |
} |
} |
Line 7984 sub portfolio_access {
|
Line 8054 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 7993 sub get_portfolio_access {
|
Line 8063 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 8019 sub get_portfolio_access {
|
Line 8097 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 8036 sub get_portfolio_access {
|
Line 8116 sub get_portfolio_access {
|
if ($allowed) { |
if ($allowed) { |
return 'ok'; |
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 ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { |
if ($guest) { |
if ($guest) { |
Line 8249 sub usertools_access {
|
Line 8342 sub usertools_access {
|
%tools = ( |
%tools = ( |
aboutme => 1, |
aboutme => 1, |
blog => 1, |
blog => 1, |
|
webdav => 1, |
portfolio => 1, |
portfolio => 1, |
portaccess => 1, |
portaccess => 1, |
timezone => 1, |
timezone => 1, |
Line 9216 sub constructaccess {
|
Line 9310 sub constructaccess {
|
if (($ownername eq $env{'course.'.$env{'request.course.id'}.'.num'}) && |
if (($ownername eq $env{'course.'.$env{'request.course.id'}.'.num'}) && |
($ownerdomain eq $env{'course.'.$env{'request.course.id'}.'.domain'})) { |
($ownerdomain eq $env{'course.'.$env{'request.course.id'}.'.domain'})) { |
if (&allowed('mdc',$env{'request.course.id'})) { |
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'}; |
$ownerhome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
return ($ownername,$ownerdomain,$ownerhome); |
return ($ownername,$ownerdomain,$ownerhome); |
} |
} |