--- loncom/interface/printout.pl 2005/06/04 20:48:33 1.82
+++ loncom/interface/printout.pl 2016/01/28 19:37:42 1.161
@@ -1,6 +1,7 @@
#!/usr/bin/perl
# CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
#
+# $Id: printout.pl,v 1.161 2016/01/28 19:37:42 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -28,42 +29,51 @@
use lib '/home/httpd/lib/perl';
use LONCAPA::loncgi;
use File::Path;
+use File::Basename;
+use File::Copy;
use IO::File;
use Image::Magick;
-use Apache::lonhtmlcommon;
+use Apache::lonhtmlcommon();
use Apache::lonnet;
-use Apache::loncommon;
+use Apache::loncommon();
use Apache::lonlocal;
-use Apache::lonmsg;
+use Apache::lonmsg();
use LONCAPA::Enrollment;
+use LONCAPA::Configuration;
use strict;
+my $busy_wait_timeout = 30;
+my $pdfs_converted = 0; # non zero if PDF includes (need to fixps).
+
+my $debugging = 0;
+
+sub debug {
+ if ($debugging) {
+ my ($text) = @_;
+ print "$text
\n";
+ }
+}
-#
# Determine if a user is operating as a student for this course/domain.
-#
-#
#Parameters:
-# course - The course id.
-# cdom - The course domain.
-#
+# none
#Implicit:
# $env{request.role} contains the role under which this user operated this
# this request.
sub is_student {
- return (! $env{'request.role.adv'});
+ return ($env{'request.role'}=~/^st\./);
}
#
# Debugging: Dump the environment for debugging.
#
sub dumpenv {
- print "
-------------------
";
+ print "
-------------------
";
foreach my $key (sort (keys %env)) {
- print "
$key -> $env{$key}";
+ print "
$key -> $env{$key}";
}
- print "
-------------------
";
+ print "
-------------------
";
}
#
@@ -111,16 +121,18 @@ sub send_error_mail {
# The user is a student in the course:
#
- if (&is_student( $courseid, $coursedom)) {
+ if (&is_student()) {
# build the subject and message body:
- # print "sending message to course coordinators.
";
+ &debug("sending message to course coordinators.");
# Todo: Convert badurl into a url from file path:
- my $subject = "Error [$badurl] Print failed for $user".'@'.$domain;
- my $message .= "Print failed to render LaTeX for $user".'@'."$domain\n";
+ my $subject = "Error [$badurl] Print failed for $user".':'.$domain;
+ my $message .= "Print failed to render LaTeX for $user".':'."$domain\n";
$message .= " User was attempting to print: \n";
- $message .= " $resources\n";
+ foreach my $resource (split(/:/,$resources)) {
+ $message .= " $resource\n";
+ }
$message .= "--------------------LaTeX logfile:------------ \n";
$message .= $logfile;
$message .= "-----------------LaTeX source file: ------------\n";
@@ -128,11 +140,11 @@ sub send_error_mail {
foreach my $line (@$texfile) {
$message .= "$line\n";
}
- my (undef, %receivers) = &Apache::lonfeedback::decide_receiver(undef, 0,
- 1,1,1);
- # print "
sending...section: $env{'request.course.sec'}";
+ my (undef, %receivers) = &Apache::lonmsg::decide_receiver(undef, 0,
+ 1,1,1);
+ &debug("sending...section: $env{'request.course.sec'}");
foreach my $dest (keys %receivers) {
- # print "
dest is $dest";
+ &debug("dest is $dest");
my @destinfo = split(/:/,$dest);
my $user = $destinfo[0];
my $dom = $destinfo[1];
@@ -159,322 +171,271 @@ Your cookie information is incorrect.