--- loncom/publisher/lonpublisher.pm 2005/05/19 03:22:04 1.194 +++ loncom/publisher/lonpublisher.pm 2005/05/30 16:56:46 1.196 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.194 2005/05/19 03:22:04 www Exp $ +# $Id: lonpublisher.pm,v 1.196 2005/05/30 16:56:46 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1020,7 +1020,7 @@ sub publish { } # ------------------------------------------------ First, check out environment - unless (-e $source.'.meta') { + if ((!(-e $source.'.meta')) || ($env{'form.forceoverride'})) { $metadatafields{'author'}=$env{'environment.firstname'}.' '. $env{'environment.middlename'}.' '. $env{'environment.lastname'}.' '. @@ -1070,10 +1070,18 @@ sub publish { delete $metadatafields{$_}; } } +# ------------------------------------------------------------- Save some stuff + my %savemeta=(); + foreach ('title') { + $savemeta{$_}=$metadatafields{$_}; + } # ------------------------------------------ See if anything new in file itself $allmeta=&parseformeta($source,$style); - +# ----------------------------------------------------------- Restore the stuff + foreach (keys %savemeta) { + $metadatafields{$_}=$savemeta{$_}; + } } @@ -1335,6 +1343,7 @@ END &hiddenfield('copyright',$metadatafields{'copyright'}). &hiddenfield('sourceavail',$metadatafields{'sourceavail'}). &hiddenfield('customdistributionfile',$metadatafields{'customdistributionfile'}). + &hiddenfield('obsolete',1). &text_with_browse_field('Suggested Replacement for Obsolete File', 'obsoletereplacement', $metadatafields{'obsoletereplacement'}); @@ -1389,13 +1398,29 @@ sub phasetwo { my ($r,$source,$target,$style,$distarget,$batch)=@_; $source=~s/\/+/\//g; $target=~s/\/+/\//g; - - if ($target=~/\_\_\_/) { - $r->print( - ''.&mt('Unsupported character combination'). - ' "___" '.&mt('in filename, FAIL').''); - return 0; +# +# Unless trying to get rid of something, check name validity +# + unless ($env{'form.obsolete'}) { + if ($target=~/(\_\_\_|\&\&\&|\:\:\:)/) { + $r->print( + ''.&mt('Unsupported character combination'). + ' "'.$1.'" '.&mt('in filename, FAIL').''); + return 0; + } + unless ($target=~/\.(\w+)$/) { + $r->print(''.&mt('No valid extension found in filename, FAIL').''); + return 0; + } + if ($target=~/\.(\d+)\.(\w+)$/) { + $r->print(''.&mt('Cannot publish versioned resource, FAIL').''); + return 0; + } } + +# +# End name check +# $distarget=~s/\/+/\//g; my $logfile; unless ($logfile=Apache::File->new('>>'.$source.'.log')) { @@ -1739,17 +1764,9 @@ sub publishdirectory { &hiddenfield('filename',$env{'form.filename'}). &checkbox('pubrec','include subdirectories'). &checkbox('forcerepub','force republication of previously published files'). - &checkbox('forceobsolete','make file(s) obsolete')); - my %allcopyrights=('keep','Keep current copyright'); - my %ratcopyrights=%allcopyrights; - foreach (&Apache::loncommon::copyrightids) { - $allcopyrights{$_}=&Apache::loncommon::copyrightdescription($_); - unless ($_ eq 'public') { $ratcopyrights{$_}=$allcopyrights{$_}; } - } - $r->print('
'.&mt('Copyright for all files:').&Apache::loncommon::select_form('keep','forceallcopy',%allcopyrights)); - $r->print('
'.&mt('Copyright for pages/sequences:').&Apache::loncommon::select_form('keep','forceratcopy',%ratcopyrights)); - $r->print(&text_with_browse_field('Custom Distribution File','forcecustomfile')); - $r->print('
'); + &checkbox('forceobsolete','make file(s) obsolete'). + &checkbox('forceoverride','force directory level catalog information over existing'). + '
'); } else { # actually publish things opendir(DIR,$fn);