END
+ if ($r->uri eq '/adm/helpdesk') {
+ &print_header($r,$url,'process');
+ }
+ my $bad_email = 0;
+ if ($to =~ /,/) {
+ my @ok_email;
+ foreach my $email (split(/,/,$to)) {
+ if ($email =~ m/^[^\@]+\@[^\@]+$/) {
+ if (!grep(/^\Q$email\E$/,@ok_email)) {
+ push(@ok_email,$email);
+ }
+ }
+ }
+ if (@ok_email > 0) {
+ $to = join(',',@ok_email);
+ } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) {
+ $to = $admin;
} else {
- $r->print(<
-
- LON-CAPA support request recorded
-
-$bodytag
-
Warning: Problem with support e-mail address
-As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University.
-END
- $to = 'helpdesk@lon-capa.org';
+ $bad_email = 1;
+ }
+ } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) {
+ if ($admin =~ m/^[^\@]+\@[^\@]+$/) {
+ $to = $admin;
+ } else {
+ $bad_email = 1;
+ }
+ }
+
+ my $message;
+ if (!$bad_email) {
+ $message = &Apache::lonhtmlcommon::confirm_success(
+ &mt('A support request has been sent to [_1]',''.$to.''));
+ } else {
+ $message = &Apache::lonhtmlcommon::confirm_success(
+ $lt{'warn'}.' '
+ .&mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.',''.$to.'','','')
+ .' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1);
+ $to = 'helpdesk@lon-capa.org';
+ }
+ $r->print(&Apache::loncommon::confirmwrapper($message));
+
+ 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.email'})) {
- if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
- $from = $ENV{'form.email'};
+
+ if (defined($env{'form.cc'})) {
+ if ($badccmsg) {
+ $displaymsg .= $badccmsg;
}
}
- my $subject = $ENV{'form.subject'};
- $subject =~ s#(`)#'#g;
- $subject =~ s#\$#\(\$\)#g;
- $supportmsg =~ s#(`)#'#g;
- $supportmsg =~ s#\$#\(\$\)#g;
- $displaymsg =~ s#(`)#'#g;
- $displaymsg =~ s#\$#\(\$\)#g;
+ my $subject = $env{'form.subject'};
+ $subject =~ s/(`)/'/g;
+ $subject =~ s/\$/\(\$\)/g;
+ $supportmsg =~ s/(`)/'/g;
+ $supportmsg =~ s/\$/\(\$\)/g;
+ $displaymsg =~ s/(`)/'/g;
+ $displaymsg =~ s/\$/\(\$\)/g;
my $fname;
my $attachmentpath = '';
my $attachmentsize = '';
- if (defined($ENV{'user.name'})) {
- if ($ENV{'form.screenshot.filename'}) {
- $attachmentsize = length($ENV{'form.screenshot'});
+ if ((defined($env{'user.name'})) && (!$public)) {
+ if ($homeserver && $env{'form.screenshot.filename'}) {
+ $attachmentsize = length($env{'form.screenshot'});
if ($attachmentsize > 131072) {
- $displaymsg .= " The uploaded screenshot file ($attachmentsize bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.";
+ $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);
} else {
$attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
}
}
}
+ my %cookies;
+ my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
+ if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
+ $cookies{'lonID'} = $1;
+ }
+
if ($attachmentpath =~ m-/([^/]+)$-) {
$fname = $1;
- $displaymsg .= " An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $ENV{'user.name'} from LON-CAPA domain: $ENV{'user.domain'}";
+ $displaymsg .= ' '
+ .&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].'
+ ,''.$fname.''
+ ,$attachmentsize
+ ,$env{'user.name'}.':'.$env{'user.domain'}
+ );
$supportmsg .= "\n";
- foreach (@envvars) {
- $supportmsg .= "$_: $ENV{$_}\n";
+ foreach my $var (@cookievars) {
+ $supportmsg .= "$var: $cookies{$var}\n";
+ }
+ foreach my $var(@ENVvars) {
+ $supportmsg .= "$var: $ENV{$var}\n";
+ }
+ foreach my $var (@envvars) {
+ $supportmsg .= "$var: $env{$var}\n";
}
}
@@ -683,8 +858,19 @@ END
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 ($attachmentpath) {
+ if ($homeserver && $attachmentpath) {
my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
$msg->attach(Type => $type,
Path => $attachmentpath,
@@ -693,395 +879,177 @@ END
} else {
my $envdata = '';
- foreach (@envvars) {
- $envdata .= "$_: $ENV{$_}\n";
+ foreach my $var (@cookievars) {
+ $envdata .= "$var: $cookies{$var}\n";
+ }
+ foreach my $var (@ENVvars) {
+ $envdata .= "$var: $ENV{$var}\n";
+ }
+ foreach my $var (@envvars) {
+ $envdata .= "$var: $env{$var}\n";
}
- foreach (@loncvars) {
- $envdata .= "$_: $ENV{$_}\n";
+ foreach my $var (@loncvars) {
+ $envdata .= "$var: $env{$var}\n";
}
$msg->attach(Type => 'TEXT',
Data => $envdata);
}
### Send it:
- # ->send can cause an sh launch which can pass all of %ENV along
- # which can be to large for /bin/sh's little mind
- my %oldENV=%ENV;
- undef(%ENV);
$msg->send('sendmail');
- %ENV=%oldENV;
- undef(%oldENV);
- if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) {
+ if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
unlink($attachmentpath);
}
- $r->print(qq|
- Your support request contained the following information: