--- loncom/interface/lonsupportreq.pm 2016/08/12 18:23:32 1.79.2.1
+++ loncom/interface/lonsupportreq.pm 2017/01/18 21:07:31 1.85
@@ -1,5 +1,5 @@
#
-# $Id: lonsupportreq.pm,v 1.79.2.1 2016/08/12 18:23:32 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.85 2017/01/18 21:07:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,8 +27,6 @@
package Apache::lonsupportreq;
use strict;
-use MIME::Types;
-use MIME::Lite;
use CGI::Cookie();
use Apache::Constants qw(:common);
use Apache::loncommon();
@@ -79,10 +77,10 @@ sub handler {
}
return OK;
}
-
+
sub print_request_form {
my ($r,$origurl,$function) = @_;
- my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,
+ my ($os,$browser,$bversion,$uname,$udom,$uhome,$urole,$usec,$email,$cid,
$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,
$formname,$public,$homeserver,$knownuser,$captcha_form,$captcha_error,
$captcha,$recaptcha_version);
@@ -91,7 +89,6 @@ sub print_request_form {
$os = $env{'browser.os'};
$browser = $env{'browser.type'};
$bversion = $env{'browser.version'};
- $uhost = $env{'request.host'};
if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
$public = 1;
} else {
@@ -106,7 +103,7 @@ sub print_request_form {
}
}
}
- if (($env{'user.name'} =~ /^$match_username$/) &&
+ if (($env{'user.name'} =~ /^$match_username$/) &&
($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
$knownuser = 1;
} else {
@@ -154,7 +151,7 @@ sub print_request_form {
subj => 'Subject',
detd => 'Detailed Description',
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',
clfm => 'Clear Form',
);
@@ -270,7 +267,7 @@ function initialize_codes() {
my $allidlist = $idlist{$codetitles[0]};
$jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);
$jscript .= $scripttext;
- $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,@codetitles);
+ $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,\@codetitles);
$loaditems = '';
}
}
@@ -284,6 +281,7 @@ $jscript
$loaditems
// ]]>
+
ENDJS
if ($recaptcha_version >=2) {
$js.= "\n".''."\n";
@@ -342,7 +340,7 @@ ENDJS
$num ++;
$i = $num%2;
if ($knownuser) {
- if ($homeserver) {
+ if ($homeserver) {
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]).
'
'."\n".
&Apache::lonhtmlcommon::row_closure();
@@ -517,10 +515,11 @@ ENDJS
$i = $num%2;
if ($knownuser) {
if ($homeserver) {
- $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]).
- '
'.
- "\n".$html_lt{'uplf'}."\n".
- &Apache::lonhtmlcommon::row_closure();
+ $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i])
+ .' '
+ .''
+ .'
'."\n".$html_lt{'uplf'}."\n"
+ .&Apache::lonhtmlcommon::row_closure();
$num ++;
$i = $num%2;
}
@@ -851,9 +850,9 @@ END
if ((defined($env{'user.name'})) && (!$public)) {
if ($homeserver && $env{'form.screenshot.filename'}) {
$attachmentsize = length($env{'form.screenshot'});
- if ($attachmentsize > 131072) {
+ if ($attachmentsize > 1048576) {
$displaymsg .= '
'.
- &mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.',$attachmentsize).'';
+ &mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 1 MB, and has therefore been discarded.',$attachmentsize).'';
} else {
$attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
}
@@ -886,33 +885,15 @@ END
}
}
- my $msg = MIME::Lite->new(
- From => $from,
- To => $to,
- Subject => $subject,
- Type =>'TEXT',
- Data => $supportmsg,
- );
+ my $cc_string;
if ($homeserver) {
if (@ok_ccs > 0) {
- my $cc_string = join(', ',@ok_ccs);
- $msg->add("Cc" => $cc_string);
+ $cc_string = join(', ',@ok_ccs);
}
}
- 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 = '';
foreach my $var (@cookievars) {
$envdata .= "$var: $cookies{$var}\n";
@@ -926,12 +907,12 @@ END
foreach my $var (@loncvars) {
$envdata .= "$var: $env{$var}\n";
}
- $msg->attach(Type => 'TEXT',
- Data => $envdata);
+ $attachment_text = $envdata;
}
-
-### Send it:
- $msg->send('sendmail');
+
+ # Compose and send a MIME email
+ &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+)/[^/]+|) {
unlink($attachmentpath);