[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 08 Oct 2002 13:24:36 -0000


www		Tue Oct  8 09:24:36 2002 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Notifies "subscribed" courses.
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.100 loncom/publisher/lonpublisher.pm:1.101
--- loncom/publisher/lonpublisher.pm:1.100	Mon Oct  7 17:07:08 2002
+++ loncom/publisher/lonpublisher.pm	Tue Oct  8 09:24:36 2002
@@ -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.101 2002/10/08 13:24:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -309,6 +309,27 @@
 #########################################
 #########################################
 
+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 @@
     } else {
 	&Apache::lonnet::logthis("Unable to open $target.subscription");
     }
-    &Apache::lonnet::logthis("Got list of ".join(':',@subscribed));
     return @subscribed;
 }
 
@@ -1396,7 +1416,7 @@
 	$r->print('<p>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.'<br />');$r->rflush;
 	print $logfile $reply;
     }
     
@@ -1408,10 +1428,22 @@
 	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.'<br />');$r->rflush;
 	print $logfile $reply;
     }
     
+# --------------------------------------------------- Notify subscribed courses
+    my %courses=&coursedependencies($target);
+    my $now=time;
+    foreach (keys %courses) {
+	$r->print('<p>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.'<br />');$r->rflush;
+	print $logfile $reply;
+    }
 # ------------------------------------------------ Provide link to new resource
     unless ($batch) {
         my $thisdistarget=$target;
@@ -1665,6 +1697,8 @@
 
   $r->print('<html><head><title>LON-CAPA Publishing</title></head>');
   $r->print(&Apache::loncommon::bodytag('Resource Publication'));
+
+
   my $thisfn=$fn;
 
   my $thistarget=$thisfn;