--- loncom/interface/lonmeta.pm 2006/11/04 01:50:31 1.186 +++ 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.186 2006/11/04 01:50:31 banghart Exp $ +# $Id: lonmeta.pm,v 1.192 2007/01/02 12:54:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,8 +39,7 @@ use Apache::lonpublisher; use Apache::lonlocal; use Apache::lonmysql; use Apache::lonmsg; -use lib '/home/httpd/lib/perl/'; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); ############################################################ @@ -63,7 +62,7 @@ use LONCAPA; ############################################################ sub get_dynamic_metadata_from_sql { my ($url) = shift(); - my ($authordom,$author)=($url=~m:^/res/(\w+)/(\w+)/:); + my ($authordom,$author)=($url=~m{^/res/($match_domain)/($match_username)/}); if (! defined($authordom)) { $authordom = shift(); } @@ -112,7 +111,7 @@ sub get_dynamic_metadata_from_sql { sub dynamicmeta { my $url=&Apache::lonnet::declutter(shift); $url=~s/\.meta$//; - my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//); + my ($adomain,$aauthor)=($url=~/^($match_domain)\/($match_username)\//); my $regexp=$url; $regexp=~s/(\W)/\\$1/g; $regexp='___'.$regexp.'___'; @@ -236,7 +235,7 @@ sub fieldnames { 'lowestgradelevel' => 'Lowest Grade Level', 'highestgradelevel' => 'Highest Grade Level'); - if (! defined($file_type) || $file_type ne 'portfolio') { + if ( !defined($file_type) || ($file_type ne 'portfolio' && $file_type ne 'groups') ) { %fields = (%fields, 'domain' => 'Domain', @@ -449,7 +448,7 @@ sub prettyprint { ($type eq 'owner') || ($type eq 'modifyinguser') || ($type eq 'authorspace')) { - $value=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse; + $value=~s/($match_username)(\:|\@)($match_domain)/&authordisplay($1,$3)/gse; return $value; } # Gradelevel @@ -724,7 +723,7 @@ sub prettyinput { sub handler { my $r=shift; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['currentpath']); + ['currentpath','changecourse']); my $uri=$r->uri; # # Set document type @@ -732,14 +731,14 @@ sub handler { $r->send_http_header; return OK if $r->header_only; my ($resdomain,$resuser)= - (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); + (&Apache::lonnet::declutter($uri)=~/^($match_domain)\/($match_username)\//); if ($uri=~m:/adm/bombs/(.*)$:) { $r->print(&Apache::loncommon::start_page('Error Messages')); # Looking for all bombs? &report_bombs($r,$uri); } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) { ($resdomain,$resuser)= - (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); + (&Apache::lonnet::declutter($uri)=~m|^($match_domain)/($match_name)/portfolio|); $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information', undef, {'domain' => $resdomain,})); @@ -752,7 +751,8 @@ sub handler { my $result=&Apache::lonnet::getfile($fn); &Apache::lonpublisher::metaeval($result); &Apache::lonnet::logthis("restricted is: ".$Apache::lonpublisher::metadatafields{'courserestricted'}); - if (!$Apache::lonpublisher::metadatafields{'courserestricted'}) { + if ((!$Apache::lonpublisher::metadatafields{'courserestricted'}) || + ($env{'form.changecourse'} eq 'true')) { &pre_select_course($r,$uri); } else { &present_editable_metadata($r,$uri,'portfolio'); @@ -792,7 +792,7 @@ sub report_bombs { $uri =~ s:/adm/bombs/::; $uri = &Apache::lonnet::declutter($uri); $r->print('
'.$lt{$field_name}.': '. + + $output .= "\n".&Apache::loncommon::start_data_table_row(); + $output .= ('
'.$lt{$field_name}.': '. + $output.=(&Apache::loncommon::start_data_table_row().'
'. @@ -1341,6 +1357,8 @@ ENDEDIT &mt('FAIL').'
'); } else { print $mfh ($file_content); + close($mfh); + &update_metadata_table($uri); $r->print(''.&mt('Wrote Metadata'). ' '.&Apache::lonlocal::locallocaltime(time). '
'); @@ -1350,16 +1368,16 @@ ENDEDIT $r->print($output.'