--- loncom/publisher/lonpublisher.pm 2005/05/30 16:56:46 1.196 +++ loncom/publisher/lonpublisher.pm 2005/05/30 17:10:44 1.197 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.196 2005/05/30 16:56:46 www Exp $ +# $Id: lonpublisher.pm,v 1.197 2005/05/30 17:10:44 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1383,10 +1383,10 @@ Returns: =over 4 -=item Scalar string +=item integer -String contains status (errors and warnings) and information associated with -the server's attempts at publication. +0: fail +1: success =cut @@ -1481,18 +1481,20 @@ sub phasetwo { if ($metadatafields{'copyright'} eq 'custom') { my $file=$metadatafields{'customdistributionfile'}; unless ($file=~/\.rights$/) { - return + $r->print( ''.&mt('No valid custom distribution rights file specified, FAIL'). - ''; + ''); + return 0; } } { print $logfile "\nWrite metadata file for ".$source; my $mfh; unless ($mfh=Apache::File->new('>'.$source.'.meta')) { - return + $r->print( ''.&mt('Could not write metadata, FAIL'). - ''; + ''); + return 0; } foreach (sort keys %metadatafields) { unless ($_=~/\./) { @@ -1543,7 +1545,9 @@ sub phasetwo { my $srcd=$1; unless ($srcd=~/^\/home\/httpd\/html\/res/) { print $logfile "\nPANIC: Target dir is ".$srcd; - return "Invalid target directory, FAIL"; + $r->print( + "Invalid target directory, FAIL"); + return 0; } opendir(DIR,$srcd); while ($filename=readdir(DIR)) { @@ -1568,8 +1572,9 @@ sub phasetwo { $r->print('

'.&mt('Copied old target file').'

'); } else { print $logfile "Unable to write ".$copyfile.':'.$!."\n"; - return "".&mt('Failed to copy old target'). - ", $!, ".&mt('FAIL').""; + $r->print("".&mt('Failed to copy old target'). + ", $!, ".&mt('FAIL').""); + return 0; } # --------------------------------------------------------------- Copy Metadata @@ -1582,9 +1587,10 @@ sub phasetwo { } else { print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n"; if (-e $target.'.meta') { - return + $r->print( "". -&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL').""; +&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL').""); + return 0; } } @@ -1615,8 +1621,9 @@ sub phasetwo { $r->print('

'.&mt('Copied source file').'

'); } else { print $logfile "\nUnable to write ".$copyfile.':'.$!."\n"; - return "". - &mt('Failed to copy source').", $!, ".&mt('FAIL').""; + $r->print("". + &mt('Failed to copy source').", $!, ".&mt('FAIL').""); + return 0; } # --------------------------------------------------------------- Copy Metadata @@ -1628,8 +1635,9 @@ sub phasetwo { $r->print('

'.&mt('Copied metadata').'

'); } else { print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n"; - return - "".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL').""; + $r->print( + "".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL').""); + return 0; } $r->rflush; @@ -1661,7 +1669,8 @@ sub phasetwo { &mt('Back to Source Directory').'

'); } $logfile->close(); - return '

'.&mt('Done').'

'; + $r->print('

'.&mt('Done').'

'); + return 1; } # =============================================================== Notifications @@ -2093,8 +2102,8 @@ ENDDIFF ''); } } else { - $r->print('
'. - &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget)); + &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget); + $r->print('
'); } } $r->print('');