--- loncom/interface/lonmeta.pm 2006/08/16 18:06:47 1.170
+++ loncom/interface/lonmeta.pm 2006/09/25 19:24:49 1.178
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.170 2006/08/16 18:06:47 banghart Exp $
+# $Id: lonmeta.pm,v 1.178 2006/09/25 19:24:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -237,12 +237,6 @@ sub fieldnames {
if (! defined($file_type) || $file_type ne 'portfolio') {
%fields =
- (%fields,
- 'courserestricted' => 'Course Restricting Metadata');
- }
-
- if (! defined($file_type) || $file_type ne 'portfolio') {
- %fields =
(%fields,
'domain' => 'Domain',
'mime' => 'MIME Type',
@@ -607,9 +601,11 @@ sub prettyinput {
return (&select_course());
# return ('');
}
+ my $course = $env{'request.course.id'};
if (($type eq 'keywords') || ($type eq 'subject')
|| ($type eq 'author')||($type eq 'notes')
- || ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')) {
+ || ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')
+ || (exists($env{'course.'.$env{'request.course.id'}.'.metadata.'.$type.'.added'}))) {
if ($values) {
if ($only_one) {
$output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options));
@@ -624,7 +620,7 @@ sub prettyinput {
$relatedvalue);
}
return ($output);
- }
+ }
if (($type eq 'lowestgradelevel') ||
($type eq 'highestgradelevel')) {
return &Apache::loncommon::select_level_form($value,$fieldname).
@@ -719,7 +715,6 @@ sub prettyinput {
# Main Handler
sub handler {
my $r=shift;
- #
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['currentpath']);
my $uri=$r->uri;
@@ -728,7 +723,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/(.*)$:) {
@@ -746,6 +740,11 @@ 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',
@@ -1106,7 +1105,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;
@@ -1185,10 +1184,20 @@ ENDEDIT
my %lt=&fieldnames($file_type);
my $output;
my @fields;
- if ($file_type eq 'portfolio') {
- @fields = ('author','title','subject','keywords','abstract',
- 'notes','lowestgradelevel',
- 'highestgradelevel','standards');
+ my $added_metadata_fields;
+ if ($file_type eq 'portfolio' || $file_type eq 'groups') {
+ if(exists ($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'})) {
+ # retrieve fieldnames (in order) from the course restricted list
+ @fields = (split /,/,$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'});
+ } else {
+ # no saved field list, use default list
+ @fields = ('author','title','subject','keywords','abstract',
+ 'notes','lowestgradelevel',
+ 'highestgradelevel','standards');
+ $added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames();
+
+ $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join (",",@fields);
+ }
} else {
@fields = ('author','title','subject','keywords','abstract','notes',
'copyright','customdistributionfile','language',
@@ -1196,8 +1205,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'}) {
@@ -1208,7 +1221,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+)$/ );
@@ -1225,8 +1238,13 @@ ENDEDIT
$r->print("This resource is not associated with a course.
");
}
}
+ foreach my $field_name(keys (%$added_metadata_fields)) {
+ push (@fields,$field_name);
+ $Apache::lonpublisher::metadatafields{$field_name} =
+ $$added_metadata_fields{$field_name};
+ $lt{$field_name} = $$added_metadata_fields{$field_name};
+ }
foreach my $field_name (@fields) {
-
if (defined($env{'form.new_'.$field_name})) {
$Apache::lonpublisher::metadatafields{$field_name}=
join(',',&Apache::loncommon::get_env_multiple('form.new_'.$field_name));
@@ -1260,22 +1278,20 @@ ENDEDIT
$Apache::lonpublisher::metadatafields{'keywords'} =
join (',', &Apache::loncommon::get_env_multiple('form.new_keywords'));
}
-
- foreach (sort keys %Apache::lonpublisher::metadatafields) {
- next if ($_ =~ /\./);
- my $unikey=$_;
- $unikey=~/^([A-Za-z]+)/;
+ foreach my $field (sort keys %Apache::lonpublisher::metadatafields) {
+ next if ($field =~ /\./);
+ my $unikey=$field;
+ $unikey=~/^([A-Za-z_]+)/;
my $tag=$1;
$tag=~tr/A-Z/a-z/;
$file_content.= "\n\<$tag";
- foreach (split(/\,/,
+ foreach my $key (split(/\,/,
$Apache::lonpublisher::metadatakeys{$unikey})
) {
my $value=
- $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
+ $Apache::lonpublisher::metadatafields{$unikey.'.'.$key};
$value=~s/\"/\'\'/g;
- $file_content.=' '.$_.'="'.$value.'"' ;
- # print $mfh ' '.$_.'="'.$value.'"';
+ $file_content.=' '.$key.'="'.$value.'"' ;
}
$file_content.= '>'.
&HTML::Entities::encode
@@ -1283,22 +1299,16 @@ ENDEDIT
'<>&"').
''.$tag.'>';
}
- 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));
- unless ($env{'form.associate'}) {
- $r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio'));
- return;
- }
- } 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));
- unless ($env{'form.associate'}) {
- $r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio'));
- return;
- }
- } else {
+ } else {
if (! ($mfh=Apache::File->new('>'.$fn))) {
$r->print('
'. &mt('Could not write metadata').', '. @@ -1309,13 +1319,8 @@ ENDEDIT ' '.&Apache::lonlocal::locallocaltime(time). '
'); } - unless ($env{'form.associate'}) { - $r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio')); - return; - } } } - $r->print($output.'