--- loncom/interface/lonsupportreq.pm 2014/01/20 17:25:41 1.78
+++ loncom/interface/lonsupportreq.pm 2017/01/18 21:07:31 1.85
@@ -1,5 +1,5 @@
#
-# $Id: lonsupportreq.pm,v 1.78 2014/01/20 17:25:41 bisitz 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,18 +77,18 @@ 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);
+ $formname,$public,$homeserver,$knownuser,$captcha_form,$captcha_error,
+ $captcha,$recaptcha_version);
$function = &Apache::loncommon::get_users_function() if (!$function);
$ccode = '';
$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 {
@@ -105,6 +103,14 @@ sub print_request_form {
}
}
}
+ if (($env{'user.name'} =~ /^$match_username$/) &&
+ ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
+ $knownuser = 1;
+ } else {
+ my $lonhost = $r->dir_config('lonHostID');
+ ($captcha_form,$captcha_error,$captcha,$recaptcha_version) =
+ &Apache::loncommon::captcha_display('login',$lonhost);
+ }
if ($homeserver) {
$uhome = $env{'user.home'};
$urole = $env{'request.role'};
@@ -116,11 +122,13 @@ sub print_request_form {
my $sourceurl = $machine.$origurl;
$server = $machine.&Apache::loncommon::cleanup_html($origurl);
$server =~ s/\?.*$//;
- my %lt = &Apache::lonlocal::texthash (
+ my %js_lt = &Apache::lonlocal::texthash (
email => 'The e-mail address you entered',
notv => 'is not a valid e-mail address',
rsub => 'You must include a subject',
rdes => 'You must include a description',
+ );
+ my %html_lt = &Apache::lonlocal::texthash (
name => 'Name',
subm => 'Submit Request',
emad => 'Your e-mail address',
@@ -143,22 +151,24 @@ 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',
);
+ &js_escape(\%js_lt);
+ &html_escape(\%html_lt);
my $scripttag = (<<"END");
function validate() {
if (validmail(document.logproblem.email) == false) {
- alert("$lt{'email'}: "+document.logproblem.email.value+" $lt{'notv'}.");
+ alert("$js_lt{'email'}: "+document.logproblem.email.value+" $js_lt{'notv'}.");
return;
}
if (document.logproblem.subject.value == '') {
- alert("$lt{'rsub'}.");
+ alert("$js_lt{'rsub'}.");
return;
}
if (document.logproblem.description.value == '') {
- alert("$lt{'rdes'}.");
+ alert("$js_lt{'rdes'}.");
return;
}
document.logproblem.submit();
@@ -257,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 = '';
}
}
@@ -271,7 +281,11 @@ $jscript
$loaditems
// ]]>
+
ENDJS
+ if ($recaptcha_version >=2) {
+ $js.= "\n".''."\n";
+ }
my %add_entries = (
style => "margin-top:0px;margin-bottom:0px;",
onload => "initialize_codes();",
@@ -299,7 +313,7 @@ ENDJS
&mt('(All fields marked with * are required.)').
''.
&Apache::lonhtmlcommon::row_closure().
- &Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n";
+ &Apache::lonhtmlcommon::row_title($html_lt{'name'},undef,$css[$num])."\n";
my $fullname = '';
if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
$fullname = "$firstname $lastname";
@@ -312,76 +326,75 @@ ENDJS
}
$output .= '&').'" />'."\n";
}
- $output .= ' '.
+ $output .= ' '.
&Apache::lonhtmlcommon::row_closure()."\n";
$num ++;
$i = $num%2;
$output .= &Apache::lonhtmlcommon::row_title(
''.
- $lt{'emad'}.' *'
+ $html_lt{'emad'}.' *'
,undef,$css[$i]).
'&').'" />
'."\n".
&Apache::lonhtmlcommon::row_closure();
$num ++;
$i = $num%2;
- if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
- if ($homeserver) {
- $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]).
+ if ($knownuser) {
+ if ($homeserver) {
+ $output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]).
'
'."\n".
&Apache::lonhtmlcommon::row_closure();
$num ++;
$i = $num%2;
}
}
- $output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]);
+ $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'unme'}/$html_lt{'doma'}",undef,$css[$i]);
my $udom_input = '&').'" />'."\n";
my $uname_input = '&').'" />'."\n";
- if (($env{'user.name'} =~ /^$match_username$/) &&
- ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
- $output .= ''.$lt{'unme'}.': '.$uname.' '.$lt{'doma'}.': '.$udom.$udom_input.$uname_input;
+ if ($knownuser) {
+ $output .= ''.$html_lt{'unme'}.': '.$uname.' '.$html_lt{'doma'}.': '.$udom.$udom_input.$uname_input;
} else {
my $udomform = '';
my $unameform = '';
if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
- $output .= $lt{'entu'};
+ $output .= $html_lt{'entu'};
} elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
- $output .= $lt{'chdo'};
+ $output .= $html_lt{'chdo'};
} else {
- $output .= $lt{'entr'};
+ $output .= $html_lt{'entr'};
}
$output .= '
'."\n";
if (!$public) {
if ($env{'user.domain'} =~ /^$match_domain$/) {
- $udomform = ''.$lt{'doma'}.': '.$udom.$udom_input;
+ $udomform = ''.$html_lt{'doma'}.': '.$udom.$udom_input;
} elsif ($env{'user.name'} =~ /^$match_username$/) {
- $unameform = ''.$lt{'unme'}.': '.$uname.' '.$uname_input;
+ $unameform = ''.$html_lt{'unme'}.': '.$uname.' '.$uname_input;
}
}
if ($udomform eq '') {
- $udomform = ''.$lt{'doma'}.': ';
+ $udomform = ''.$html_lt{'doma'}.': ';
$udomform .= &Apache::loncommon::select_dom_form($codedom,'udom')."\n";
}
if ($unameform eq '') {
- $unameform= ''.$lt{'unme'}.': ';
+ $unameform= ''.$html_lt{'unme'}.': ';
}
$output .= $unameform.$udomform;
}
$output .= &Apache::lonhtmlcommon::row_closure();
$num ++;
$i = $num%2;
- $output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]).
+ $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]).
$server."\n".'&').'" />'."\n".
&Apache::lonhtmlcommon::row_closure().
- &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value').
+ &Apache::lonhtmlcommon::row_title("$html_lt{'phon'}",undef,'LC_evenrow_value').
'
'."\n".
&Apache::lonhtmlcommon::row_closure();
$num ++;
$i = $num%2;
- $output .= &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,$css[$i]);
+ $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]);
if ($cnum) {
if ($coursecodes{$cnum}) {
foreach my $item (@codetitles) {
@@ -389,14 +402,14 @@ ENDJS
}
$output .= ' &').'" />'."\n";
} else {
- $output .= $lt{'enin'}.':
+ $output .= $html_lt{'enin'}.':
'."\n";
}
} else {
if ($totcodes > 0) {
my $numtitles = @codetitles;
if ($numtitles == 0) {
- $output .= $lt{'enin'}.':
+ $output .= $html_lt{'enin'}.':
'."\n";
} else {
my @standardnames = &Apache::loncommon::get_standard_codeitems();
@@ -406,7 +419,7 @@ ENDJS
}
$output .= '
'.$codetitles[0].' '."\n". ' |