--- loncom/interface/lonmeta.pm 2006/08/04 22:16:38 1.164 +++ loncom/interface/lonmeta.pm 2006/08/28 00:19:38 1.168.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.164 2006/08/04 22:16:38 albertel Exp $ +# $Id: lonmeta.pm,v 1.168.2.3 2006/08/28 00:19:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -287,15 +287,22 @@ sub portfolio_linked_path { if ($group) { $start = "groups/$group/".$start; } - my $result = &Apache::portfolio::make_anchor($port_path,$start,'/'); - + my %anchor_fields = ( + 'selectfile' => $start, + 'currentpath' => '/' + ); + my $result = &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$start); my $fullpath = '/'; my (undef,@tree) = split('/',$path); my $filename = pop(@tree); foreach my $dir (@tree) { $fullpath .= $dir.'/'; $result .= '/'; - $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath); + my %anchor_fields = ( + 'selectfile' => $dir, + 'currentpath' => $fullpath + ); + $result .= &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$dir); } $result .= "/$filename"; return $result; @@ -358,14 +365,18 @@ sub pre_select_course { $r->print('

'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'',''.$res_uri.'').'

'); $output = &select_course(); $r->print($output.'
'); + &mt('Associate Resource With Selected Course').'" />'); $r->print(''); my ($port_path,$group) = &get_port_path_and_group($uri); - $r->print('

'. + my $group_input; + if ($group) { + $group_input = ''; + } + $r->print('

'. ''. - ''. - ''. + $group_input. + ''. '
'); return; @@ -713,7 +724,6 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; - # my ($resdomain,$resuser)= (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); if ($uri=~m:/adm/bombs/(.*)$:) { @@ -731,6 +741,12 @@ sub handler { } else { &pre_select_course($r,$uri); } + } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/groups/|) { + $r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information', + undef, + {'domain' => $resdomain,})); + + &present_editable_metadata($r,$uri,'groups'); } elsif ($uri=~m|^/~|) { # Construction space $r->print(&Apache::loncommon::start_page('Edit Catalog nformation', @@ -1091,7 +1107,7 @@ sub print_dynamic_metadata { ##################################################### ##################################################### sub present_editable_metadata { - my ($r,$uri, $file_type) = @_; + my ($r,$uri,$file_type) = @_; # Construction Space Call # Header my $disuri=$uri; @@ -1181,8 +1197,12 @@ ENDEDIT 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', 'obsolete','obsoletereplacement'); } + if ($file_type eq 'groups') { + $Apache::lonpublisher::metadatafields{'courserestricted'}= + 'course.'.$env{'request.course.id'}; + } if ((! $Apache::lonpublisher::metadatafields{'courserestricted'}) && - (! $env{'form.new_courserestricted'})) { + (! $env{'form.new_courserestricted'}) && (! $file_type eq 'groups')) { $Apache::lonpublisher::metadatafields{'courserestricted'}= 'none'; } elsif ($env{'form.new_courserestricted'}) { @@ -1193,7 +1213,7 @@ ENDEDIT $Apache::lonpublisher::metadatafields{'copyright'}= 'default'; } - if ($file_type eq 'portfolio') { + if (($file_type eq 'portfolio') || ($file_type eq 'groups')) { if (! $Apache::lonpublisher::metadatafields{'mime'}) { ($Apache::lonpublisher::metadatafields{'mime'}) = ( $target=~/\.(\w+)$/ ); @@ -1268,14 +1288,16 @@ ENDEDIT '<>&"'). ''; } - if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) { - my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); + if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles|) { + my ($path, $new_fn); + if ($fn =~ m|\w+/groups/\w+/portfolio/|) { + ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); + } else { + ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); + } $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 { + } else { if (! ($mfh=Apache::File->new('>'.$fn))) { $r->print('

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