--- loncom/interface/lonsupportreq.pm 2017/10/15 03:43:52 1.79.2.3.2.1
+++ loncom/interface/lonsupportreq.pm 2017/02/25 20:00:47 1.91
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Helpdesk request form
#
-# $Id: lonsupportreq.pm,v 1.79.2.3.2.1 2017/10/15 03:43:52 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.91 2017/02/25 20:00:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,8 +29,6 @@
package Apache::lonsupportreq;
use strict;
-use MIME::Types;
-use MIME::Lite;
use CGI::Cookie();
use Apache::Constants qw(:common);
use Apache::loncommon();
@@ -315,6 +313,7 @@ $jscript
$loaditems
// ]]>
+
ENDJS
if ($recaptcha_version >=2) {
$js.= "\n".''."\n";
@@ -574,10 +573,11 @@ ENDJS
$showmax = $helpform{'maxsize'};
}
$showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')';
- $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]).
- '
'.
- "\n".$html_lt{'uplf'}.$showmax."\n".
- &Apache::lonhtmlcommon::row_closure();
+ $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i])
+ .' '
+ .''
+ .'
'."\n".$html_lt{'uplf'}.$showmax."\n"
+ .&Apache::lonhtmlcommon::row_closure();
$num ++;
$i = $num%2;
}
@@ -657,11 +657,19 @@ sub print_request_receipt {
my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
- my @cookievars = ('lonID');
+ my @cookievars;
+ if ($ENV{'SERVER_PORT'} == 443) {
+ @cookievars = ('lonLinkID');
+ } else {
+ @cookievars = ('lonID');
+ }
my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
my $defdom = &get_domain();
+ my ($to,$bcc,$addtext) =
+ &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
+ $defdom,$origmail);
my $from = $admin;
my %helpform;
my %domconfig =
@@ -875,33 +883,6 @@ $lt{'date'}: $reporttime
}
}
}
-
- my ($requname,$requdom,$reqemail);
- foreach my $field ('uname','udom','email') {
- $env{'form.'.$field} =~ s/^\s+//;
- $env{'form.'.$field} =~ s/\s+$//;
- }
- if ($env{'form.uname'} =~ /^$match_username$/) {
- $requdom = $env{'form.udom'};
- }
- if ($env{'form.udom'} =~ /^$match_domain$/) {
- $requdom = $env{'form.udom'};
- }
- if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
- $reqemail = $env{'form.email'};
- }
-
- my $dom_in_effect;
- unless ($env{'user.domain'} eq 'public') {
- $dom_in_effect = $env{'user.domain'};
- }
- if ($dom_in_effect eq '') {
- $dom_in_effect = $requdom;
- }
- if ($dom_in_effect eq '') {
- $dom_in_effect = $defdom;
- }
-
$displaymsg .= ''.
$lt{'date'}.': '.$reporttime.'
'."\n";
@@ -924,11 +905,6 @@ END
&print_header($r,$url,'process');
}
my $bad_email = 0;
- my ($to,$bcc,$addtext) =
- &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
- $dom_in_effect,$origmail,
- $requname,$requdom,
- $reqemail);
if ($to =~ /,/) {
my @ok_email;
foreach my $email (split(/,/,$to)) {
@@ -966,8 +942,12 @@ END
}
$r->print(&Apache::loncommon::confirmwrapper($message));
- if ($reqemail ne '') {
- $from = $reqemail;
+ if (defined($env{'form.email'})) {
+ $env{'form.email'} =~ s/^\s+//;
+ $env{'form.email'} =~ s/\s+$//;
+ if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
+ $from = $env{'form.email'};
+ }
}
if (defined($env{'form.cc'})) {
@@ -1016,7 +996,9 @@ END
if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
$cookies{'lonID'} = $1;
}
-
+ if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {
+ $cookies{'lonLinkID'} = $1;
+ }
if ($attachmentpath =~ m-/([^/]+)$-) {
$fname = $1;
$displaymsg .= '
'
@@ -1057,6 +1039,7 @@ END
foreach my $var (@loncvars) {
$attachment_text .= "$var: $env{$var}\n";
}
+ $attachment_text = $envdata;
}
if ($addtext) {
@@ -1069,39 +1052,9 @@ END
}
}
- my $msg = MIME::Lite->new(
- From => $from,
- To => $to,
- Subject => $subject,
- Type =>'TEXT',
- Data => $supportmsg,
- );
- if ($homeserver) {
- if (@ok_ccs > 0) {
- my $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
- );
-
- } elsif ($attachment_text ne '') {
- $msg->attach(Type => 'TEXT',
- Data => $attachment_text);
- }
-
-### 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);