Diff for /loncom/publisher/lonpublisher.pm between versions 1.179 and 1.182

version 1.179, 2004/10/05 13:41:36 version 1.182, 2005/01/12 16:18:54
Line 138  my $docroot; Line 138  my $docroot;
 my $cuname;  my $cuname;
 my $cudom;  my $cudom;
   
   my $registered_cleanup;
   
 =pod  =pod
   
 =item B<metaeval>  =item B<metaeval>
Line 329  sub textfield { Line 331  sub textfield {
            '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';             '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';
 }  }
   
   sub text_with_browse_field {
       my ($title,$name,$value,$restriction)=@_;
       $value=~s/^\s+//gs;
       $value=~s/\s+$//gs;
       $value=~s/\s+/ /gs;
       $title=&mt($title);
       $ENV{'form.'.$name}=$value;
       return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
              "</b></font></p><br />".
              '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />'.
      '<a href="javascript:openbrowser(\'pubform\',\''.$name.'\',\''.$restriction.'\');">Select</a>&nbsp;'.
      '<a href="javascript:opensearcher(\'pubform\',\''.$name.'\');">Search</a>';
      
   }
   
 sub hiddenfield {  sub hiddenfield {
     my ($name,$value)=@_;      my ($name,$value)=@_;
     $ENV{'form.'.$name}=$value;      $ENV{'form.'.$name}=$value;
Line 1238  END Line 1255  END
  my $copyright_help =   my $copyright_help =
     Apache::loncommon::help_open_topic('Publishing_Copyright');      Apache::loncommon::help_open_topic('Publishing_Copyright');
  $intr_scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;   $intr_scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
  $intr_scrout.=&textfield('Custom Distribution File','customdistributionfile',   $intr_scrout.=&text_with_browse_field('Custom Distribution File','customdistributionfile',$metadatafields{'customdistributionfile'},'rights').$copyright_help;
  $metadatafields{'customdistributionfile'}).  
      $copyright_help;  
  $intr_scrout.=&selectbox('Source Distribution','sourceavail',   $intr_scrout.=&selectbox('Source Distribution','sourceavail',
  $defaultsourceoption,   $defaultsourceoption,
  \&Apache::loncommon::source_copyrightdescription,   \&Apache::loncommon::source_copyrightdescription,
  (&Apache::loncommon::source_copyrightids));   (&Apache::loncommon::source_copyrightids));
  $intr_scrout.=&textfield('Source Custom Distribution File','sourcerights',   $intr_scrout.=&text_with_browse_field('Source Custom Distribution File','sourcerights',$metadatafields{'sourcerights'},'rights');
   $metadatafields{'sourcerights'});  
  my $uctitle=&mt('Obsolete');   my $uctitle=&mt('Obsolete');
  $intr_scrout.=   $intr_scrout.=
     "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
Line 1255  END Line 1269  END
     $intr_scrout.=' checked="1" ';      $intr_scrout.=' checked="1" ';
  }   }
  $intr_scrout.='/ ></p>'.   $intr_scrout.='/ ></p>'.
     &textfield('Suggested Replacement for Obsolete File',      &text_with_browse_field('Suggested Replacement for Obsolete File',
        'obsoletereplacement',      'obsoletereplacement',
        $metadatafields{'obsoletereplacement'});      $metadatafields{'obsoletereplacement'});
     } else {      } else {
  $intr_scrout.=&hiddenfield('copyright','private');   $intr_scrout.=&hiddenfield('copyright','private');
     }      }
Line 1529  sub phasetwo { Line 1543  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);  # ------------------------------------------------------------- Trigger updates
     foreach my $subhost (@subscribed) {      print $logfile("\nRegistering for notifications: $target $source\n");
  $r->print('<p>'.&mt('Notifying host').' '.$subhost.':');$r->rflush;      push(@{$ENV{'internal.publication.targetsource'}},[$target,$source]);
  print $logfile "\nNotifying host ".$subhost.':';      unless ($registered_cleanup) {
  my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);   &Apache::lonnet::logthis('Cleanup handler registered');
  $r->print($reply.'</p><br />');$r->rflush;   $r->register_cleanup(\&notify);
  print $logfile $reply;   $registered_cleanup=1;
     }  
       
 # ---------------------------------------- Send update notifications, meta only  
   
     my @subscribedmeta=&get_subscribed_hosts("$target.meta");  
     foreach my $subhost (@subscribedmeta) {  
  $r->print('<p>'.  
 &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.'</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 1586  sub phasetwo { Line 1573  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
       &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 {  sub batchpublish {
Line 1798  sub handler { Line 1824  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['filename']);                                              ['filename']);
   
   # ------------------------------------------------- Flag for registered cleanup
       $registered_cleanup=0;
 # -------------------------------------------------------------- Check filename  # -------------------------------------------------------------- Check filename
   
     my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});      my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
Line 1891  sub handler { Line 1919  sub handler {
   
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
       
     $r->print('<html><head><title>LON-CAPA Publishing</title></head>');      my $js=&Apache::loncommon::browser_and_searcher_javascript();
       $r->print('<html><head><title>LON-CAPA Publishing</title>
                 <script type="text/javascript">'.$js.'
                 </script></head>');
     $r->print(&Apache::loncommon::bodytag('Resource Publication'));      $r->print(&Apache::loncommon::bodytag('Resource Publication'));
   
   

Removed from v.1.179  
changed lines
  Added in v.1.182


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