--- loncom/interface/lonmeta.pm 2007/01/02 11:38:28 1.191 +++ loncom/interface/lonmeta.pm 2007/01/02 12:54:40 1.192 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.191 2007/01/02 11:38:28 raeburn Exp $ +# $Id: lonmeta.pm,v 1.192 2007/01/02 12:54:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1349,7 +1349,7 @@ ENDEDIT ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); } $r->print(&store_portfolio_metadata($formname,$file_content,$path, - $new_fn)); + $new_fn,$uri)); } else { if (! ($mfh=Apache::File->new('>'.$fn))) { $r->print('
'.
@@ -1358,6 +1358,7 @@ ENDEDIT
} else {
print $mfh ($file_content);
close($mfh);
+ &update_metadata_table($uri);
$r->print(' '.&mt('Wrote Metadata').
' '.&Apache::lonlocal::locallocaltime(time).
'
'.&mt('Wrote Metadata'). ' '.&Apache::lonlocal::locallocaltime(time).'
'; } } +sub update_metadata_table { + my ($uri) = @_; + my ($group,$file_name); + my ($udom,$uname,$remainder) = + ($uri=~m -^/+(?:uploaded|editupload)/+($match_domain)/+($match_name)/+(.*)$-); + + if ($remainder =~ /groups\/(\w+)\/portfolio(\/.+)$/) { + $group = $1; + $file_name = $2; + } elsif ($remainder =~ /portfolio(\/.+)$/) { + $file_name = $1; + } + $file_name =~ s/\.meta$//; + my $current_permissions = + &Apache::lonnet::get_portfile_permissions($udom,$uname); + my %access_controls = + &Apache::lonnet::get_access_controls($current_permissions,$group, + $group.$file_name); + my $access_hash = $access_controls{$file_name}; + my $available = 0; + if (ref($access_hash) eq 'HASH') { + foreach my $key (keys(%{$access_hash})) { + my ($num,$scope,$end,$start) = + ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); + if ($scope eq 'public' || $scope eq 'guest') { + $available = 1; + last; + } + } + } + if ($available) { + my $result = + &Apache::lonnet::update_portfolio_table($uname,$udom, + $file_name,'portfolio_metadata',$group); + } +} + + 1; __END__