Diff for /loncom/publisher/lonpublisher.pm between versions 1.180 and 1.185

version 1.180, 2004/10/11 17:40:46 version 1.185, 2005/02/28 21:28:18
Line 138  my $docroot; Line 138  my $docroot;
 my $cuname;  my $cuname;
 my $cudom;  my $cudom;
   
   my $registered_cleanup;
   my $modified_urls;
   
 =pod  =pod
   
 =item B<metaeval>  =item B<metaeval>
Line 839  sub store_metadata { Line 842  sub store_metadata {
 }  }
   
   
   # ========================================== Parse file for errors and warnings
   
   sub checkonthis {
       my ($r,$source)=@_;
       my $oldpath=$ENV{'request.filename'};
       $ENV{'request.filename'}=$source;
       &Apache::lonxml::xmlparse($r,'web',
         &Apache::lonnet::getfile($source));
       undef($Apache::lonhomework::parsing_a_problem);
       $ENV{'request.filename'}=$oldpath;
       if (($Apache::lonxml::errorcount) ||
    ($Apache::lonxml::warningcount)) {
    if ($Apache::lonxml::errorcount) {
       $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
         $Apache::lonxml::errorcount.' '.
         &mt('error(s)').'</b></font> ');
    }
    if ($Apache::lonxml::warningcount) {
       $r->print('<font color="blue">'.
         $Apache::lonxml::warningcount.' '.
         &mt('warning(s)').'</font>');
    }
       } else {
    $r->print('<font color="green">'.&mt('ok').'</font>');
       }
       $r->rflush();
       return ($Apache::lonxml::warningcount,$Apache::lonxml::errorcount);
   }
   
 # ============================================== Parse file itself for metadata  # ============================================== Parse file itself for metadata
 #  #
 # parses a file with target meta, sets global %metadatafields %metadatakeys   # parses a file with target meta, sets global %metadatafields %metadatakeys 
Line 1004  sub publish { Line 1036  sub publish {
             $scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);              $scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
     $prefix=~s|^\.\./||;      $prefix=~s|^\.\./||;
         }          }
   
 # ----------------------------------------------------------- Parse file itself  # ----------------------------------------------------------- Parse file itself
 # read %metadatafields from file itself  # read %metadatafields from file itself
     
Line 1541  sub phasetwo { Line 1574  sub phasetwo {
             "<font color=\"red\">".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL')."</font>";              "<font color=\"red\">".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL')."</font>";
     }      }
     $r->rflush;      $r->rflush;
 # --------------------------------------------------- Send update notifications  
   
     my @subscribed=&get_subscribed_hosts($target);  
     foreach my $subhost (@subscribed) {  
  $r->print('<p>'.&mt('Notifying host').' '.$subhost.':');$r->rflush;  
  print $logfile "\nNotifying host ".$subhost.':';  
  my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);  
  $r->print($reply.'</p><br />');$r->rflush;  
  print $logfile $reply;  
     }  
       
 # ---------------------------------------- Send update notifications, meta only  
   
     my @subscribedmeta=&get_subscribed_hosts("$target.meta");  # ------------------------------------------------------------- Trigger updates
     foreach my $subhost (@subscribedmeta) {      push(@{$modified_urls},[$target,$source]);
  $r->print('<p>'.      unless ($registered_cleanup) {
 &mt('Notifying host for metadata only').' '.$subhost.':');$r->rflush;   $r->register_cleanup(\&notify);
  print $logfile "\nNotifying host for metadata only ".$subhost.':';   $registered_cleanup=1;
  my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',  
     $subhost);  
  $r->print($reply.'</p><br />');$r->rflush;  
  print $logfile $reply;  
     }  
       
 # --------------------------------------------------- Notify subscribed courses  
     my %courses=&coursedependencies($target);  
     my $now=time;  
     foreach (keys %courses) {  
  $r->print('<p>'.&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.'</p><br />');$r->rflush;  
  print $logfile $reply;  
     }      }
 # ------------------------------------------------ Provide link to new resource  # ------------------------------------------------ Provide link to new resource
     unless ($batch) {      unless ($batch) {
Line 1598  sub phasetwo { Line 1602  sub phasetwo {
                    '"><font size="+2">'.                     '"><font size="+2">'.
   &mt('Back to Source Directory').'</font></a></p>');    &mt('Back to Source Directory').'</font></a></p>');
     }      }
       $logfile->close();
     return '<p><font color="green">'.&mt('Done').'</font></p>';      return '<p><font color="green">'.&mt('Done').'</font></p>';
 }  }
   
   # =============================================================== Notifications
   sub notify {  
   # --------------------------------------------------- Send update notifications
       foreach my $targetsource (@{$modified_urls}){
    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 {  sub batchpublish {
Line 1681  sub publishdirectory { Line 1723  sub publishdirectory {
     $ruid,$rgid,$rrdev,$rsize,      $ruid,$rgid,$rrdev,$rsize,
     $ratime,$rmtime,$rctime,      $ratime,$rmtime,$rctime,
     $rblksize,$rblocks)=stat($resdir.'/'.$filename);      $rblksize,$rblocks)=stat($resdir.'/'.$filename);
         if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'})) {          if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'} eq 'ON')) {
 # previously published, modified now  # previously published, modified now
     $publishthis=1;      $publishthis=1;
                 }                  }
Line 1810  sub handler { Line 1852  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['filename']);                                              ['filename']);
   
   # -------------------------------------- Flag and buffer for registered cleanup
       $registered_cleanup=0;
       @{$modified_urls}=();
 # -------------------------------------------------------------- Check filename  # -------------------------------------------------------------- Check filename
   
     my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});      my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
Line 1963  ENDDIFF Line 2008  ENDDIFF
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.  # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
   
  unless ($ENV{'form.phase'} eq 'two') {   unless ($ENV{'form.phase'} eq 'two') {
   # ---------------------------------------------------------- Parse for problems
       &checkonthis($r,$thisfn);
     my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);      my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);
     $r->print('<hr />'.$outstring);      $r->print('<hr />'.$outstring);
  } else {   } else {

Removed from v.1.180  
changed lines
  Added in v.1.185


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>