--- loncom/publisher/lonpublisher.pm 2007/07/13 20:11:27 1.227 +++ loncom/publisher/lonpublisher.pm 2008/05/19 18:43:16 1.236 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.227 2007/07/13 20:11:27 albertel Exp $ +# $Id: lonpublisher.pm,v 1.236 2008/05/19 18:43:16 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -143,6 +143,8 @@ my $cudom; my $registered_cleanup; my $modified_urls; +my $lock; + =pod =item B @@ -344,8 +346,8 @@ sub text_with_browse_field { return "\n

$title:". "


". ''. - 'Select '. - 'Search'; + ''.&mt('Select').' '. + ''.&mt('Search').''; } @@ -663,6 +665,7 @@ sub fix_ids_and_indices { "Max Index: $maxindex (min 10)\n"; } my $outstring=''; + my $responsecounter=1; my @parser; $parser[0]=HTML::LCParser->new(\$content); $parser[-1]->xml_mode(1); @@ -678,6 +681,10 @@ sub fix_ids_and_indices { next; } if ($lctag eq 'base') { next; } + if (($lctag eq 'part') || ($lctag eq 'problem')) { + $responsecounter=0; + } + if ($lctag=~/response$/) { $responsecounter++; } my %parms=%{$token->[2]}; $counter=$addid{$tag}; if (!$counter) { $counter=$addid{$lctag}; } @@ -773,7 +780,7 @@ sub fix_ids_and_indices { } if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; } $outstring.='<'.$tag.$newparmstring.$endtag.'>'; - if ($lctag eq 'm' || $lctag eq 'script' + if ($lctag eq 'm' || $lctag eq 'script' || $lctag eq 'answer' || $lctag eq 'display' || $lctag eq 'tex') { $outstring.=&get_all_text_unbalanced('/'.$lctag,\@parser); } @@ -782,7 +789,12 @@ sub fix_ids_and_indices { unless ($token->[1] eq 'allow') { $outstring.='[1].'>'; } - } + } + if ((($token->[1] eq 'part') || ($token->[1] eq 'problem')) + && (!$responsecounter)) { + my $outstring=''.&mt('Found [_1] without responses',$token->[1]).''; + return ($outstring,1); + } } else { $outstring.=$token->[1]; } @@ -841,8 +853,9 @@ sub store_metadata { if (($metadata{'obsolete'}) || ($metadata{'copyright'} eq 'priv') || ($metadata{'copyright'} eq 'custom')) { # remove this entry - $status=&LONCAPA::lonmetadata::delete_metadata($dbh,undef, - $metadata{'url'}); + my $delitem = 'url = '.$dbh->quote($metadata{'url'}); + $status = &LONCAPA::lonmetadata::delete_metadata($dbh,undef,$delitem); + } else { $status = &LONCAPA::lonmetadata::update_metadata($dbh,undef,undef, \%metadata); @@ -963,18 +976,23 @@ sub publish { $scrout.='

'.&mt('Dependencies').'

'; my $allowstr=''; - foreach (sort(keys(%allow))) { - my $thisdep=$_; + foreach my $thisdep (sort(keys(%allow))) { if ($thisdep !~ /[^\s]/) { next; } + if ($thisdep =~/\$/) { + $scrout.='
' + .&mt('The resource depends on another resource with variable filename, i.e., [_1].',''.$thisdep.'').'
' + .&mt('You likely need to explicitly allow access to all possible dependencies using the [_1]-tag.','<allow>') + .'

'; + } unless ($style eq 'rat') { $allowstr.="\n".''; } $scrout.='
'; - if ($thisdep!~/\*/ && $thisdep!~m|^/adm/|) { + if ($thisdep!~/[\*\$]/ && $thisdep!~m|^/adm/|) { $scrout.=''; } $scrout.=''.$thisdep.''; - if ($thisdep!~/\*/ && $thisdep!~m|^/adm/|) { + if ($thisdep!~/[\*\$]/ && $thisdep!~m|^/adm/|) { $scrout.=''; if ( &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'. @@ -1130,6 +1148,11 @@ sub publish { '

'. &mt('If this resource is in active use, student performance data from the previous version may become inaccessible.').'


'; } + if ($metadatafields{'copyright'} eq 'priv') { + $scrout.='

'.&mt('Warning!'). + '

'. + &mt('Copyright/distribution option "Private" is no longer supported. Select another option from below. Consider "Custom Rights" for maximum control over the usage of your resource.').'


'; + } # ------------------------------------------------------- Now have all metadata @@ -1289,6 +1312,9 @@ END $metadatafields{'copyright'}='default'; $metadatafields{'sourceavail'}='open'; } + if ($metadatafields{'copyright'} eq 'priv') { + $metadatafields{'copyright'}='domain'; + } # ------------------------------------------------ Dial in reasonable defaults my $defaultoption=$metadatafields{'copyright'}; unless ($defaultoption) { $defaultoption='default'; } @@ -1305,12 +1331,12 @@ END $intr_scrout.=&selectbox('Copyright/Distribution','copyright', $defaultoption, \&Apache::loncommon::copyrightdescription, - (grep !/^public$/,(&Apache::loncommon::copyrightids))); + (grep !/^(public|priv)$/,(&Apache::loncommon::copyrightids))); } else { $intr_scrout.=&selectbox('Copyright/Distribution','copyright', $defaultoption, \&Apache::loncommon::copyrightdescription, - (&Apache::loncommon::copyrightids)); + (grep !/^priv$/,(&Apache::loncommon::copyrightids))); } my $copyright_help = Apache::loncommon::help_open_topic('Publishing_Copyright'); @@ -1730,6 +1756,7 @@ sub notify { print $logfile "\n============ Done ============\n"; $logfile->close(); } + if ($lock) { &Apache::lonnet::remove_lock($lock); } return OK; } @@ -1799,7 +1826,9 @@ sub publishdirectory { &checkbox('obsolete','make file(s) obsolete'). &checkbox('forceoverride','force directory level catalog information over existing'). '
'); + $lock=0; } else { + unless ($lock) { $lock=&Apache::lonnet::set_lock(&mt('Publishing [_1]',$fn)); } # actually publish things opendir(DIR,$fn); my @files=sort(readdir(DIR));