version 1.79, 2015/06/09 21:22:57
|
version 1.81, 2015/06/23 02:42:34
|
Line 27
|
Line 27
|
package Apache::lonsupportreq; |
package Apache::lonsupportreq; |
|
|
use strict; |
use strict; |
use MIME::Types; |
|
use MIME::Lite; |
|
use CGI::Cookie(); |
use CGI::Cookie(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon(); |
use Apache::loncommon(); |
Line 145 sub print_request_form {
|
Line 143 sub print_request_form {
|
subj => 'Subject', |
subj => 'Subject', |
detd => 'Detailed Description', |
detd => 'Detailed Description', |
opfi => 'Optional file upload', |
opfi => 'Optional file upload', |
uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (128 KB max.)', |
uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (1 MB max.)', |
fini => 'Finish', |
fini => 'Finish', |
clfm => 'Clear Form', |
clfm => 'Clear Form', |
); |
); |
Line 275 $jscript
|
Line 273 $jscript
|
$loaditems |
$loaditems |
// ]]> |
// ]]> |
</script> |
</script> |
|
<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script> |
ENDJS |
ENDJS |
my %add_entries = ( |
my %add_entries = ( |
style => "margin-top:0px;margin-bottom:0px;", |
style => "margin-top:0px;margin-bottom:0px;", |
Line 506 ENDJS
|
Line 505 ENDJS
|
$i = $num%2; |
$i = $num%2; |
if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
if ($homeserver) { |
if ($homeserver) { |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]). |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]) |
' <input type="file" name="screenshot" size="20" /><br />'. |
.' <input type="file" name="screenshot" class="flUpload" size="20" />' |
"\n".$html_lt{'uplf'}."\n". |
.'<input type="hidden" id="free_space" value="1048576" />' |
&Apache::lonhtmlcommon::row_closure(); |
.'<br />'."\n".$html_lt{'uplf'}."\n" |
|
.&Apache::lonhtmlcommon::row_closure(); |
$num ++; |
$num ++; |
$i = $num%2; |
$i = $num%2; |
} |
} |
Line 843 END
|
Line 843 END
|
if ((defined($env{'user.name'})) && (!$public)) { |
if ((defined($env{'user.name'})) && (!$public)) { |
if ($homeserver && $env{'form.screenshot.filename'}) { |
if ($homeserver && $env{'form.screenshot.filename'}) { |
$attachmentsize = length($env{'form.screenshot'}); |
$attachmentsize = length($env{'form.screenshot'}); |
if ($attachmentsize > 131072) { |
if ($attachmentsize > 1048576) { |
$displaymsg .= '<br /><span class="LC_warning">'. |
$displaymsg .= '<br /><span class="LC_warning">'. |
&mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.',$attachmentsize).'</span>'; |
&mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 1 MB, and has therefore been discarded.',$attachmentsize).'</span>'; |
} else { |
} else { |
$attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests'); |
$attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests'); |
} |
} |
Line 878 END
|
Line 878 END
|
} |
} |
} |
} |
|
|
my $msg = MIME::Lite->new( |
my $cc_string; |
From => $from, |
|
To => $to, |
|
Subject => $subject, |
|
Type =>'TEXT', |
|
Data => $supportmsg, |
|
); |
|
if ($homeserver) { |
if ($homeserver) { |
if (@ok_ccs > 0) { |
if (@ok_ccs > 0) { |
my $cc_string = join(', ',@ok_ccs); |
$cc_string = join(', ',@ok_ccs); |
$msg->add("Cc" => $cc_string); |
|
} |
} |
} |
} |
if ($bcc ne '') { |
|
$msg->add("Bcc" => $bcc); |
|
} |
|
$msg->attr("content-type" => "text/plain"); |
|
$msg->attr("content-type.charset" => "UTF-8"); |
|
|
|
if ($homeserver && $attachmentpath) { |
|
my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); |
|
$msg->attach(Type => $type, |
|
Path => $attachmentpath, |
|
Filename => $fname |
|
); |
|
|
|
} else { |
my $attachment_text; |
|
unless ($homeserver && $attachmentpath) { |
my $envdata = ''; |
my $envdata = ''; |
foreach my $var (@cookievars) { |
foreach my $var (@cookievars) { |
$envdata .= "$var: $cookies{$var}\n"; |
$envdata .= "$var: $cookies{$var}\n"; |
Line 918 END
|
Line 900 END
|
foreach my $var (@loncvars) { |
foreach my $var (@loncvars) { |
$envdata .= "$var: $env{$var}\n"; |
$envdata .= "$var: $env{$var}\n"; |
} |
} |
$msg->attach(Type => 'TEXT', |
$attachment_text = $envdata; |
Data => $envdata); |
|
} |
} |
|
|
### Send it: |
# Compose and send a MIME email |
$msg->send('sendmail'); |
&Apache::loncommon::mime_email($from, $to, $subject, $supportmsg, $cc_string, $bcc, |
|
$attachmentpath, $fname, $attachment_text); |
|
|
if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { |
if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { |
unlink($attachmentpath); |
unlink($attachmentpath); |