--- loncom/lonnet/perl/lonnet.pm 2005/04/22 21:01:25 1.628 +++ loncom/lonnet/perl/lonnet.pm 2005/04/25 17:18:15 1.629 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.628 2005/04/22 21:01:25 albertel Exp $ +# $Id: lonnet.pm,v 1.629 2005/04/25 17:18:15 banghart Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3757,7 +3757,6 @@ sub mark_as_readonly { my %current_permissions = &dump('file_permissions',$domain,$user); my ($tmp)=keys(%current_permissions); if ($tmp=~/^error:/) { undef(%current_permissions); } - foreach my $file (@{$files}) { push(@{$current_permissions{$file}},$what); } @@ -3836,17 +3835,21 @@ sub files_not_in_path { #--------------------------------------------------------------Get Marked as Read Only + sub get_marked_as_readonly { my ($domain,$user,$what) = @_; my %current_permissions = &dump('file_permissions',$domain,$user); my ($tmp)=keys(%current_permissions); if ($tmp=~/^error:/) { undef(%current_permissions); } - my @readonly_files; + my $cmp1=$what; + if (ref($what)) { $cmp1=join('',@{$what}) }; while (my ($file_name,$value) = each(%current_permissions)) { if (ref($value) eq "ARRAY"){ foreach my $stored_what (@{$value}) { - if ($stored_what eq $what) { + my $cmp2=$stored_what; + if (ref($stored_what)) { $cmp2=join('',@{$stored_what}) }; + if ($cmp1 eq $cmp2) { push(@readonly_files, $file_name); } elsif (!defined($what)) { push(@readonly_files, $file_name); @@ -3881,13 +3884,13 @@ sub get_marked_as_readonly_hash { # ------------------------------------------------------------ Unmark as Read Only sub unmark_as_readonly { - # unmarks all files locked by $what - # for portfolio submissions, $what contains $crsid and $symb - my ($domain,$user,$what) = @_; + # unmarks $file_name (if $file_name is defined), or all files locked by $what + # for portfolio submissions, $what contains [$symb,$crsid] + my ($domain,$user,$what,$file_name) = @_; + my $symb_crs = join('',@$what); my %current_permissions = &dump('file_permissions',$domain,$user); my ($tmp)=keys(%current_permissions); if ($tmp=~/^error:/) { undef(%current_permissions); } - my @readonly_files = &get_marked_as_readonly($domain,$user,$what); foreach my $file(@readonly_files){ my $current_locks = $current_permissions{$file}; @@ -3895,7 +3898,12 @@ sub unmark_as_readonly { my @del_keys; if (ref($current_locks) eq "ARRAY"){ foreach my $locker (@{$current_locks}) { - unless ($locker eq $what) { + &logthis("$$locker[0].$$locker[1] eq $symb_crs"); + if ($$locker[0].$$locker[1] eq $symb_crs) { + if (defined($file_name) && ($file_name ne $file)) { + push(@new_locks, $what); + } + } else { push(@new_locks, $what); } } @@ -5324,6 +5332,7 @@ sub receipt { sub getfile { my ($file) = @_; + &Apache::lonnet::logthis("file name is $file"); if ($file =~ m -^/*(uploaded|editupload)/-) { $file=&filelocation("",$file); } &repcopy($file); return &readfile($file);