--- loncom/publisher/lonpublisher.pm 2002/10/07 21:07:08 1.100 +++ loncom/publisher/lonpublisher.pm 2002/10/10 15:05:36 1.102 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.100 2002/10/07 21:07:08 matthew Exp $ +# $Id: lonpublisher.pm,v 1.102 2002/10/10 15:05:36 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -309,6 +309,27 @@ sub sqltime { ######################################### ######################################### +sub coursedependencies { + my $url=&Apache::lonnet::declutter(shift); + $url=~s/\.meta$//; + my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//); + my $regexp=$url; + $regexp=~s/(\W)/\\$1/g; + $regexp='___'.$regexp.'___course'; + my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain, + $aauthor,$regexp); + my %courses=(); + foreach (keys %evaldata) { + if ($_=~/^([a-zA-Z0-9]+_[a-zA-Z0-9]+)___.+___course$/) { + $courses{$1}=1; + } + } + return %courses; +} +######################################### +######################################### + + =pod =item Form-field-generating subroutines. @@ -492,7 +513,6 @@ sub get_subscribed_hosts { } else { &Apache::lonnet::logthis("Unable to open $target.subscription"); } - &Apache::lonnet::logthis("Got list of ".join(':',@subscribed)); return @subscribed; } @@ -1206,6 +1226,9 @@ the server's attempts at publication. sub phasetwo { my ($r,$source,$target,$style,$distarget,$batch)=@_; + $source=~s/\/+/\//g; + $target=~s/\/+/\//g; + $distarget=~s/\/+/\//g; my $logfile; unless ($logfile=Apache::File->new('>>'.$source.'.log')) { return @@ -1396,7 +1419,7 @@ sub phasetwo { $r->print('

Notifying host '.$subhost.':');$r->rflush; print $logfile "\nNotifying host ".$subhost.':'; my $reply=&Apache::lonnet::critical('update:'.$target,$subhost); - $r->print($reply);$r->rflush; + $r->print($reply.'
');$r->rflush; print $logfile $reply; } @@ -1408,10 +1431,22 @@ sub phasetwo { print $logfile "\nNotifying host for metadata only ".$subhost.':'; my $reply=&Apache::lonnet::critical('update:'.$target.'.meta', $subhost); - $r->print($reply);$r->rflush; + $r->print($reply.'
');$r->rflush; print $logfile $reply; } +# --------------------------------------------------- Notify subscribed courses + my %courses=&coursedependencies($target); + my $now=time; + foreach (keys %courses) { + $r->print('

Notifying course '.$_.':');$r->rflush; + print $logfile "\nNotifying host ".$_.':'; + my ($cdom,$cname)=split(/\_/,$_); + my $reply=&Apache::lonnet::cput + ('versionupdate',{$target => $now},$cdom,$cname); + $r->print($reply.'
');$r->rflush; + print $logfile $reply; + } # ------------------------------------------------ Provide link to new resource unless ($batch) { my $thisdistarget=$target; @@ -1437,6 +1472,8 @@ sub phasetwo { sub batchpublish { my ($r,$srcfile,$targetfile)=@_; + $srcfile=~s/\/+/\//g; + $targetfile=~s/\/+/\//g; my $thisdisfn=$srcfile; $thisdisfn=~s/\/home\/korte\/public_html\///; $srcfile=~s/\/+/\//g; @@ -1474,6 +1511,8 @@ sub batchpublish { sub publishdirectory { my ($r,$fn,$thisdisfn)=@_; + $fn=~s/\/+/\//g; + $thisdisfn=~s/\/+/\//g; my $resdir= $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.'/'. $thisdisfn; @@ -1665,6 +1704,8 @@ unless ($ENV{'form.phase'} eq 'two') { $r->print('LON-CAPA Publishing'); $r->print(&Apache::loncommon::bodytag('Resource Publication')); + + my $thisfn=$fn; my $thistarget=$thisfn;