');
+ if ($bad_email) {
+ $r->print(&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message,$bad_email)).'
');
+ }
+ if ($reqemail ne '') {
+ $from = $reqemail;
+ }
+
+ 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;
+ $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 ($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.";
- } else {
- $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
+ my $showsize = '';
+
+ if ((defined($env{'user.name'})) && (!$public)) {
+ if ($homeserver && $env{'form.screenshot.filename'}) {
+ unless ($helpform{'screenshot'} eq 'no') {
+ my $attachmentsize = length($env{'form.screenshot'});
+ my $max = 1048576;
+ my $showmax = 1.00;
+ if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
+ $max *= $helpform{'maxsize'};
+ $showmax = $helpform{'maxsize'};
+ }
+ $showmax = '('.sprintf("%.2f",$showmax).' MB)';
+ $showsize = $attachmentsize/1048576;
+ $showsize = '('.sprintf("%.2f",$showsize).' MB)';
+ if ($attachmentsize > $max) {
+ $displaymsg .= '
'.
+ &mt('The uploaded screenshot file [_1] included with your request exceeded the maximum allowed size [_2], and has therefore been discarded.',$showsize,$showmax).'';
+ } else {
+ $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
+ }
}
}
}
- my %cookies = ();
+ my %cookies;
my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
- if ($$cookie{'lonID'} =~ /lonID=(\w+);/) {
+ if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
$cookies{'lonID'} = $1;
}
-
+ if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {
+ $cookies{'lonLinkID'} = $1;
+ }
+ my $lti_info;
+ if (($env{'request.lti.login'}) && ($env{'request.course.id'})) {
+ my $ltidom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ if ($ltidom) {
+ my %lti = &Apache::lonnet::get_domain_lti($ltidom,'provider');
+ if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
+ if ($lti{$env{'request.lti.login'}}{'consumer'}) {
+ $lti_info = "LTI consumer: ".$lti{$env{'request.lti.login'}}{'consumer'}."\n";
+ }
+ }
+ }
+ }
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] was included in the request sent by [_2].'
+ ,'
'.$fname.' '.$showsize,
+ ,$env{'user.name'}.':'.$env{'user.domain'}
+ );
$supportmsg .= "\n";
- foreach (@cookievars) {
- $supportmsg .= "$_: $cookies{$_}\n";
+ foreach my $var (@cookievars) {
+ $supportmsg .= "$var: $cookies{$var}\n";
+ }
+ foreach my $var(@ENVvars) {
+ $supportmsg .= "$var: $ENV{$var}\n";
}
- foreach (@ENVvars) {
- $supportmsg .= "$_: $ENV{$_}\n";
+ $supportmsg .= "REMOTE_ADDR: $ip\n";
+ foreach my $var (@envvars) {
+ $supportmsg .= "$var: $env{$var}\n";
}
- foreach (@envvars) {
- $supportmsg .= "$_: $env{$_}\n";
+ if ($lti_info) {
+ $supportmsg .= $lti_info;
}
}
-
- my $msg = MIME::Lite->new(
- From => $from,
- To => $to,
- Subject => $subject,
- Type =>'TEXT',
- Data => $supportmsg,
- );
-
- if ($attachmentpath) {
- my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
- $msg->attach(Type => $type,
- Path => $attachmentpath,
- Filename => $fname
- );
- } else {
- my $envdata = '';
- foreach (@cookievars) {
- $envdata .= "$_: $cookies{$_}\n";
+ my $cc_string;
+ if ($homeserver) {
+ if (@ok_ccs > 0) {
+ $cc_string = join(', ',@ok_ccs);
}
- foreach (@ENVvars) {
- $envdata .= "$_: $ENV{$_}\n";
+ }
+
+ my $attachment_text = '';
+ unless ($homeserver && $attachmentpath) {
+ foreach my $var (@cookievars) {
+ $attachment_text .= "$var: $cookies{$var}\n";
+ }
+ foreach my $var (@ENVvars) {
+ $attachment_text .= "$var: $ENV{$var}\n";
}
- foreach (@envvars) {
- $envdata .= "$_: $env{$_}\n";
+ $attachment_text .= "REMOTE_ADDR: $ip\n";
+ foreach my $var (@envvars) {
+ $attachment_text .= "$var: $env{$var}\n";
}
- foreach (@loncvars) {
- $envdata .= "$_: $env{$_}\n";
+ foreach my $var (@loncvars) {
+ $attachment_text .= "$var: $env{$var}\n";
+ }
+ if ($lti_info) {
+ $attachment_text .= $lti_info;
}
- $msg->attach(Type => 'TEXT',
- Data => $envdata);
}
-### Send it:
- $msg->send('sendmail');
+ if ($addtext) {
+ my ($addloc,$addstr) = split(/:/,$addtext,2);
+ $addstr = &unescape($addstr);
+ if ($addloc eq 's') {
+ $subject = $addstr.' '.$subject;
+ } elsif ($addloc eq 'b') {
+ $supportmsg = $addstr."\n".$supportmsg;
+ }
+ }
- if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) {
+ if ($bad_email) {
+ $r->print('
'.$lt{'belo'}.''.
+ $lt{'ifyk'}."\n");
+ } else {
+ # Compose and send a MIME email
+ &Apache::loncommon::mime_email($from,'',$to,$subject,$supportmsg,$cc_string,
+ $bcc,$attachmentpath,$fname,$attachment_text);
+ $r->print('
'.$lt{'your'}.':'."\n");
+ }
+ if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
unlink($attachmentpath);
}
- $r->print(qq|
-
Your support request contained the following information:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Information supplied
- |
-
-
- |
-
-
- |
-
-
-
- 
- |
-
-
-
-
-
- Additional information recorded
- |
-
-
- |
-
-
-
-
- |);
- foreach (@cookievars) {
- unless($cookies{$_} eq '') {
- $r->print("$_: $cookies{$_}, ");
- }
- }
- foreach (@ENVvars) {
- unless($ENV{$_} eq '') {
- $r->print("$_: $ENV{$_}, ");
- }
- }
- foreach (@envvars) {
- unless($env{$_} eq '') {
- $r->print("$_: $env{$_}, ");
- }
- }
- $r->print("
- |
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
- ");
- $r->print(&Apache::loncommon::end_page());
+ $r->print('
'.
+ &Apache::lonhtmlcommon::start_pick_box().
+ &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
+ &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value'));
+ my $envmsg;
+ foreach my $var (@cookievars) {
+ if ($cookies{$var} ne '') {
+ $envmsg.= ''.
+ $var.': '.$cookies{$var}.', ';
+ }
+ }
+ foreach my $var (@ENVvars) {
+ if ($ENV{$var} ne '') {
+ $envmsg .= ''.
+ $var.': '.$ENV{$var}.', ';
+ }
+ }
+ if ($ip ne '') {
+ $envmsg .= ''.
+ 'REMOTE_ADDR: '.$ip.', ';
+ }
+ foreach my $var (@envvars) {
+ if ($env{$var} ne '') {
+ $envmsg .= ''.
+ $var.': '.$env{$var}.', ';
+ }
+ }
+ $envmsg =~ s/, $//;
+ $r->print($envmsg."\n".
+ &Apache::lonhtmlcommon::row_closure(1)."\n".
+ &Apache::lonhtmlcommon::end_pick_box().
+ '
');
+ unless ($bad_email) {
+ $r->print('
'.&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message)).'
');
+ }
+ $r->print("
\n".
+ &Apache::loncommon::end_page());
}
sub print_header {
- my ($r,$origurl,$action) = @_;
+ my ($r,$origurl,$command) = @_;
my $location=&Apache::loncommon::lonhttpdurl("/adm");
- my $tablecolor = '#EEEE99';
my ($component_url);
- my $helpdesk_link = '