--- loncom/interface/lonsupportreq.pm 2019/06/16 05:49:43 1.95
+++ loncom/interface/lonsupportreq.pm 2024/07/15 17:12:40 1.106
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Helpdesk request form
#
-# $Id: lonsupportreq.pm,v 1.95 2019/06/16 05:49:43 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.106 2024/07/15 17:12:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,7 +68,7 @@ sub handler {
}
my $origurl = $env{'form.origurl'};
if ($origurl =~ m{^https?://[^/]+(.*)$}) {
- $origurl =~ $1;
+ $origurl = $1;
}
$origurl =~ s/(`)//g;
$origurl =~ s/\$/\(\$\)/g;
@@ -151,7 +151,6 @@ sub print_request_form {
}
}
- my %coursecodes;
my %codes;
my @codetitles;
my %cat_titles;
@@ -159,9 +158,7 @@ sub print_request_form {
my %idlist;
my %idnums;
my %idlist_titles;
- my $caller = 'global';
my $totcodes = 0;
- my $format_reply;
my $jscript = '';
my $loaditems = qq|
function initialize_codes() {
@@ -169,10 +166,17 @@ function initialize_codes() {
}
|;
unless ($helpform{'course'} eq 'no') {
- $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom);
- if ($totcodes > 0) {
- $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
- if ($format_reply eq 'ok') {
+ my $instcats = &Apache::lonnet::get_dom_instcats($codedom);
+ if (ref($instcats) eq 'HASH') {
+ if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
+ (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
+ %codes = %{$instcats->{'codes'}};
+ @codetitles = @{$instcats->{'codetitles'}};
+ %cat_titles = %{$instcats->{'cat_titles'}};
+ %cat_order = %{$instcats->{'cat_order'}};
+ $totcodes = scalar(keys(%codes));
+ }
+ if ($totcodes > 0) {
my $numtypes = @codetitles;
&Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
@@ -315,9 +319,10 @@ $jscript
$loaditems
// ]]>
-
ENDJS
- if ($recaptcha_version >=2) {
+ if ($knownuser) {
+ $js .="\n".'';
+ } elsif ($recaptcha_version >=2) {
$js.= "\n".''."\n";
}
my %add_entries = (
@@ -386,7 +391,11 @@ ENDJS
$i = $num%2;
if ($knownuser) {
if ($homeserver) {
- unless ($helpform{'cc'} eq 'no') {
+ my $ip = &Apache::lonnet::get_requestor_ip($r);
+ my %setters;
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'com',$ip);
+ unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]).
'
'."\n".
&Apache::lonhtmlcommon::row_closure();
@@ -457,7 +466,7 @@ ENDJS
my $numtitles = @codetitles;
if ($numtitles == 0) {
$output .= $html_lt{'enin'}.':
- '."\n";
+ ').'" />'."\n";
} else {
my @standardnames = &Apache::loncommon::get_standard_codeitems();
my $lasttitle = $numtitles;
@@ -578,8 +587,8 @@ ENDJS
}
$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();
$num ++;
@@ -658,7 +667,11 @@ sub print_request_receipt {
return;
}
}
- my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
+ my $ip = &Apache::lonnet::get_requestor_ip($r);
+ my %setters;
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'com',$ip);
+ my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','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;
@@ -703,7 +716,7 @@ sub print_request_receipt {
unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) {
$formvars{'course'} = 1;
}
- unless ($helpform{'cc'} eq 'no') {
+ unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
$formvars{'cc'} = 1;
}
unless ($helpform{'screenshot'} eq 'no') {
@@ -714,8 +727,12 @@ sub print_request_receipt {
$coursecode = $env{'form.coursecode'};
if ($coursecode eq '') {
my $totcodes = 0;
- my %coursecodes;
- $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom);
+ my $instcats = &Apache::lonnet::get_dom_instcats($defdom);
+ if (ref($instcats) eq 'HASH') {
+ if (ref($instcats->{'codes'}) eq 'HASH') {
+ $totcodes = scalar(keys(%{$instcats->{'codes'}}));
+ }
+ }
my @standardnames = &Apache::loncommon::get_standard_codeitems();
if ($totcodes > 0) {
my $noregexps = 1;
@@ -745,6 +762,8 @@ sub print_request_receipt {
secn => 'Section',
warn => 'Warning: Problem with support e-mail address',
your => 'Your support request contained the following information',
+ belo => 'Below is your support request which could not be sent',
+ ifyk => 'If you know an IT support address for your institution, you could copy this information and send it to that email address.',
sect => 'section',
info => 'Information supplied',
adin => 'Additional information recorded',
@@ -973,16 +992,16 @@ END
my $message;
if (!$bad_email) {
- $message = &Apache::lonhtmlcommon::confirm_success(
- &mt('A support request has been sent to [_1]',''.$to.''));
+ $message = &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';
+ $message = $lt{'warn'}.'
';
+ if ($to eq '') {
+ $message .= &mt('For this LON-CAPA server no e-mail address has been configured to receive support requests, so your support request has [_1]not[_2] been sent to the LON-CAPA support staff or administrator at your institution.','','');
+ } else {
+ $message .= &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.'','','');
+ }
}
- $r->print(&Apache::loncommon::confirmwrapper($message));
+ $r->print(&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message,$bad_email)));
if ($reqemail ne '') {
$from = $reqemail;
@@ -1063,6 +1082,7 @@ END
foreach my $var(@ENVvars) {
$supportmsg .= "$var: $ENV{$var}\n";
}
+ $supportmsg .= "REMOTE_ADDR: $ip\n";
foreach my $var (@envvars) {
$supportmsg .= "$var: $env{$var}\n";
}
@@ -1086,6 +1106,7 @@ END
foreach my $var (@ENVvars) {
$attachment_text .= "$var: $ENV{$var}\n";
}
+ $attachment_text .= "REMOTE_ADDR: $ip\n";
foreach my $var (@envvars) {
$attachment_text .= "$var: $env{$var}\n";
}
@@ -1107,14 +1128,18 @@ END
}
}
- # Compose and send a MIME email
- &Apache::loncommon::mime_email($from, $to, $subject, $supportmsg, $cc_string, $bcc,
- $attachmentpath, $fname, $attachment_text);
-
+ 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(''.$lt{'your'}.':
'."\n");
$r->print('