--- loncom/interface/lonmeta.pm 2006/05/31 17:44:14 1.158 +++ loncom/interface/lonmeta.pm 2006/07/19 19:29:20 1.161 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.158 2006/05/31 17:44:14 www Exp $ +# $Id: lonmeta.pm,v 1.161 2006/07/19 19:29:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -287,8 +287,7 @@ sub portfolio_linked_path { if ($group) { $start = "groups/$group/".$start; } - my $result = &Apache::portfolio::make_anchor($port_path,$start,'/', - undef,undef,undef,$group); + my $result = &Apache::portfolio::make_anchor($port_path,$start,'/'); my $fullpath = '/'; my (undef,@tree) = split('/',$path); @@ -296,8 +295,7 @@ sub portfolio_linked_path { foreach my $dir (@tree) { $fullpath .= $dir.'/'; $result .= '/'; - $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath, - undef,undef,undef,$group); + $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath); } $result .= "/$filename"; return $result; @@ -316,6 +314,9 @@ sub get_port_path_and_group { } else { $port_path = '/adm/portfolio'; } + if ($env{'form.group'} ne $group) { + $env{'form.group'} = $group; + } return ($port_path,$group); } @@ -1247,22 +1248,13 @@ ENDEDIT '<>&"'). ''; } - if ($fn =~ m|/portfolio/|) { + if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) { my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); - $env{'form.'.$formname}=$file_content."\n"; - $env{'form.'.$formname.'.filename'}=$new_fn; - my $result =&Apache::lonnet::userfileupload($formname,'', - $path); - - if ($result =~ /(error|notfound)/) { - $r->print('

'. - &mt('Could not write metadata').', '. - &mt('FAIL').'

'); - } else { - $r->print('

'.&mt('Wrote Metadata'). - ' '.&Apache::lonlocal::locallocaltime(time). - '

'); - } + $r->print(&store_portfolio_metadata($formname,$file_content,$path, + $new_fn)); + } elsif ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) { + my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); + $r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn)); } else { if (! ($mfh=Apache::File->new('>'.$fn))) { $r->print('

'. @@ -1282,6 +1274,9 @@ ENDEDIT if ($file_type eq 'portfolio') { my ($port_path,$group) = &get_port_path_and_group($uri); + if ($group) { + $r->print(''); + } $r->print('

'. ''. @@ -1295,7 +1290,21 @@ ENDEDIT return; } +sub store_portfolio_metadata { + my ($formname,$content,$path,$new_fn) = @_; + $env{'form.'.$formname}=$content."\n"; + $env{'form.'.$formname.'.filename'}=$new_fn; + my $result =&Apache::lonnet::userfileupload($formname,'',$path); + if ($result =~ /(error|notfound)/) { + return '

'. + &mt('Could not write metadata').', '. + &mt('FAIL').'

'; + } else { + return '

'.&mt('Wrote Metadata'). + ' '.&Apache::lonlocal::locallocaltime(time).'

'; + } +} + 1; __END__ -