--- loncom/lonnet/perl/lonnet.pm 2024/05/01 12:06:25 1.1526 +++ loncom/lonnet/perl/lonnet.pm 2024/11/21 07:26:02 1.1530 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1526 2024/05/01 12:06:25 raeburn Exp $ +# $Id: lonnet.pm,v 1.1530 2024/11/21 07:26:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -188,7 +188,11 @@ sub create_connection { Type => SOCK_STREAM, Timeout => 10); 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>; chomp($result); return 1 if ($result eq 'done'); @@ -2802,7 +2806,7 @@ sub get_domain_defaults { $domdefaults{'requestauthor'} = $domconfig{'requestauthor'}; } 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 (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') { $domdefaults{$item} = join(',',@{$domconfig{'authordefaults'}{'editors'}}); @@ -2825,6 +2829,9 @@ sub get_domain_defaults { if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { $domdefaults{'postsubmit'} = $domconfig{'coursedefaults'}{'postsubmit'}{'client'}; } + if (ref($domconfig{'coursedefaults'}{'crseditors'}) eq 'ARRAY') { + $domdefaults{'crseditors'}=join(',',@{$domconfig{'coursedefaults'}{'crseditors'}}); + } foreach my $type (@coursetypes) { if (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') { unless ($type eq 'community') { @@ -2858,9 +2865,6 @@ sub get_domain_defaults { } 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'}{'instcode'}) eq 'ARRAY') { @@ -5623,6 +5627,39 @@ sub coauthorrolelog { 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 { my ($cid,$codes) = @_; $cid=$env{'request.course.id'} unless (defined($cid)); @@ -6712,18 +6749,22 @@ sub store { # -------------------------------------------------------------- Critical Store sub cstore { - my ($storehash,$symb,$namespace,$domain,$stuname,$laststore) = @_; + my ($storehash,$symb,$namespace,$domain,$stuname,$laststore,$ip,$nolog) = @_; my $home=''; if ($stuname) { $home=&homeserver($stuname,$domain); } - $symb=&symbclean($symb); + unless (($symb eq '_feedback') || ($symb eq '_discussion')) { + $symb=&symbclean($symb); + } if (!$symb) { unless ($symb=&symbread()) { return ''; } } if (!$domain) { $domain=$env{'user.domain'}; } if (!$stuname) { $stuname=$env{'user.name'}; } - &devalidate($symb,$stuname,$domain); + unless (($symb eq '_feedback') || ($symb eq '_discussion')) { + &devalidate($symb,$stuname,$domain); + } $symb=escape($symb); if (!$namespace) { @@ -6733,7 +6774,11 @@ sub cstore { } if (!$home) { $home=$env{'user.home'}; } - $$storehash{'ip'}=&get_requestor_ip(); + if ($ip ne '') { + $$storehash{'ip'} = $ip; + } else { + $$storehash{'ip'} = &get_requestor_ip(); + } $$storehash{'host'}=$perlvar{'lonHostID'}; my $namevalue=''; @@ -6741,7 +6786,9 @@ sub cstore { $namevalue.=&escape($key).'='.&freeze_escape($$storehash{$key}).'&'; } $namevalue=~s/\&$//; - &courselog($symb.':'.$stuname.':'.$domain.':CSTORE:'.$namevalue); + unless ($nolog) { + &courselog($symb.':'.$stuname.':'.$domain.':CSTORE:'.$namevalue); + } return critical ("store:$domain:$stuname:$namespace:$symb:$namevalue:$laststore","$home"); }