version 1.69, 2012/08/27 06:28:06
|
version 1.98, 2019/08/11 15:15:40
|
Line 1
|
Line 1
|
|
# The LearningOnline Network with CAPA |
|
# Helpdesk request form |
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 27
|
Line 29
|
package Apache::lonsupportreq; |
package Apache::lonsupportreq; |
|
|
use strict; |
use strict; |
use MIME::Types; |
|
use MIME::Lite; |
|
use CGI::Cookie(); |
use CGI::Cookie(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon(); |
use Apache::loncommon(); |
Line 39 use Apache::lonacc();
|
Line 39 use Apache::lonacc();
|
use Apache::lonauth(); |
use Apache::lonauth(); |
use Apache::courseclassifier; |
use Apache::courseclassifier; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
use HTML::Entities; |
|
|
sub handler { |
sub handler { |
my ($r) = @_; |
my ($r) = @_; |
Line 57 sub handler {
|
Line 57 sub handler {
|
if ($r->uri eq '/adm/helpdesk') { |
if ($r->uri eq '/adm/helpdesk') { |
&Apache::lonacc::get_posted_cgi($r); |
&Apache::lonacc::get_posted_cgi($r); |
} |
} |
my $function = $env{'form.function'}; |
my $function; |
|
if ($env{'form.function'}) { |
|
if (($env{'form.function'} eq 'norole') || |
|
($env{'form.function'} eq 'student') || |
|
($env{'form.function'} eq 'admin') || |
|
($env{'form.function'} eq 'author')) { |
|
$function = $env{'form.function'}; |
|
} |
|
} |
my $origurl = $env{'form.origurl'}; |
my $origurl = $env{'form.origurl'}; |
|
if ($origurl =~ m{^https?://[^/]+(.*)$}) { |
|
$origurl =~ $1; |
|
} |
|
$origurl =~ s/(`)//g; |
|
$origurl =~ s/\$/\(\$\)/g; |
my $command = $env{'form.command'}; |
my $command = $env{'form.command'}; |
|
|
if ($command eq 'process') { |
if ($command eq 'process') { |
Line 68 sub handler {
|
Line 81 sub handler {
|
} |
} |
return OK; |
return OK; |
} |
} |
|
|
sub print_request_form { |
sub print_request_form { |
my ($r,$origurl,$function) = @_; |
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, |
$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server, |
$formname,$public,$homeserver); |
$formname,$public,$homeserver,$knownuser,$captcha_form,$captcha_error, |
|
$captcha,$recaptcha_version,$extra_validations,%groupid); |
$function = &Apache::loncommon::get_users_function() if (!$function); |
$function = &Apache::loncommon::get_users_function() if (!$function); |
$ccode = ''; |
$ccode = ''; |
$os = $env{'browser.os'}; |
$os = $env{'browser.os'}; |
$browser = $env{'browser.type'}; |
$browser = $env{'browser.type'}; |
$bversion = $env{'browser.version'}; |
$bversion = $env{'browser.version'}; |
$uhost = $env{'request.host'}; |
|
if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) { |
if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) { |
$public = 1; |
$public = 1; |
} else { |
} else { |
Line 94 sub print_request_form {
|
Line 107 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); |
|
} |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom', |
|
'useremail','useraccount']); |
|
|
if ($homeserver) { |
if ($homeserver) { |
$uhome = $env{'user.home'}; |
$uhome = $env{'user.home'}; |
$urole = $env{'request.role'}; |
$urole = $env{'request.role'}; |
$usec = $env{'request.course.sec'}; |
$usec = $env{'request.course.sec'}; |
$cid = $env{'request.course.id'}; |
$cid = $env{'request.course.id'}; |
} |
} |
|
if ($cid) { |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
|
} |
|
if ($cdom && $cnum) { |
|
my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum); |
|
$ctitle = $csettings{'description'}; |
|
$ccode = $csettings{'internal.coursecode'}; |
|
$sectionlist = $csettings{'internal.sectionnums'}; |
|
my @sections = split(/,/,$sectionlist); |
|
foreach my $section (@sections) { |
|
my ($sec,$grp) = split(/:/,$section); |
|
$groupid{$sec} = $grp; |
|
} |
|
} |
|
|
$formname = 'logproblem'; |
$formname = 'logproblem'; |
my $machine = &Apache::lonnet::absolute_url(); |
my $codedom = &get_domain(); |
if ($origurl =~ m-^https?://-) { |
my %helpform; |
$server = $origurl; |
my %domconfig = |
} else { |
&Apache::lonnet::get_dom('configuration',['contacts'],$codedom); |
$server = $machine.$origurl; |
if (ref($domconfig{'contacts'}) eq 'HASH') { |
|
if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') { |
|
%helpform = %{$domconfig{'contacts'}{'helpform'}}; |
|
} |
} |
} |
my $showserver = $server; |
|
$showserver =~ s/\?.*$//; |
my %codes; |
my %lt = &Apache::lonlocal::texthash ( |
my @codetitles; |
|
my %cat_titles; |
|
my %cat_order; |
|
my %idlist; |
|
my %idnums; |
|
my %idlist_titles; |
|
my $totcodes = 0; |
|
my $jscript = ''; |
|
my $loaditems = qq| |
|
function initialize_codes() { |
|
return; |
|
} |
|
|; |
|
unless ($helpform{'course'} eq 'no') { |
|
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); |
|
my $longtitles_str = join('","',@{$longtitles}); |
|
my $allidlist = $idlist{$codetitles[0]}; |
|
my $knowncodes; |
|
if (($ccode ne '') && ($cnum ne '')) { |
|
my (%singlecodes,@singlecodetitles,%singlecat_titles,%singlecat_order); |
|
my $crscode_reply = &Apache::lonnet::auto_instcode_format($cnum,$codedom,{ $cnum => $ccode },\%singlecodes, |
|
\@singlecodetitles,\%singlecat_titles,\%singlecat_order); |
|
if (ref($singlecodes{$cnum}) eq 'HASH') { |
|
$knowncodes = $singlecodes{$cnum}; |
|
} |
|
} |
|
$jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist); |
|
$jscript .= $scripttext; |
|
$jscript .= &Apache::courseclassifier::javascript_code_selections($formname,\@codetitles,$knowncodes,$sectionlist); |
|
$loaditems = ''; |
|
} |
|
} |
|
} |
|
my %missing = &Apache::lonlocal::texthash( |
|
username => 'You must include a name.', |
|
phone => 'You must include a phone.', |
|
); |
|
&js_escape(\%missing); |
|
if (keys(%helpform)) { |
|
foreach my $key (keys(%helpform)) { |
|
if (($helpform{$key} eq 'req') && ($missing{$key} ne '')) { |
|
next if (($key eq 'username') && (($knownuser) || |
|
(($env{'user.name'} =~ /^$match_username$/) && (!$public)))); |
|
$extra_validations .= <<"END"; |
|
|
|
if (document.$formname.$key.value == '') { |
|
alert("$missing{$key}"); |
|
return; |
|
} |
|
|
|
END |
|
} |
|
} |
|
} |
|
my $machine = &Apache::lonnet::absolute_url(); |
|
my $sourceurl = $machine.$origurl; |
|
$server = $machine.&Apache::loncommon::cleanup_html($origurl); |
|
$server =~ s/\?.*$//; |
|
my %js_lt = &Apache::lonlocal::texthash ( |
email => 'The e-mail address you entered', |
email => 'The e-mail address you entered', |
notv => 'is not a valid e-mail address', |
notv => 'is not a valid e-mail address', |
rsub => 'You must include a subject', |
rsub => 'You must include a subject', |
rdes => 'You must include a description', |
rdes => 'You must include a description', |
|
); |
|
my %html_lt = &Apache::lonlocal::texthash ( |
name => 'Name', |
name => 'Name', |
subm => 'Submit Request', |
subm => 'Submit Request', |
emad => 'Your e-mail address', |
emad => 'Your e-mail address', |
emac => 'Cc', |
emac => 'Cc', |
unme => 'username', |
unme => 'username', |
doma => 'domain', |
doma => 'domain', |
entu => 'Enter the username you use to log-in to LON-CAPA', |
entu => 'Enter the username you use to log-in to LON-CAPA', |
Line 136 sub print_request_form {
|
Line 252 sub print_request_form {
|
subj => 'Subject', |
subj => 'Subject', |
detd => 'Detailed Description', |
detd => 'Detailed Description', |
opfi => 'Optional file upload', |
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', |
fini => 'Finish', |
fini => 'Finish', |
clfm => 'Clear Form', |
clfm => 'Clear Form', |
); |
); |
|
&js_escape(\%js_lt); |
|
&html_escape(\%html_lt); |
my $scripttag = (<<"END"); |
my $scripttag = (<<"END"); |
function validate() { |
function validate() { |
if (validmail(document.logproblem.email) == false) { |
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; |
return; |
} |
} |
if (document.logproblem.subject.value == '') { |
if (document.logproblem.subject.value == '') { |
alert("$lt{'rsub'}."); |
alert("$js_lt{'rsub'}."); |
return; |
return; |
} |
} |
if (document.logproblem.description.value == '') { |
if (document.logproblem.description.value == '') { |
alert("$lt{'rdes'}."); |
alert("$js_lt{'rdes'}."); |
return; |
return; |
} |
} |
|
$extra_validations |
document.logproblem.submit(); |
document.logproblem.submit(); |
} |
} |
|
|
END |
END |
$scripttag .= &Apache::lonhtmlcommon::javascript_valid_email(); |
$scripttag .= &Apache::lonhtmlcommon::javascript_valid_email(); |
if ($cid) { |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
|
} |
|
if ($cdom && $cnum) { |
|
my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum); |
|
$ctitle = $csettings{'description'}; |
|
$ccode = $csettings{'internal.coursecode'}; |
|
$sectionlist = $csettings{'internal.sectionnums'}; |
|
} |
|
|
|
if ($homeserver) { |
if ($homeserver) { |
if ($env{'environment.permanentemail'}) { |
if ($env{'environment.permanentemail'}) { |
Line 185 END
|
Line 294 END
|
$firstname = $env{'environment.firstname'}; |
$firstname = $env{'environment.firstname'}; |
} |
} |
} |
} |
my @sections = split(/,/,$sectionlist); |
|
my %groupid; |
|
foreach my $section (@sections) { |
|
my ($sec,$grp) = split(/:/,$section); |
|
$groupid{$sec} = $grp; |
|
} |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom', |
|
'useremail','useraccount']); |
|
if ($env{'form.origurl'} eq '/adm/createaccount') { |
if ($env{'form.origurl'} eq '/adm/createaccount') { |
if ($email eq '') { |
if ($email eq '') { |
if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) { |
if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) { |
Line 205 END
|
Line 306 END
|
} |
} |
} |
} |
} |
} |
my $codedom = &get_domain(); |
|
my $details_title; |
my $details_title; |
if ($codedom) { |
if ($codedom) { |
$details_title = '<br />('.$codedom.')'; |
$details_title = '<br />('.$codedom.')'; |
} |
} |
my %coursecodes; |
|
my %codes; |
|
my @codetitles; |
|
my %cat_titles; |
|
my %cat_order; |
|
my %idlist; |
|
my %idnums; |
|
my %idlist_titles; |
|
my $caller = 'global'; |
|
my $totcodes = 0; |
|
my $format_reply; |
|
my $jscript = ''; |
|
my $loaditems = qq| |
|
function initialize_codes() { |
|
return; |
|
} |
|
|; |
|
if ($cnum) { |
|
$coursecodes{$cnum} = $ccode; |
|
if ($ccode eq '') { |
|
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
|
} else { |
|
$coursecodes{$cnum} = $ccode; |
|
$caller = $cnum; |
|
$totcodes ++; |
|
} |
|
} else { |
|
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
|
} |
|
if ($totcodes > 0) { |
|
if ($ccode eq '') { |
|
$format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); |
|
if ($format_reply eq 'ok') { |
|
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); |
|
my $longtitles_str = join('","',@{$longtitles}); |
|
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); |
|
$loaditems = ''; |
|
} |
|
} |
|
} |
|
|
|
my $js = <<"ENDJS"; |
my $js = <<"ENDJS"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 264 $jscript
|
Line 319 $jscript
|
$loaditems |
$loaditems |
// ]]> |
// ]]> |
</script> |
</script> |
|
<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script> |
ENDJS |
ENDJS |
|
if ($recaptcha_version >=2) { |
|
$js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n"; |
|
} |
my %add_entries = ( |
my %add_entries = ( |
style => "margin-top:0px;margin-bottom:0px;", |
style => "margin-top:0px;margin-bottom:0px;", |
onload => "initialize_codes();", |
onload => "initialize_codes();", |
Line 285 ENDJS
|
Line 344 ENDJS
|
if ($homeserver) { |
if ($homeserver) { |
$formtype = ' enctype="multipart/form-data"'; |
$formtype = ' enctype="multipart/form-data"'; |
} |
} |
|
my $topsubmit = ' <input type="button" value="'.$html_lt{'subm'}.'" onclick="validate()" /> '; |
|
my $shownsubmit; |
$r->print('<form method="post" action="" name="logproblem"'.$formtype.'>'."\n"); |
$r->print('<form method="post" action="" name="logproblem"'.$formtype.'>'."\n"); |
my $output = &Apache::lonhtmlcommon::start_pick_box(). |
my $output = &Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n"; |
&Apache::lonhtmlcommon::row_headline(). |
my $fullname = ''; |
'<span class="LC_info">'. |
if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) { |
&mt('(All fields marked with * are required.)'). |
$fullname = "$firstname $lastname"; |
'</span>'. |
$output .= $fullname.'<input type="hidden" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n"; |
&Apache::lonhtmlcommon::row_closure(); |
} else { |
unless ($helpform{'username'} eq 'no') { |
if (defined($firstname) && $firstname ne '') { |
my ($reqd,$namefield,$fullname); |
$fullname = $firstname; |
if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) { |
} elsif (defined($lastname) && $lastname ne '') { |
$fullname = "$firstname $lastname"; |
$fullname = " $lastname"; |
$namefield = $fullname.'<input type="hidden" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n"; |
} |
|
$output .= '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n"; |
|
} |
|
$output .= ' <input type="button" value="'.$lt{'subm'}.'" onclick="validate()" /> '. |
|
&Apache::lonhtmlcommon::row_closure()."\n"; |
|
$num ++; |
|
$i = $num%2; |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,$css[$i]). |
|
'<input type="text" size="20" name="email" value="'. |
|
&HTML::Entities::encode($email,'"<>&').'" /><br />'."\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]). |
|
'<input type="text" size="50" name="cc" value="" /><br />'."\n". |
|
&Apache::lonhtmlcommon::row_closure(); |
|
$num ++; |
|
$i = $num%2; |
|
} |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]); |
|
my $udom_input = '<input type="hidden" name="udom" value="'. |
|
&HTML::Entities::encode($udom,'"<>&').'" />'."\n"; |
|
my $uname_input = '<input type="hidden" name="uname" value="'. |
|
&HTML::Entities::encode($uname,'"<>&').'" />'."\n"; |
|
if (($env{'user.name'} =~ /^$match_username$/) && |
|
($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) { |
|
$output .= '<i>'.$lt{'unme'}.'</i>: '.$uname.' <i>'.$lt{'doma'}.'</i>: '.$udom.$udom_input.$uname_input; |
|
} else { |
|
my $udomform = ''; |
|
my $unameform = ''; |
|
if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) { |
|
$output .= $lt{'entu'}; |
|
} elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
|
$output .= $lt{'chdo'}; |
|
} else { |
} else { |
$output .= $lt{'entr'}; |
if (defined($firstname) && $firstname ne '') { |
} |
$fullname = $firstname; |
$output .= '<br />'."\n"; |
} elsif (defined($lastname) && $lastname ne '') { |
if (!$public) { |
$fullname = " $lastname"; |
if ($env{'user.domain'} =~ /^$match_domain$/) { |
} |
$udomform = '<i>'.$lt{'doma'}.'</i>: '.$udom.$udom_input; |
$namefield = '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n"; |
} elsif ($env{'user.name'} =~ /^$match_username$/) { |
if ($helpform{'username'} eq 'req') { |
$unameform = '<i>'.$lt{'unme'}.'</i>: '.$uname.' '.$uname_input; |
$reqd = '<span class="LC_info">*</span>'; |
} |
} |
} |
} |
if ($udomform eq '') { |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'name'}.$reqd,undef,$css[$num])."\n".$namefield. |
$udomform = '<i>'.$lt{'doma'}.'</i>: '; |
$topsubmit. |
$udomform .= &Apache::loncommon::select_dom_form($codedom,'udom')."\n"; |
&Apache::lonhtmlcommon::row_closure()."\n"; |
} |
$shownsubmit = 1; |
if ($unameform eq '') { |
$num ++; |
$unameform= '<i>'.$lt{'unme'}.'</i>: <input type="text" size="20" name="uname" value="'.$uname.'" /> '; |
$i = $num%2; |
} |
} |
$output .= $unameform.$udomform; |
$output .= &Apache::lonhtmlcommon::row_title( |
|
'<span title="'.&mt('required').'">'. |
|
$html_lt{'emad'}.' <span class="LC_info">*</span></span>' |
|
,undef,$css[$i]). |
|
'<input type="text" size="20" name="email" value="'. |
|
&HTML::Entities::encode($email,'"<>&').'" />'."\n"; |
|
unless ($shownsubmit) { |
|
$output .= $topsubmit; |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(); |
$output .= &Apache::lonhtmlcommon::row_closure(); |
$num ++; |
$num ++; |
$i = $num%2; |
$i = $num%2; |
$output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]). |
if ($knownuser) { |
$showserver."\n".'<input type="hidden" name="sourceurl" value="'. |
if ($homeserver) { |
&HTML::Entities::encode($server,'"<>&').'" />'."\n". |
unless ($helpform{'cc'} eq 'no') { |
&Apache::lonhtmlcommon::row_closure(). |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]). |
&Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value'). |
'<input type="text" size="50" name="cc" value="" /><br />'."\n". |
'<input type="text" size="15" name="phone" /><br />'."\n". |
&Apache::lonhtmlcommon::row_closure(); |
&Apache::lonhtmlcommon::row_closure(); |
$num ++; |
$num ++; |
$i = $num%2; |
$i = $num%2; |
|
$output .= &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,$css[$i]); |
|
if ($cnum) { |
|
if ($coursecodes{$cnum}) { |
|
foreach my $item (@codetitles) { |
|
$output .= '<i>'.$item.'</i>: '.$codes{$cnum}{$item}.'; '; |
|
} |
} |
$output .= ' <input type="hidden" name="coursecode" value="'.&HTML::Entities::encode($coursecodes{$cnum},'"<>&').'" />'."\n"; |
} |
|
} |
|
unless (($helpform{'user'} eq 'no') || ($env{'request.lti.login'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title("$html_lt{'unme'}/$html_lt{'doma'}",undef,$css[$i]); |
|
my $udom_input = '<input type="hidden" name="udom" value="'. |
|
&HTML::Entities::encode($udom,'"<>&').'" />'."\n"; |
|
my $uname_input = '<input type="hidden" name="uname" value="'. |
|
&HTML::Entities::encode($uname,'"<>&').'" />'."\n"; |
|
if ($knownuser) { |
|
$output .= '<i>'.$html_lt{'unme'}.'</i>: '.$uname.' <i>'.$html_lt{'doma'}.'</i>: '.$udom.$udom_input.$uname_input; |
} else { |
} else { |
$output .= $lt{'enin'}.': |
my $udomform = ''; |
<input type="text" name="coursecode" size="15" value="" />'."\n"; |
my $unameform = ''; |
|
if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) { |
|
$output .= $html_lt{'entu'}; |
|
} elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
|
$output .= $html_lt{'chdo'}; |
|
} else { |
|
$output .= $html_lt{'entr'}; |
|
} |
|
$output .= '<br />'."\n"; |
|
if (!$public) { |
|
if ($env{'user.domain'} =~ /^$match_domain$/) { |
|
$udomform = '<i>'.$html_lt{'doma'}.'</i>: '.$udom.$udom_input; |
|
} elsif ($env{'user.name'} =~ /^$match_username$/) { |
|
$unameform = '<i>'.$html_lt{'unme'}.'</i>: '.$uname.' '.$uname_input; |
|
} |
|
} |
|
if ($udomform eq '') { |
|
$udomform = '<i>'.$html_lt{'doma'}.'</i>: '; |
|
$udomform .= &Apache::loncommon::select_dom_form($codedom,'udom')."\n"; |
|
} |
|
if ($unameform eq '') { |
|
$unameform= '<i>'.$html_lt{'unme'}.'</i>: <input type="text" size="20" name="uname" value="'.$uname.'" /> '; |
|
} |
|
$output .= $unameform.$udomform; |
} |
} |
} else { |
$output .= &Apache::lonhtmlcommon::row_closure(); |
|
$num ++; |
|
$i = $num%2; |
|
} |
|
unless ($env{'request.lti.login'}) { |
|
$output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]). |
|
$server."\n".'<input type="hidden" name="sourceurl" value="'. |
|
&HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n". |
|
&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
unless ($helpform{'phone'} eq 'no') { |
|
my $reqd; |
|
if ($helpform{'phone'} eq 'req') { |
|
$reqd = '<span class="LC_info">*</span>'; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'phon'}.$reqd,undef,'LC_evenrow_value'). |
|
'<input type="text" size="15" name="phone" /><br />'."\n". |
|
&Apache::lonhtmlcommon::row_closure(); |
|
$num ++; |
|
$i = $num%2; |
|
} |
|
unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]); |
if ($totcodes > 0) { |
if ($totcodes > 0) { |
my $numtitles = @codetitles; |
my $numtitles = @codetitles; |
if ($numtitles == 0) { |
if ($numtitles == 0) { |
$output .= $lt{'enin'}.': |
$output .= $html_lt{'enin'}.': |
<input type="text" name="coursecode" size="15" value="" />'."\n"; |
<input type="text" name="coursecode" size="15" value="" />'."\n"; |
} else { |
} else { |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my $lasttitle = $numtitles; |
my $lasttitle = $numtitles; |
if ($numtitles > 4) { |
if ($numtitles > 4) { |
$lasttitle = 4; |
$lasttitle = 4; |
} |
} |
|
my $onchange; |
|
if ($sectionlist) { |
|
$onchange = 'toggleSecVis()'; |
|
} |
$output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n". |
$output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n". |
'<select name="'.$standardnames[0].'" onchange="courseSet('."'$codetitles[0]'".')">'."\n". |
'<select name="'.$standardnames[0].'" onchange="courseSet('."'$codetitles[0]'".');'.$onchange.'">'."\n". |
' <option value="-1">'.$lt{'sele'}."</option>\n"; |
' <option value="-1">'.$html_lt{'sele'}."</option>\n"; |
my @items = (); |
my @items = (); |
my @longitems = (); |
my @longitems = (); |
if ($idlist{$codetitles[0]} =~ /","/) { |
if ($idlist{$codetitles[0]} =~ /","/) { |
Line 419 ENDJS
|
Line 502 ENDJS
|
$output .= '</select></td>'; |
$output .= '</select></td>'; |
for (my $i=1; $i<$numtitles; $i++) { |
for (my $i=1; $i<$numtitles; $i++) { |
$output .= '<td>'.$codetitles[$i].'<br />'."\n". |
$output .= '<td>'.$codetitles[$i].'<br />'."\n". |
'<select name="'.$standardnames[$i].'" onchange="courseSet('."'$codetitles[$i]'".')">'."\n". |
'<select name="'.$standardnames[$i].'" onchange="courseSet('."'$codetitles[$i]'".');'.$onchange.'">'."\n". |
'<option value="-1"><-'.$lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n". |
'<option value="-1"><-'.$html_lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n". |
'</select>'."\n". |
'</select>'."\n". |
'</td>'."\n"; |
'</td>'."\n"; |
} |
} |
$output .= '</tr></table>'; |
$output .= '</tr></table>'; |
if ($numtitles > 4) { |
if ($numtitles > 4) { |
$output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n". |
$output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n". |
'<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".')">'."\n". |
'<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".');'.$onchange.'">'."\n". |
'<option value="-1"><-'.$lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n". |
'<option value="-1"><-'.$html_lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n". |
'</select>'."\n"; |
'</select>'."\n"; |
} |
} |
} |
} |
} else { |
} else { |
$output .= $lt{'enin'}.': |
$output .= $html_lt{'enin'}.': |
<input type="text" name="coursecode" size="15" value="" />'."\n"; |
<input type="text" name="coursecode" size="15" value="" />'."\n"; |
} |
} |
} |
my $reqd; |
if ($ctitle) { |
if ($helpform{'course'} eq 'req') { |
$output .= '<br /><i>'.$lt{'titl'}.'</i>: '.$ctitle. |
$reqd = '<span class="LC_info">*</span>'; |
'<input type="hidden" name="title" value="'. |
} |
|
$output .= '<br />'.$html_lt{'enct'}.$reqd.': |
|
<input type="text" name="title" size="25" value="'. |
&HTML::Entities::encode($ctitle,'"<>&').'" />'."\n"; |
&HTML::Entities::encode($ctitle,'"<>&').'" />'."\n"; |
} else { |
$output .= &Apache::lonhtmlcommon::row_closure(); |
$output .= '<br />'.$lt{'enct'}.': |
$num ++; |
<input type="text" name="title" size="25" value="" />'."\n"; |
$i = $num%2; |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(); |
unless (($helpform{'section'} eq 'no') || ($env{'request.lti.login'})) { |
$num ++; |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'secn'},undef,$css[$i]); |
$i = $num%2; |
if ($sectionlist) { |
$output .= &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,$css[$i]); |
$output .= "<div id=\"LC_helpdesk_sectionlist\"><select name=\"sectionsel\">\n". |
if ($sectionlist) { |
" <option value=\"\" selected=\"selected\">$html_lt{'sele'}</option>\n"; |
$output .= "<select name=\"section\"\n>". |
foreach my $id (sort(keys(%groupid))) { |
" <option value=\"\" selected=\"selected\">$lt{'sele'}</option>\n"; |
if ($id eq $groupid{$id} || $groupid{$id} eq '') { |
foreach my $id (sort(keys(%groupid))) { |
$output .= " <option value=". |
if ($id eq $groupid{$id} || $groupid{$id} eq '') { |
&HTML::Entities::encode($id,'"<>&'). |
$output .= " <option value=". |
" >$id</option>\n"; |
&HTML::Entities::encode($id,'"<>&'). |
} else { |
" >$id</option>\n"; |
$output .= " <option value=". |
} else { |
&HTML::Entities::encode($id,'"<>&'). |
$output .= " <option value=". |
" >$id - ($html_lt{'lsec'}: $groupid{$id})</option>\n"; |
&HTML::Entities::encode($id,'"<>&'). |
} |
" >$id - ($lt{'lsec'}: $groupid{$id})</option>\n"; |
|
} |
} |
|
$output .= '</select></div>'."\n". |
|
'<div id="LC_helpdesk_section" style="display:none">'. |
|
'<input type="text" name="sectiontxt" size="10" /></div>'."\n"; |
|
} else { |
|
$output .= '<input type="text" name="section" size="10" />'."\n"; |
} |
} |
$output .= "</select>"; |
$output .= &Apache::lonhtmlcommon::row_closure(); |
} else { |
$num ++; |
$output .= '<input type="text" name="section" size="10" />'."\n"; |
$i = $num%2; |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(); |
$output .= &Apache::lonhtmlcommon::row_title( |
$num ++; |
'<span title="'.&mt('required').'">'. |
$i = $num%2; |
$html_lt{'subj'}.' <span class="LC_info">*</span></span>' |
$output .= &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_oddrow_value'). |
,undef,'LC_oddrow_value'). |
' <input type="text" size="40" name="subject" />'."\n". |
'<input type="text" size="40" name="subject" />'."\n". |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_evenrow_value'). |
&Apache::lonhtmlcommon::row_title( |
' <textarea rows="10" cols="45" name="description" style="word-wrap:normal;">'. |
'<span title="'.&mt('required').'">'. |
|
$html_lt{'detd'}.' <span class="LC_info">*</span></span>' |
|
,undef,'LC_evenrow_value'). |
|
'<textarea rows="10" cols="45" name="description" style="word-wrap:normal;">'. |
'</textarea>'."\n". |
'</textarea>'."\n". |
&Apache::lonhtmlcommon::row_closure(); |
&Apache::lonhtmlcommon::row_closure(); |
$num ++; |
$num ++; |
$i = $num%2; |
$i = $num%2; |
if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
if ($knownuser) { |
if ($homeserver) { |
if ($homeserver) { |
$output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]). |
unless ($helpform{'screenshot'} eq 'no') { |
' <input type="file" name="screenshot" size="20" /><br />'. |
my $max = 1048576; |
"\n".$lt{'uplf'}."\n". |
my $showmax = 1.00; |
&Apache::lonhtmlcommon::row_closure(); |
if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) { |
$num ++; |
$max *= $helpform{'maxsize'}; |
$i = $num%2; |
$showmax = $helpform{'maxsize'}; |
|
} |
|
$showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')'; |
|
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]) |
|
.' <input type="file" name="screenshot" class="LC_flUpload" size="20" />' |
|
.'<input type="hidden" id="LC_free_space" value="'.$max.'" />' |
|
.'<br />'."\n".$html_lt{'uplf'}.$showmax."\n" |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
$num ++; |
|
$i = $num%2; |
|
} |
} |
} |
} else { |
} else { |
my $lonhost = $r->dir_config('lonHostID'); |
if ($captcha_form) { |
my ($captchaform,$error) = |
$output .= &Apache::lonhtmlcommon::row_title( |
&Apache::loncommon::captcha_display('login',$lonhost); |
'<span title="'.&mt('required').'">'. |
if ($captchaform) { |
&mt('Validation'). |
$output .= &Apache::lonhtmlcommon::row_title(&mt('Validation'),undef, |
' <span class="LC_info">*</span></span>' |
$css[$i])."\n". |
,undef,$css[$i]). |
$captchaform."\n". |
$captcha_form."\n". |
&Apache::lonhtmlcommon::row_closure(); |
&Apache::lonhtmlcommon::row_closure(); |
$num ++; |
$num ++; |
$i = $num%2; |
$i = $num%2; |
} |
} |
} |
} |
$output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]); |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'fini'},undef,$css[$i]); |
$output .= <<END; |
$output .= <<END; |
<table border="0" cellpadding="8" cellspacing="0"> |
<table border="0" cellpadding="8" cellspacing="0"> |
<tr> |
<tr> |
<td> |
<td> |
<input type="hidden" name="command" value="process" /> |
<input type="hidden" name="command" value="process" /> |
<input type="button" value="$lt{'subm'}" onclick="validate()" /> |
<input type="button" value="$html_lt{'subm'}" onclick="validate()" /> |
</td> |
</td> |
<td> </td> |
<td> </td> |
<td> |
<td> |
<input type="reset" value="$lt{'clfm'}" /> |
<input type="reset" value="$html_lt{'clfm'}" /> |
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
Line 533 sub print_request_receipt {
|
Line 635 sub print_request_receipt {
|
if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) { |
if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) { |
$public = 1; |
$public = 1; |
} |
} |
|
my $lonhost = $r->dir_config('lonHostID'); |
unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { |
my $lonhost = $r->dir_config('lonHostID'); |
|
my ($captcha_chk,$captcha_error) = |
my ($captcha_chk,$captcha_error) = |
&Apache::loncommon::captcha_response('login',$lonhost); |
&Apache::loncommon::captcha_response('login',$lonhost); |
if ($captcha_chk != 1) { |
if ($captcha_chk != 1) { |
Line 548 sub print_request_receipt {
|
Line 650 sub print_request_receipt {
|
if ($r->uri eq '/adm/helpdesk') { |
if ($r->uri eq '/adm/helpdesk') { |
&print_header($r,$url,'process'); |
&print_header($r,$url,'process'); |
} |
} |
$r->print('<h3>'.&mt('Support request failed').'</h3>'. |
$r->print( |
'<span class="LC_error">'. |
'<h2>'.&mt('Support request failed').'</h2>'. |
&mt('Validation of the code you entered failed.'). |
&Apache::lonhtmlcommon::confirm_success( |
|
&mt('Validation of the code you entered failed.'),1). |
|
'<br /><br />'. |
|
&Apache::lonhtmlcommon::actionbox([ |
|
&mt('[_1]Go back[_2] and try again', |
|
'<a href="javascript:history.go(-1)">','</a>')]). |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
Line 558 sub print_request_receipt {
|
Line 665 sub print_request_receipt {
|
my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME'); |
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 @envvars = ('browser.os','browser.type','browser.version','user.home','request.role'); |
my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id'); |
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 $admin = $Apache::lonnet::perlvar{'lonAdminMail'}; |
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
my $defdom = &get_domain(); |
my $defdom = &get_domain(); |
my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', |
|
$defdom,$origmail); |
|
my $from = $admin; |
my $from = $admin; |
my $bcc; |
my %helpform; |
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['contacts'],$defdom); |
&Apache::lonnet::get_dom('configuration',['contacts'],$defdom); |
if (ref($domconfig{'contacts'}) eq 'HASH') { |
if (ref($domconfig{'contacts'}) eq 'HASH') { |
if (exists($domconfig{'contacts'}{'helpdeskmail'})) { |
if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') { |
if (ref($domconfig{'contacts'}{'helpdeskmail'}) eq 'HASH') { |
%helpform = %{$domconfig{'contacts'}{'helpform'}}; |
my $bccmail = $domconfig{'contacts'}{'helpdeskmail'}{'bcc'}; |
|
if ($bccmail ne '') { |
|
my @bccs = split(/,/,$bccmail); |
|
my @ok_bccs; |
|
foreach my $bcc (@bccs) { |
|
$bcc =~ s/^\s+//g; |
|
$bcc =~ s/\s+$//g; |
|
if ($bcc =~ m/^[^\@]+\@[^\@]+$/) { |
|
if (!(grep(/^\Q$bcc\E$/,@ok_bccs))) { |
|
push(@ok_bccs,$bcc); |
|
} |
|
} |
|
} |
|
if (@ok_bccs > 0) { |
|
$bcc = join(', ',@ok_bccs); |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
my $reporttime = &Apache::lonlocal::locallocaltime(time); |
my $reporttime = &Apache::lonlocal::locallocaltime(time); |
my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot'); |
my %formvars = ( |
|
email => 1, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); |
sourceurl => 1, |
my $coursecode = $env{'form.coursecode'}; |
subject => 1, |
if ($coursecode eq '') { |
description => 1, |
my $totcodes = 0; |
); |
my %coursecodes; |
unless ($helpform{'username'} eq 'no') { |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom,$totcodes); |
$formvars{'username'} = 1; |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
} |
if ($totcodes > 0) { |
unless ($helpform{'user'} eq 'no') { |
my $noregexps = 1; |
$formvars{'uname'} = 1; |
$coursecode = |
$formvars{'udom'} = 1; |
&Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps); |
} |
} |
unless ($helpform{'phone'} eq 'no') { |
|
$formvars{'phone'} = 1; |
|
} |
|
unless (($helpform{'section'} eq 'no') || ($env{'request.lti.login'})) { |
|
$formvars{'section'} = 1; |
|
} |
|
unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) { |
|
$formvars{'course'} = 1; |
|
} |
|
unless ($helpform{'cc'} eq 'no') { |
|
$formvars{'cc'} = 1; |
|
} |
|
unless ($helpform{'screenshot'} eq 'no') { |
|
$formvars{'screenshot'} = 1; |
|
} |
|
my ($coursecode,$sourceurl); |
|
if ($formvars{'course'}) { |
|
$coursecode = $env{'form.coursecode'}; |
if ($coursecode eq '') { |
if ($coursecode eq '') { |
foreach my $item (@standardnames) { |
my $totcodes = 0; |
if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) { |
my $instcats = &Apache::lonnet::get_dom_instcats($defdom); |
$coursecode .= $env{'form.'.$item}; |
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; |
|
$coursecode = |
|
&Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps); |
|
} |
|
if ($coursecode eq '') { |
|
foreach my $item (@standardnames) { |
|
if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) { |
|
$coursecode .= $env{'form.'.$item}; |
|
} |
} |
} |
} |
} |
} |
} |
Line 634 sub print_request_receipt {
|
Line 758 sub print_request_receipt {
|
adin => 'Additional information recorded', |
adin => 'Additional information recorded', |
); |
); |
|
|
my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$public,$homeserver); |
my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$homeserver); |
if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) { |
unless ($public) { |
$public = 1; |
|
} else { |
|
if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) { |
if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) { |
$homeserver = &Apache::lonnet::homeserver($env{'user.name'}, |
$homeserver = &Apache::lonnet::homeserver($env{'user.name'}, |
$env{'user.domain'}); |
$env{'user.domain'}); |
} |
} |
} |
} |
|
my ($cid,$cdom,$cnum,$sectionlist,$ccode); |
if (($homeserver) && (defined($env{'form.cc'}))) { |
if ($homeserver) { |
|
$cid = $env{'request.course.id'}; |
|
} |
|
if ($cid) { |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
|
} |
|
if ($cdom && $cnum) { |
|
my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum); |
|
$ccode = $csettings{'internal.coursecode'}; |
|
$sectionlist = $csettings{'internal.sectionnums'}; |
|
} |
|
if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) { |
my @ccs; |
my @ccs; |
if ($env{'form.cc'} =~ /,/) { |
if ($env{'form.cc'} =~ /,/) { |
@ccs = split(/,/,$env{'form.cc'}); |
@ccs = split(/,/,$env{'form.cc'}); |
Line 670 sub print_request_receipt {
|
Line 804 sub print_request_receipt {
|
$okcclist = join(', ',@ok_ccs); |
$okcclist = join(', ',@ok_ccs); |
} |
} |
if (@bad_ccs == 1) { |
if (@bad_ccs == 1) { |
$badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0]; |
if ($bad_ccs[0] ne '') { |
|
$badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').&Apache::loncommon::cleanup_html($bad_ccs[0]); |
|
} |
} elsif (@bad_ccs > 1) { |
} elsif (@bad_ccs > 1) { |
my $bad_cc_string = join(', ',@bad_ccs); |
$badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ',@bad_ccs)); |
$badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string; |
} |
|
} |
|
if ($env{'request.lti.login'}) { |
|
if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) { |
|
$env{'form.user'} = "'".$env{'user.name'}.':'.$env{'user.domain'}."'"; |
|
} |
|
$sourceurl = &Apache::lonnet::absolute_url().$url; |
|
} else { |
|
$env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'"; |
|
$sourceurl = $env{'form.sourceurl'}; |
|
} |
|
if ($formvars{'course'}) { |
|
$env{'form.crsi'} = $env{'form.title'}; |
|
if ($coursecode ne '') { |
|
$env{'form.crsi'} .= ' - '.$coursecode; |
} |
} |
} |
} |
$env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'"; |
if ($formvars{'section'}) { |
$env{'form.crsi'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'}; |
my $section; |
my $supportmsg = <<END; |
if ($sectionlist) { |
$lt{'username'}: $env{'form.username'} |
if ($coursecode eq $ccode) { |
$lt{'email'}: $env{'form.email'} |
$section = $env{'form.sectionsel'} |
$lt{'cc'}: $okcclist |
} else { |
$lt{'user'}: $env{'form.user'} |
$section = $env{'form.sectiontxt'}; |
$lt{'phone'}: $env{'form.phone'} |
} |
$lt{'crsi'}: $env{'form.crsi'} |
} else { |
$lt{'subject'}: $env{'form.subject'} |
$section = $env{'form.section'}; |
|
} |
|
$env{'form.crsi'} .= ' - '.$lt{'sect'}.': '.$section; |
|
} |
|
my $supportmsg; |
|
if ($formvars{'username'}) { |
|
$supportmsg .= "$lt{'username'}: $env{'form.username'}\n"; |
|
} |
|
$supportmsg .= "$lt{'email'}: $env{'form.email'}\n"; |
|
if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) { |
|
$supportmsg .= "$lt{'cc'}: $okcclist\n"; |
|
} |
|
if ($formvars{'user'}) { |
|
$supportmsg .= "$lt{'user'}: $env{'form.user'}\n"; |
|
} |
|
if ($formvars{'phone'}) { |
|
$supportmsg .= "$lt{'phone'}: $env{'form.phone'}\n"; |
|
} |
|
if ($formvars{'course'}) { |
|
$supportmsg .= "$lt{'crsi'}: $env{'form.crsi'}\n"; |
|
} |
|
$supportmsg .= "$lt{'subject'}: $env{'form.subject'} |
$lt{'description'}: $env{'form.description'} |
$lt{'description'}: $env{'form.description'} |
$lt{'sourceurl'}: $env{'form.sourceurl'} |
$lt{'sourceurl'}: $sourceurl |
$lt{'date'}: $reporttime |
$lt{'date'}: $reporttime |
|
"; |
|
|
END |
|
my $displaymsg; |
my $displaymsg; |
foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') { |
foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') { |
if ($env{'form.'.$item} ne '') { |
if ($env{'form.'.$item} ne '') { |
if ($item eq 'description') { |
if ($item eq 'description') { |
my $descrip = $env{'form.description'}; |
my $descrip = $env{'form.description'}; |
$descrip = &cleanup_html($descrip); |
$descrip = &Apache::loncommon::cleanup_html($descrip); |
$descrip =~ s|[\n\r\f]|<br />|g; |
$descrip =~ s|[\n\r\f]|<br />|g; |
$displaymsg .= |
$displaymsg .= |
'<span class="LC_helpform_receipt_cat">'. |
'<span class="LC_helpform_receipt_cat">'. |
Line 704 END
|
Line 875 END
|
} elsif ($item eq 'sourceurl') { |
} elsif ($item eq 'sourceurl') { |
my $showurl = $env{'form.sourceurl'}; |
my $showurl = $env{'form.sourceurl'}; |
$showurl =~ s/\?.*$//; |
$showurl =~ s/\?.*$//; |
$showurl = &cleanup_html($showurl); |
$showurl = &Apache::loncommon::cleanup_html($showurl); |
$displaymsg .= |
$displaymsg .= |
'<span class="LC_helpform_receipt_cat">'. |
'<span class="LC_helpform_receipt_cat">'. |
"$lt{$item}</span>: $showurl<br />\n"; |
"$lt{$item}</span>: $showurl<br />\n"; |
} elsif ($item eq 'cc') { |
} elsif ($item eq 'cc') { |
$displaymsg .= |
next if ($helpform{'cc'} eq 'no'); |
'<span class="LC_helpform_receipt_cat">'. |
if ($okcclist) { |
"$lt{$item}</span>: $okcclist<br />\n"; |
my $showcclist = &Apache::loncommon::cleanup_html($okcclist); |
|
$displaymsg .= |
|
'<span class="LC_helpform_receipt_cat">'. |
|
"$lt{$item}</span>: $showcclist<br />\n"; |
|
} |
} else { |
} else { |
|
if (($item eq 'username') || ($item eq 'user') || ($item eq 'phone')) { |
|
next if ($helpform{$item} eq 'no'); |
|
} |
|
next if (($item eq 'crsi') && ($helpform{'course'} eq 'no')); |
|
next if (($item eq 'user') && ($env{'request.lti.login'})); |
my $showitem = $env{'form.'.$item}; |
my $showitem = $env{'form.'.$item}; |
$showitem = &cleanup_html($showitem); |
$showitem = &Apache::loncommon::cleanup_html($showitem); |
$displaymsg .= |
$displaymsg .= |
'<span class="LC_helpform_receipt_cat">'. |
'<span class="LC_helpform_receipt_cat">'. |
"$lt{$item}</span>: $showitem<br />\n"; |
"$lt{$item}</span>: $showitem<br />\n"; |
} |
} |
} |
} |
} |
} |
|
|
|
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$/) { |
|
$requname = $env{'form.uname'}; |
|
} |
|
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 .= '<span class="LC_helpform_receipt_cat">'. |
$displaymsg .= '<span class="LC_helpform_receipt_cat">'. |
$lt{'date'}.'</span>: '.$reporttime.'<br />'."\n"; |
$lt{'date'}.'</span>: '.$reporttime.'<br />'."\n"; |
|
|
Line 735 END
|
Line 942 END
|
|
|
$r->print(<<"END"); |
$r->print(<<"END"); |
$start_page |
$start_page |
<form name="logproblem"> |
<form name="logproblem" action=""> |
<input type="hidden" name="command" value="result" /> |
<input type="hidden" name="command" value="result" /> |
</form> |
</form> |
END |
END |
Line 743 END
|
Line 950 END
|
&print_header($r,$url,'process'); |
&print_header($r,$url,'process'); |
} |
} |
my $bad_email = 0; |
my $bad_email = 0; |
|
my ($to,$bcc,$addtext) = |
|
&Apache::loncommon::build_recipient_list(undef,'helpdeskmail', |
|
$dom_in_effect,$origmail, |
|
$requname,$requdom, |
|
$reqemail); |
if ($to =~ /,/) { |
if ($to =~ /,/) { |
my @ok_email; |
my @ok_email; |
foreach my $email (split(/,/,$to)) { |
foreach my $email (split(/,/,$to)) { |
Line 780 END
|
Line 992 END
|
} |
} |
$r->print(&Apache::loncommon::confirmwrapper($message)); |
$r->print(&Apache::loncommon::confirmwrapper($message)); |
|
|
if (defined($env{'form.email'})) { |
if ($reqemail ne '') { |
$env{'form.email'} =~ s/^\s+//; |
$from = $reqemail; |
$env{'form.email'} =~ s/\s+$//; |
|
if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) { |
|
$from = $env{'form.email'}; |
|
} |
|
} |
} |
|
|
if (defined($env{'form.cc'})) { |
if (defined($env{'form.cc'})) { |
Line 804 END
|
Line 1012 END
|
my $fname; |
my $fname; |
|
|
my $attachmentpath = ''; |
my $attachmentpath = ''; |
my $attachmentsize = ''; |
my $showsize = ''; |
if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public') |
|
&& ($env{'user.domain'} ne 'public')) { |
if ((defined($env{'user.name'})) && (!$public)) { |
if ($homeserver && $env{'form.screenshot.filename'}) { |
if ($homeserver && $env{'form.screenshot.filename'}) { |
$attachmentsize = length($env{'form.screenshot'}); |
unless ($helpform{'screenshot'} eq 'no') { |
if ($attachmentsize > 131072) { |
my $attachmentsize = length($env{'form.screenshot'}); |
$displaymsg .= '<br />'.&mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.',$attachmentsize); |
my $max = 1048576; |
} else { |
my $showmax = 1.00; |
$attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests'); |
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 .= '<br /><span class="LC_warning">'. |
|
&mt('The uploaded screenshot file [_1] included with your request exceeded the maximum allowed size [_2], and has therefore been discarded.',$showsize,$showmax).'</span>'; |
|
} else { |
|
$attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests'); |
|
} |
} |
} |
} |
} |
} |
} |
Line 822 END
|
Line 1042 END
|
if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) { |
if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) { |
$cookies{'lonID'} = $1; |
$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-/([^/]+)$-) { |
if ($attachmentpath =~ m-/([^/]+)$-) { |
$fname = $1; |
$fname = $1; |
$displaymsg .= '<br />' |
$displaymsg .= '<br />' |
.&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].' |
.&mt('An uploaded screenshot file [_1] was included in the request sent by [_2].' |
,'<span class="LC_filename">'.$fname.'</span>' |
,'<span class="LC_filename">'.$fname.'</span> '.$showsize, |
,$attachmentsize |
|
,$env{'user.name'}.':'.$env{'user.domain'} |
,$env{'user.name'}.':'.$env{'user.domain'} |
); |
); |
$supportmsg .= "\n"; |
$supportmsg .= "\n"; |
Line 841 END
|
Line 1074 END
|
foreach my $var (@envvars) { |
foreach my $var (@envvars) { |
$supportmsg .= "$var: $env{$var}\n"; |
$supportmsg .= "$var: $env{$var}\n"; |
} |
} |
|
if ($lti_info) { |
|
$supportmsg .= $lti_info; |
|
} |
} |
} |
|
|
my $msg = MIME::Lite->new( |
my $cc_string; |
From => $from, |
|
To => $to, |
|
Subject => $subject, |
|
Type =>'TEXT', |
|
Data => $supportmsg, |
|
); |
|
if ($homeserver) { |
if ($homeserver) { |
if (@ok_ccs > 0) { |
if (@ok_ccs > 0) { |
my $cc_string = join(', ',@ok_ccs); |
$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 |
|
); |
|
|
|
} else { |
my $attachment_text = ''; |
my $envdata = ''; |
unless ($homeserver && $attachmentpath) { |
foreach my $var (@cookievars) { |
foreach my $var (@cookievars) { |
$envdata .= "$var: $cookies{$var}\n"; |
$attachment_text .= "$var: $cookies{$var}\n"; |
} |
} |
foreach my $var (@ENVvars) { |
foreach my $var (@ENVvars) { |
$envdata .= "$var: $ENV{$var}\n"; |
$attachment_text .= "$var: $ENV{$var}\n"; |
} |
} |
foreach my $var (@envvars) { |
foreach my $var (@envvars) { |
$envdata .= "$var: $env{$var}\n"; |
$attachment_text .= "$var: $env{$var}\n"; |
} |
} |
foreach my $var (@loncvars) { |
foreach my $var (@loncvars) { |
$envdata .= "$var: $env{$var}\n"; |
$attachment_text .= "$var: $env{$var}\n"; |
|
} |
|
if ($lti_info) { |
|
$attachment_text .= $lti_info; |
|
} |
|
} |
|
|
|
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; |
} |
} |
$msg->attach(Type => 'TEXT', |
|
Data => $envdata); |
|
} |
} |
|
|
### Send it: |
# Compose and send a MIME email |
$msg->send('sendmail'); |
&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+)/[^/]+|) { |
if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { |
unlink($attachmentpath); |
unlink($attachmentpath); |
Line 938 sub print_header {
|
Line 1167 sub print_header {
|
login => 'Log-in help', |
login => 'Log-in help', |
ask => 'Ask helpdesk', |
ask => 'Ask helpdesk', |
getst => 'Getting started guide', |
getst => 'Getting started guide', |
back => 'Back to last location', |
back => 'Back to last location', |
headline => 'help/support', |
headline => 'help/support', |
stud => 'Students', |
stud => 'Students', |
ifyo => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.', |
ifyo => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.', |
Line 951 sub print_header {
|
Line 1180 sub print_header {
|
} else { |
} else { |
$reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.'); |
$reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.'); |
} |
} |
|
my $linkback; |
if ($origurl eq '') { |
if ($origurl eq '') { |
$origurl = 'javascript:history.go(-1)'; |
$linkback = 'javascript:history.go(-1)'; |
|
} else { |
|
$linkback = &HTML::Entities::encode($origurl,'"<>&'); |
} |
} |
my $loginhelp = &Apache::lonauth::loginhelpdisplay(); |
my $loginhelp = &Apache::lonauth::loginhelpdisplay(); |
if ($loginhelp eq '') { |
if ($loginhelp eq '') { |
Line 972 sub print_header {
|
Line 1204 sub print_header {
|
<tr> |
<tr> |
<td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" /> <b><a href="$loginhelp">$lt{'login'}</a></b> </span></td> |
<td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" /> <b><a href="$loginhelp">$lt{'login'}</a></b> </span></td> |
<td align="center"><span class="LC_nobreak"> <b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" style="vertical-align:middle" /> $lt{'ask'}</a></b> </span></td>$getstartlink |
<td align="center"><span class="LC_nobreak"> <b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" style="vertical-align:middle" /> $lt{'ask'}</a></b> </span></td>$getstartlink |
<td align="center"><span class="LC_nobreak"> <b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="($lt{'back'})" style="vertical-align:middle" /> $lt{'back'}</a></b> </span></td> |
<td align="center"><span class="LC_nobreak"> <b><a href="$linkback" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="($lt{'back'})" style="vertical-align:middle" /> $lt{'back'}</a></b> </span></td> |
</tr> |
</tr> |
</table> |
</table> |
</fieldset> |
</fieldset> |
Line 989 END
|
Line 1221 END
|
$r->print(<<"END"); |
$r->print(<<"END"); |
<tr> |
<tr> |
<td colspan="3">$reviewtext |
<td colspan="3">$reviewtext |
$lt{'ifyo'}<br /> |
$lt{'ifyo'} |
<span style="font-size:90%;"><b>$lt{'stud'}</b>: |
<p class="LC_info"> |
$stuwarn $lt{'cont'}</span> |
<b>$lt{'stud'}:</b> |
<br /><br /> |
$stuwarn $lt{'cont'} |
|
</p><br /> |
</td> |
</td> |
</tr> |
</tr> |
END |
END |
Line 1005 END
|
Line 1238 END
|
sub get_domain { |
sub get_domain { |
my $codedom; |
my $codedom; |
if (exists($env{'form.codedom'})) { |
if (exists($env{'form.codedom'})) { |
$codedom = $env{'form.codedom'}; |
if (&Apache::lonnet::domain($env{'form.codedom'}) ne '') { |
} elsif ($env{'request.course.id'}) { |
return $env{'form.codedom'}; |
|
} |
|
} |
|
if ($env{'request.course.id'}) { |
$codedom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$codedom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
} elsif ($env{'request.role.domain'}) { |
} elsif ($env{'request.role.domain'}) { |
$codedom = $env{'request.role.domain'}; |
$codedom = $env{'request.role.domain'}; |
Line 1016 sub get_domain {
|
Line 1252 sub get_domain {
|
return $codedom; |
return $codedom; |
} |
} |
|
|
sub cleanup_html { |
|
my ($incoming) = @_; |
|
my $outgoing; |
|
if ($incoming ne '') { |
|
$outgoing = $incoming; |
|
$outgoing =~ s/\#/#/g; |
|
$outgoing =~ s/\&/&/g; |
|
$outgoing =~ s/</</g; |
|
$outgoing =~ s/>/>/g; |
|
$outgoing =~ s/\(/(/g; |
|
$outgoing =~ s/\)/)/g; |
|
$outgoing =~ s/"/"/g; |
|
$outgoing =~ s/'/'/g; |
|
$outgoing =~ s/\$/$/g; |
|
} |
|
return $outgoing; |
|
} |
|
|
|
1; |
1; |