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

www lon-capa-cvs@mail.lon-capa.org
Mon, 30 May 2005 17:10:47 -0000


www		Mon May 30 13:10:47 2005 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Was not dealing consistently with return codes from phasetwo
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.196 loncom/publisher/lonpublisher.pm:1.197
--- loncom/publisher/lonpublisher.pm:1.196	Mon May 30 12:56:46 2005
+++ loncom/publisher/lonpublisher.pm	Mon May 30 13:10:44 2005
@@ -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 @@
 
 =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 @@
     if ($metadatafields{'copyright'} eq 'custom') {
 	my $file=$metadatafields{'customdistributionfile'};
 	unless ($file=~/\.rights$/) {
-            return 
+            $r->print(
                 '<font color="red">'.&mt('No valid custom distribution rights file specified, FAIL').
-		'</font>';
+		'</font>');
+	    return 0;
         }
     }
     {
         print $logfile "\nWrite metadata file for ".$source;
         my $mfh;
         unless ($mfh=Apache::File->new('>'.$source.'.meta')) {
-            return 
+            $r->print( 
                 '<font color="red">'.&mt('Could not write metadata, FAIL').
-		'</font>';
+		'</font>');
+	    return 0;
         }
         foreach (sort keys %metadatafields) {
             unless ($_=~/\./) {
@@ -1543,7 +1545,9 @@
         my $srcd=$1;
         unless ($srcd=~/^\/home\/httpd\/html\/res/) {
             print $logfile "\nPANIC: Target dir is ".$srcd;
-            return "<font color=\"red\">Invalid target directory, FAIL</font>";
+            $r->print(
+	 "<font color=\"red\">Invalid target directory, FAIL</font>");
+	    return 0;
         }
         opendir(DIR,$srcd);
         while ($filename=readdir(DIR)) {
@@ -1568,8 +1572,9 @@
             $r->print('<p>'.&mt('Copied old target file').'</p>');
         } else {
 	    print $logfile "Unable to write ".$copyfile.':'.$!."\n";
-            return "<font color=\"red\">".&mt('Failed to copy old target').
-		", $!, ".&mt('FAIL')."</font>";
+            $r->print("<font color=\"red\">".&mt('Failed to copy old target').
+		", $!, ".&mt('FAIL')."</font>");
+	    return 0;
         }
         
 # --------------------------------------------------------------- Copy Metadata
@@ -1582,9 +1587,10 @@
         } else {
 	    print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
             if (-e $target.'.meta') {
-                return 
+                $r->print( 
                     "<font color=\"red\">".
-&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL')."</font>";
+&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL')."</font>");
+		return 0;
 	    }
         }
         
@@ -1615,8 +1621,9 @@
         $r->print('<p>'.&mt('Copied source file').'</p>');
     } else {
         print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
-        return "<font color=\"red\">".
-	    &mt('Failed to copy source').", $!, ".&mt('FAIL')."</font>";
+        $r->print("<font color=\"red\">".
+	    &mt('Failed to copy source').", $!, ".&mt('FAIL')."</font>");
+	return 0;
     }
     
 # --------------------------------------------------------------- Copy Metadata
@@ -1628,8 +1635,9 @@
         $r->print('<p>'.&mt('Copied metadata').'</p>');
     } else {
         print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n";
-        return 
-            "<font color=\"red\">".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL')."</font>";
+        $r->print(
+            "<font color=\"red\">".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL')."</font>");
+	return 0;
     }
     $r->rflush;
 
@@ -1661,7 +1669,8 @@
 		  &mt('Back to Source Directory').'</font></a></p>');
     }
     $logfile->close();
-    return '<p><font color="green">'.&mt('Done').'</font></p>';
+    $r->print('<p><font color="green">'.&mt('Done').'</font></p>');
+    return 1;
 }
 
 # =============================================================== Notifications
@@ -2093,8 +2102,8 @@
 			  '</h3>');
 	    }
 	} else {
-	    $r->print('<hr />'.
-	    &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget)); 
+	    &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget); 
+	    $r->print('<hr />');
 	}
     }
     $r->print('</body></html>');