[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 07 Mar 2003 17:52:37 -0000
albertel Fri Mar 7 12:52:37 2003 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
- if an error occurs during phase one of publishing don't do phasetwo
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.112 loncom/publisher/lonpublisher.pm:1.113
--- loncom/publisher/lonpublisher.pm:1.112 Tue Feb 18 18:18:50 2003
+++ loncom/publisher/lonpublisher.pm Fri Mar 7 12:52:37 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.112 2003/02/18 23:18:50 albertel Exp $
+# $Id: lonpublisher.pm,v 1.113 2003/03/07 17:52:37 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -789,6 +789,10 @@
backup copies, performs any automatic processing (prior to publication,
especially for rat and ssi files),
+Returns a 2 element array, the first is the string to be shown to the
+user, the second is an error code, either 1 (an error occured) or 0
+(no error occurred)
+
I<Additional documentation needed.>
=cut
@@ -805,8 +809,7 @@
my %allow=();
unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
- return
- '<font color=red>No write permission to user directory, FAIL</font>';
+ return ('<font color=red>No write permission to user directory, FAIL</font>',1);
}
print $logfile
"\n\n================= Publish ".localtime()." Phase One ================\n";
@@ -820,14 +823,14 @@
print $logfile "Copied original file to ".$copyfile."\n";
} else {
print $logfile "Unable to write backup ".$copyfile.':'.$!."\n";
- return "<font color=red>Failed to write backup copy, $!,FAIL</font>";
+ return ("<font color=red>Failed to write backup copy, $!,FAIL</font>",1);
}
# ------------------------------------------------------------- IDs and indices
my ($outstring,$error);
($outstring,$error,%allow)=&fix_ids_and_indices($logfile,$source,
$target);
- if ($error) { return $outstring; }
+ if ($error) { return ($outstring,$error); }
# ------------------------------------------------------------ Construct Allows
$scrout.='<h3>Dependencies</h3>';
@@ -872,9 +875,8 @@
my $org;
unless ($org=Apache::File->new('>'.$source)) {
print $logfile "No write permit to $source\n";
- return
- '<font color="red">No write permission to '.$source.
- ', FAIL</font>';
+ return ('<font color="red">No write permission to '.$source.
+ ', FAIL</font>',1);
}
print($org $outstring);
}
@@ -1122,8 +1124,7 @@
my $copyright_help =
Apache::loncommon::help_open_topic('Publishing_Copyright');
$scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
- return $scrout.
- '<p><input type="submit" value="Finalize Publication" /></p></form>';
+ return ($scrout.'<p><input type="submit" value="Finalize Publication" /></p></form>',0);
# =============================================================================
# BATCH MODE
#
@@ -1151,7 +1152,7 @@
$ENV{'form.copyright'}='default';
}
$ENV{'form.allmeta'}=&Apache::lonnet::escape($allmeta);
- return $scrout;
+ return ($scrout,0);
}
}
@@ -1472,13 +1473,16 @@
# phase one takes
# my ($source,$target,$style,$batch)=@_;
- $r->print('<p>'.&publish($srcfile,$targetfile,$thisembstyle,1).'</p>');
+ my ($outstring,$error)=&publish($srcfile,$targetfile,$thisembstyle,1);
+ $r->print('<p>'.$outstring.'</p>');
# phase two takes
# my ($source,$target,$style,$distarget,batch)=@_;
# $ENV{'form.allmeta'},$ENV{'form.title'},$ENV{'form.author'},...
- $r->print('<p>');
- &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);
- $r->print('</p>');
+ if (!$error) {
+ $r->print('<p>');
+ &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);
+ $r->print('</p>');
+ }
return '';
}
@@ -1593,7 +1597,7 @@
# -------------------------------------------------------------- Check filename
- my $fn=$ENV{'form.filename'};
+ my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
unless ($fn) {
@@ -1723,13 +1727,12 @@
# ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
unless ($ENV{'form.phase'} eq 'two') {
- $r->print(
- '<hr />'.&publish($thisfn,$thistarget,$thisembstyle));
+ my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);
+ $r->print('<hr />'.$outstring);
} else {
$r->print('<hr />');
&phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget);
- }
-
+ }
}
$r->print('</body></html>');