--- loncom/publisher/lonpublisher.pm 2005/05/17 00:46:36 1.193
+++ loncom/publisher/lonpublisher.pm 2006/01/13 19:19:34 1.205
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.193 2005/05/17 00:46:36 www Exp $
+# $Id: lonpublisher.pm,v 1.205 2006/01/13 19:19:34 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -355,7 +355,8 @@ sub hiddenfield {
sub checkbox {
my ($name,$text)=@_;
- return "\n
$text";
+ return "\n
";
}
sub selectbox {
@@ -507,7 +508,6 @@ sub get_subscribed_hosts {
if ( $sh=Apache::File->new("$target.subscription") ) {
&Apache::lonnet::logthis("opened $target.subscription");
while (my $subline=<$sh>) {
- &Apache::lonnet::logthis("Trying $subline");
if ($subline =~ /(^\w+):/) {
if ($1 ne $Apache::lonnet::perlvar{'lonHostID'}) {
push(@subscribed,$1);
@@ -676,6 +676,7 @@ sub fix_ids_and_indices {
$allow{$token->[2]->{'src'}}=1;
next;
}
+ if ($lctag eq 'base') { next; }
my %parms=%{$token->[2]};
$counter=$addid{$tag};
if (!$counter) { $counter=$addid{$lctag}; }
@@ -685,7 +686,9 @@ sub fix_ids_and_indices {
$parms{'id'}!~/^\s*$/) {
$maxid++;
$parms{'id'}=$maxid;
- print $logfile 'ID: '.$tag.':'.$maxid."\n";
+ print $logfile 'ID(new) : '.$tag.':'.$maxid."\n";
+ } else {
+ print $logfile 'ID(kept): '.$tag.':'.$parms{'id'}."\n";
}
} elsif ($counter eq 'index') {
unless (defined($parms{'index'}) &&
@@ -696,12 +699,14 @@ sub fix_ids_and_indices {
}
}
}
- foreach my $type ('src','href','background','bgimg') {
- foreach my $key (keys(%parms)) {
- if ($key =~ /^$type$/i) {
- $parms{$key}=&set_allow(\%allow,$logfile,
- $target,$tag,
- $parms{$key});
+ unless ($parms{'type'} eq 'zombie') {
+ foreach my $type ('src','href','background','bgimg') {
+ foreach my $key (keys(%parms)) {
+ if ($key =~ /^$type$/i) {
+ $parms{$key}=&set_allow(\%allow,$logfile,
+ $target,$tag,
+ $parms{$key});
+ }
}
}
}
@@ -1020,7 +1025,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 +1075,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{$_};
+ }
}
@@ -1151,16 +1164,17 @@ sub publish {
my $intr_scrout.=
'
'.&mt('Copied old target file').'
'); } else { print $logfile "Unable to write ".$copyfile.':'.$!."\n"; - return "".&mt('Failed to copy old target'). - ", $!, ".&mt('FAIL').""; + $r->print("".&mt('Failed to copy old target'). + ", $!, ".&mt('FAIL').""); + return 0; } # --------------------------------------------------------------- Copy Metadata @@ -1533,9 +1592,10 @@ sub phasetwo { } else { print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n"; if (-e $target.'.meta') { - return + $r->print( "". -&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL').""; +&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL').""); + return 0; } } @@ -1566,8 +1626,9 @@ sub phasetwo { $r->print(''.&mt('Copied source file').'
'); } else { print $logfile "\nUnable to write ".$copyfile.':'.$!."\n"; - return "". - &mt('Failed to copy source').", $!, ".&mt('FAIL').""; + $r->print("". + &mt('Failed to copy source').", $!, ".&mt('FAIL').""); + return 0; } # --------------------------------------------------------------- Copy Metadata @@ -1579,8 +1640,9 @@ sub phasetwo { $r->print(''.&mt('Copied metadata').'
'); } else { print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n"; - return - "".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL').""; + $r->print( + "".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL').""); + return 0; } $r->rflush; @@ -1590,10 +1652,16 @@ sub phasetwo { $r->register_cleanup(\¬ify); $registered_cleanup=1; } + +# ---------------------------------------------------------- Clear local caches + my $thisdistarget=$target; + $thisdistarget=~s/^\Q$docroot\E//; + &Apache::lonnet::devalidate_cache_new('resversion',$target); + &Apache::lonnet::devalidate_cache_new('meta', + &Apache::lonnet::declutter($thisdistarget)); + # ------------------------------------------------ Provide link to new resource unless ($batch) { - my $thisdistarget=$target; - $thisdistarget=~s/^\Q$docroot\E//; my $thissrc=$source; $thissrc=~s/^\/home\/(\w+)\/public_html/\/priv\/$1/; @@ -1612,7 +1680,8 @@ sub phasetwo { &mt('Back to Source Directory').''); } $logfile->close(); - return ''.&mt('Done').'
'; + $r->print(''.&mt('Done').'
'); + return 1; } # =============================================================== Notifications @@ -1714,8 +1783,10 @@ sub publishdirectory { &hiddenfield('phase','two'). &hiddenfield('filename',$env{'form.filename'}). &checkbox('pubrec','include subdirectories'). - &checkbox('forcerepub','force republication of previously published files')); - $r->print(''); + &checkbox('forcerepub','force republication of previously published files'). + &checkbox('forceobsolete','make file(s) obsolete'). + &checkbox('forceoverride','force directory level catalog information over existing'). + '