--- loncom/publisher/lonpublisher.pm 2004/10/05 13:41:36 1.179
+++ loncom/publisher/lonpublisher.pm 2005/01/12 16:18:54 1.182
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.179 2004/10/05 13:41:36 matthew Exp $
+# $Id: lonpublisher.pm,v 1.182 2005/01/12 16:18:54 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -138,6 +138,8 @@ my $docroot;
my $cuname;
my $cudom;
+my $registered_cleanup;
+
=pod
=item B $title:".
+ " $uctitle:".
@@ -1255,9 +1269,9 @@ END
$intr_scrout.=' checked="1" ';
}
$intr_scrout.='/ > '.&mt('Notifying host').' '.$subhost.':');$r->rflush;
- print $logfile "\nNotifying host ".$subhost.':';
- my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
- $r->print($reply.' '.
-&mt('Notifying host for metadata only').' '.$subhost.':');$r->rflush;
- print $logfile "\nNotifying host for metadata only ".$subhost.':';
- my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
- $subhost);
- $r->print($reply.' '.&mt('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.'
".
+ ''.
+ 'Select '.
+ 'Search';
+
+}
+
sub hiddenfield {
my ($name,$value)=@_;
$ENV{'form.'.$name}=$value;
@@ -1238,15 +1255,12 @@ END
my $copyright_help =
Apache::loncommon::help_open_topic('Publishing_Copyright');
$intr_scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
- $intr_scrout.=&textfield('Custom Distribution File','customdistributionfile',
- $metadatafields{'customdistributionfile'}).
- $copyright_help;
+ $intr_scrout.=&text_with_browse_field('Custom Distribution File','customdistributionfile',$metadatafields{'customdistributionfile'},'rights').$copyright_help;
$intr_scrout.=&selectbox('Source Distribution','sourceavail',
$defaultsourceoption,
\&Apache::loncommon::source_copyrightdescription,
(&Apache::loncommon::source_copyrightids));
- $intr_scrout.=&textfield('Source Custom Distribution File','sourcerights',
- $metadatafields{'sourcerights'});
+ $intr_scrout.=&text_with_browse_field('Source Custom Distribution File','sourcerights',$metadatafields{'sourcerights'},'rights');
my $uctitle=&mt('Obsolete');
$intr_scrout.=
"\n
');$r->rflush;
- print $logfile $reply;
- }
-
-# ---------------------------------------- Send update notifications, meta only
-
- my @subscribedmeta=&get_subscribed_hosts("$target.meta");
- foreach my $subhost (@subscribedmeta) {
- $r->print('
');$r->rflush;
- print $logfile $reply;
- }
-
-# --------------------------------------------------- Notify subscribed courses
- my %courses=&coursedependencies($target);
- my $now=time;
- foreach (keys %courses) {
- $r->print('
');$r->rflush;
- print $logfile $reply;
+# ------------------------------------------------------------- Trigger updates
+ print $logfile("\nRegistering for notifications: $target $source\n");
+ push(@{$ENV{'internal.publication.targetsource'}},[$target,$source]);
+ unless ($registered_cleanup) {
+ &Apache::lonnet::logthis('Cleanup handler registered');
+ $r->register_cleanup(\¬ify);
+ $registered_cleanup=1;
}
# ------------------------------------------------ Provide link to new resource
unless ($batch) {
@@ -1586,9 +1573,48 @@ sub phasetwo {
'">'.
&mt('Back to Source Directory').'
'.&mt('Done').'
'; } +# =============================================================== Notifications +sub notify { +# --------------------------------------------------- Send update notifications + &Apache::lonnet::logthis('Cleanup Phase Publication Handler'); + foreach my $targetsource (@{$ENV{'internal.publication.targetsource'}}){ + my ($target,$source)=@{$targetsource}; + my $logfile=Apache::File->new('>>'.$source.'.log'); + print $logfile "\nCleanup phase: Notifications\n"; + my @subscribed=&get_subscribed_hosts($target); + foreach my $subhost (@subscribed) { + print $logfile "\nNotifying host ".$subhost.':'; + my $reply=&Apache::lonnet::critical('update:'.$target,$subhost); + print $logfile $reply; + } +# ---------------------------------------- Send update notifications, meta only + my @subscribedmeta=&get_subscribed_hosts("$target.meta"); + foreach my $subhost (@subscribedmeta) { + print $logfile "\nNotifying host for metadata only ".$subhost.':'; + my $reply=&Apache::lonnet::critical('update:'.$target.'.meta', + $subhost); + print $logfile $reply; + } +# --------------------------------------------------- Notify subscribed courses + my %courses=&coursedependencies($target); + my $now=time; + foreach (keys %courses) { + print $logfile "\nNotifying course ".$_.':'; + my ($cdom,$cname)=split(/\_/,$_); + my $reply=&Apache::lonnet::cput + ('versionupdate',{$target => $now},$cdom,$cname); + print $logfile $reply; + } + print $logfile "\n============ Done ============\n"; + $logfile->close(); + } + return OK; +} + ######################################### sub batchpublish { @@ -1798,6 +1824,8 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['filename']); +# ------------------------------------------------- Flag for registered cleanup + $registered_cleanup=0; # -------------------------------------------------------------- Check filename my $fn=&Apache::lonnet::unescape($ENV{'form.filename'}); @@ -1891,8 +1919,11 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - - $r->print('