version 1.4, 2004/07/09 21:08:24
|
version 1.55.6.1, 2010/11/29 13:36:43
|
Line 1
|
Line 1
|
|
# |
|
# $Id$ |
|
# |
|
# Copyright Michigan State University Board of Trustees |
|
# |
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
# |
|
# LON-CAPA is free software; you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation; either version 2 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# LON-CAPA is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with LON-CAPA; if not, write to the Free Software |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
# |
|
# /home/httpd/html/adm/gpl.txt |
|
# |
|
# http://www.lon-capa.org/ |
|
# |
|
|
package Apache::lonsupportreq; |
package Apache::lonsupportreq; |
|
|
use strict; |
use strict; |
use lib qw(/home/httpd/lib/perl); |
use MIME::Types; |
|
use MIME::Lite; |
|
use CGI::Cookie(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonnet(); |
use Apache::lonhtmlcommon; |
use localenroll; |
use Apache::lonnet; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonacc(); |
use Mail::Send; |
use Apache::courseclassifier; |
# use MIME::Lite; |
use LONCAPA; |
# use MIME::Types; |
|
|
|
sub handler { |
sub handler { |
my ($r) = @_; |
my ($r) = @_; |
Line 20 sub handler {
|
Line 48 sub handler {
|
if ($r->header_only) { |
if ($r->header_only) { |
return OK; |
return OK; |
} |
} |
|
if ($r->uri eq '/adm/helpdesk') { |
|
&Apache::lonlocal::get_language_handle($r); |
|
} |
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']); |
|
if ($r->uri eq '/adm/helpdesk') { |
|
&Apache::lonacc::get_posted_cgi($r); |
|
} |
|
my $function = $env{'form.function'}; |
|
my $origurl = &unescape($env{'form.origurl'}); |
|
my $command = $env{'form.command'}; |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','origurl','function']); |
if ($command eq 'process') { |
my $action = $ENV{'form.action'}; |
|
my $function = $ENV{'form.function'}; |
|
my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'}); |
|
if ($action eq 'process') { |
|
&print_request_receipt($r,$origurl,$function); |
&print_request_receipt($r,$origurl,$function); |
} else { |
} else { |
&print_request_form($r,$origurl,$function); |
&print_request_form($r,$origurl,$function); |
Line 35 sub handler {
|
Line 70 sub handler {
|
|
|
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,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server); |
my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname); |
my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1); |
$function = &Apache::loncommon::get_users_function() if (!$function); |
my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); |
$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'}; |
$uhost = $env{'request.host'}; |
$uname = $ENV{'user.name'}; |
$uname = $env{'user.name'}; |
$udom = $ENV{'user.domain'}; |
$udom = $env{'user.domain'}; |
$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'}; |
$server = $ENV{'SERVER_NAME'}; |
$formname = 'logproblem'; |
my $scripttag; |
my $machine = &Apache::lonnet::absolute_url(); |
if ($cid =~ m/_/) { |
if ($origurl =~ m-^https?://-) { |
($cdom,$cnum) = split/_/,$cid; |
$server = $origurl; |
|
} else { |
|
$server = $machine.$origurl; |
|
} |
|
my $showserver = $server; |
|
$showserver =~ s/\?.*$//; |
|
my %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', |
|
name => 'Name', |
|
subm => 'Submit Request', |
|
emad => 'Your e-mail address', |
|
emac => 'Cc', |
|
unme => 'username', |
|
doma => 'domain', |
|
entu => 'Enter the username you use to log-in to LON-CAPA', |
|
chdo => 'Choose your LON-CAPA domain', |
|
entr => 'Enter the username you use to log-in to LON-CAPA, and your domain.', |
|
urlp => 'URL of page', |
|
phon => 'Phone', |
|
crsd => 'Course Details', |
|
enin => 'Enter institutional course code', |
|
pick => 'Pick', |
|
enct => 'Enter course title', |
|
secn => 'Section Number', |
|
sele => 'Select', |
|
titl => 'Title', |
|
lsec => 'LON-CAPA sec', |
|
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.)', |
|
fini => 'Finish', |
|
clfm => 'Clear Form', |
|
); |
|
my $scripttag = (<<"END"); |
|
function validate() { |
|
if (validmail(document.logproblem.email) == false) { |
|
alert("$lt{'email'}: "+document.logproblem.email.value+" $lt{'notv'}."); |
|
return; |
|
} |
|
if (document.logproblem.subject.value == '') { |
|
alert("$lt{'rsub'}."); |
|
return; |
|
} |
|
if (document.logproblem.description.value == '') { |
|
alert("$lt{'rdes'}."); |
|
return; |
|
} |
|
document.logproblem.submit(); |
|
} |
|
|
|
END |
|
$scripttag .= &Apache::lonhtmlcommon::javascript_valid_email(); |
|
if ($cid) { |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
} |
} |
if ($cdom && $cnum) { |
if ($cdom && $cnum) { |
my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum); |
my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum); |
Line 59 sub print_request_form {
|
Line 152 sub print_request_form {
|
$ccode = $csettings{'internal.coursecode'}; |
$ccode = $csettings{'internal.coursecode'}; |
$sectionlist = $csettings{'internal.sectionnums'}; |
$sectionlist = $csettings{'internal.sectionnums'}; |
} |
} |
if ($ENV{'environment.critnotification'}) { |
|
$email = $ENV{'environment.critnotification'}; |
if ($env{'environment.permanentemail'}) { |
} |
$email = $env{'environment.permanentemail'}; |
if (!$email && $ENV{'environment.notification'}) { |
} elsif ($env{'environment.critnotification'}) { |
$email = $ENV{'environment.notification'}; |
$email = $env{'environment.critnotification'}; |
} |
} elsif ($env{'environment.notification'}) { |
if ($ENV{'environment.lastname'}) { |
$email = $env{'environment.notification'}; |
$lastname = $ENV{'environment.lastname'}; |
} |
} |
if ($env{'environment.lastname'}) { |
if ($ENV{'environment.firstname'}) { |
$lastname = $env{'environment.lastname'}; |
$firstname = $ENV{'environment.firstname'}; |
} |
} |
if ($env{'environment.firstname'}) { |
my @sections = split/,/,$sectionlist; |
$firstname = $env{'environment.firstname'}; |
my %groupid = (); |
} |
foreach (@sections) { |
my @sections = split(/,/,$sectionlist); |
my ($sec,$grp) = split/:/,$_; |
my %groupid; |
|
foreach my $section (@sections) { |
|
my ($sec,$grp) = split(/:/,$section); |
$groupid{$sec} = $grp; |
$groupid{$sec} = $grp; |
} |
} |
$r->print(<<END); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']); |
<html> |
my $codedom = &get_domain(); |
<head> |
my $details_title; |
<title>LON-CAPA support request</title> |
if ($codedom) { |
END |
$details_title = '<br />('.$codedom.')'; |
my $defdom = $Apache::lonnet::perlvar{'lonDefDomain'}; |
} |
my $codedom = $defdom; |
my %coursecodes; |
my %coursecodes = (); |
my %codes; |
my %codes = (); |
my @codetitles; |
my @codetitles = (); |
my %cat_titles; |
my %cat_titles = (); |
my %cat_order; |
my %cat_order = (); |
my %idlist; |
|
my %idnums; |
|
my %idlist_titles; |
my $caller = 'global'; |
my $caller = 'global'; |
my $totcodes = 0; |
my $totcodes = 0; |
my $format_reply; |
my $format_reply; |
|
my $jscript = ''; |
if ($cdom) { |
my $loaditems = qq| |
$codedom = $cdom; |
function initialize_codes() { |
} |
return; |
|
} |
|
|; |
if ($cnum) { |
if ($cnum) { |
$coursecodes{$cnum} = $ccode; |
$coursecodes{$cnum} = $ccode; |
if ($ccode eq '') { |
if ($ccode eq '') { |
$totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
} else { |
} else { |
$coursecodes{$cnum} = $ccode; |
$coursecodes{$cnum} = $ccode; |
$caller = $cnum; |
$caller = $cnum; |
$totcodes ++; |
$totcodes ++; |
} |
} |
} else { |
} else { |
$totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
} |
} |
if ($totcodes > 0) { |
if ($totcodes > 0) { |
$format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); |
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 = ''; |
|
} |
|
} |
} |
} |
$r->print(<<END); |
|
<html> |
my $js = '<script type="text/javascript">'."\n$scripttag\n$jscript\n". |
<head> |
'</script>'; |
<title>LON-CAPA support request</title> |
my %add_entries = (topmargin => "0", |
$scripttag |
marginheight => "0", |
</head> |
onLoad =>"initialize_codes()",); |
$bodytag |
|
<table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"> |
|
<tr> |
$r->print(&Apache::loncommon::start_page('Support Request',$js, |
<td> |
{ 'function' => $function, |
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"> |
'add_entries' => \%add_entries, |
<tr> |
'only_body' => 1,})); |
<td> |
if ($r->uri eq '/adm/helpdesk') { |
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff"> |
&print_header($r,$origurl); |
<tr> |
} |
<td> |
my @css = ('LC_evenrow_value','LC_oddrow_value'); |
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff"> |
my $num = 1; |
<form method="post" name="logproblem" onSubmit="return validate()"> |
my $i = $num%2; |
<tr> |
$r->print('<form method="post" name="logproblem" enctype="multipart/form-data">'."\n"); |
<td width="140" bgcolor="$tablecolor"> |
my $output = &Apache::lonhtmlcommon::start_pick_box(). |
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
&Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n"; |
<tr> |
|
<td align="right"><b>Name:</b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
END |
|
my $fullname = ''; |
my $fullname = ''; |
if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) { |
if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) { |
$fullname = "$firstname $lastname"; |
$fullname = "$firstname $lastname"; |
$r->print("$fullname<input type=\"hidden\" name=\"username\" value=\"$fullname\" />"); |
$output .= $fullname.'<input type="hidden" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'; |
} else { |
} else { |
if (defined($firstname) && $firstname ne '') { |
if (defined($firstname) && $firstname ne '') { |
$fullname = $firstname; |
$fullname = $firstname; |
} elsif (defined($lastname) && $lastname ne '') { |
} elsif (defined($lastname) && $lastname ne '') { |
$fullname= " $lastname"; |
$fullname = " $lastname"; |
} |
} |
$r->print('<input type="text" size="20" name="username" value="'.$fullname.'" /><br />'); |
$output .= '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'; |
} |
} |
$r->print(<<END); |
$output .= ' <input type="button" value="'.$lt{'subm'}.'" onclick="validate()" /> '. |
</td> |
&Apache::lonhtmlcommon::row_closure()."\n"; |
</tr> |
$num ++; |
</table> |
$i = $num%2; |
</td> |
$output .= &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,$css[$i]). |
</tr> |
'<input type="text" size="20" name="email" value="'. |
<tr> |
&HTML::Entities::encode($email,'"<>&').'" /><br />'."\n". |
<td width="100%" colspan="2" bgcolor="#000000"> |
&Apache::lonhtmlcommon::row_closure(); |
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
$num ++; |
</td> |
$i = $num%2; |
</tr> |
if (defined($env{'user.name'})) { |
<tr> |
$output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]). |
<td width="140" bgcolor="$tablecolor"> |
'<input type="text" size="50" name="cc" value="" /><br />'."\n". |
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
&Apache::lonhtmlcommon::row_closure(); |
<tr> |
$num ++; |
<td align="right"><b>E-mail address:</b> |
$i = $num%2; |
</td> |
} |
</tr> |
$output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]); |
</table> |
my $udom_input = '<input type="hidden" name="udom" value="'. |
</td> |
&HTML::Entities::encode($udom,'"<>&').'" />'; |
<td width="100%" valign="top"> |
my $uname_input = '<input type="hidden" name="uname" value="'. |
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
&HTML::Entities::encode($uname,'"<>&').'" />'; |
<tr> |
|
<td> |
|
<input type="text" size="20" name="email" value="$email" /><br /> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="100%" colspan="2" bgcolor="#000000"> |
|
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="140" bgcolor="$tablecolor"> |
|
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td align="right"><b>username/domain:</b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
END |
|
my $udom_input = '<input type="hidden" name="udom" value="'.$udom.'" />'; |
|
my $uname_input = '<input type="hidden" name="uname" value="'.$uname.'" />'; |
|
if (defined($uname) && defined($udom)) { |
if (defined($uname) && defined($udom)) { |
$r->print('<i>username</i>: '.$uname.' <i>domain</i>: '.$udom.$udom_input.$uname_input); |
$output .= '<i>'.$lt{'unme'}.'</i>: '.$uname.' <i>'.$lt{'doma'}.'</i>: '.$udom.$udom_input.$uname_input; |
} else { |
} else { |
my $udomform = ''; |
my $udomform = ''; |
my $unameform = ''; |
my $unameform = ''; |
if (defined($udom)) { |
if (defined($udom)) { |
$udomform = '<i>domain</i>: '.$udom.$udom_input; |
$output .= $lt{'entu'}; |
} elsif (defined($uname)) { |
} elsif (defined($uname)) { |
$unameform = '<i>username</i>: '.$uname.' '.$uname_input; |
$output .= $lt{'chdo'}; |
|
} else { |
|
$output .= $lt{'entr'}; |
|
} |
|
$output .= '<br />'; |
|
if (defined($udom)) { |
|
$udomform = '<i>'.$lt{'doma'}.'</i>: '.$udom.$udom_input; |
|
} elsif (defined($uname)) { |
|
$unameform = '<i>'.$lt{'unme'}.'</i>: '.$uname.' '.$uname_input; |
} |
} |
if ($udomform eq '') { |
if ($udomform eq '') { |
$udomform = '<i>domain</i>: '; |
$udomform = '<i>'.$lt{'doma'}.'</i>: '; |
$udomform .= &Apache::loncommon::select_dom_form('','udom'); |
$udomform .= &Apache::loncommon::select_dom_form($codedom,'udom'); |
} |
} |
if ($unameform eq '') { |
if ($unameform eq '') { |
$unameform= '<i>username</i>: <input type="text" size="20" name="loncname" value="'.$uname.'" /> '; |
$unameform= '<i>'.$lt{'unme'}.'</i>: <input type="text" size="15" name="uname" value="'.$uname.'" /> '; |
} |
} |
$r->print($unameform.$udomform.'<br />Enter the username you use to log-in to your LON-CAPA system, and choose your domain.'); |
$output .= $unameform.$udomform; |
} |
} |
$r->print(<<END); |
$output .= &Apache::lonhtmlcommon::row_closure(); |
</td> |
$num ++; |
</tr> |
$i = $num%2; |
</table> |
$output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]). |
</td> |
$showserver.'<input type="hidden" name="sourceurl" value="'. |
</tr> |
&HTML::Entities::encode($server,'"<>&').'" />'. |
<tr> |
&Apache::lonhtmlcommon::row_closure(); |
<td width="100%" colspan="2" bgcolor="#000000"> |
if (&Apache::loncommon::check_for_gci_dc()) { |
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
$output .= &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef, |
</td> |
'LC_evenrow_value'). |
</tr> |
'<input type="text" size="15" name="phone" /><br />'. |
<tr> |
&Apache::lonhtmlcommon::row_closure(); |
<td width="140" bgcolor="$tablecolor"> |
$num ++; |
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
$i = $num%2; |
<tr> |
$output .= &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,$css[$i]); |
<td align="right"><b>URL of page:</b> |
if ($cnum) { |
</td> |
if ($coursecodes{$cnum}) { |
</tr> |
foreach my $item (@codetitles) { |
</table> |
$output .= '<i>'.$item.'</i>: '.$codes{$cnum}{$item}.'; '; |
</td> |
} |
<td width="100%" valign="top"> |
$output .= ' <input type="hidden" name="coursecode" value="'.&HTML::Entities::encode($coursecodes{$cnum},'"<>&').'" />'; |
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
$server$origurl<input type="hidden" name="origurl" value="$server$origurl" /> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="100%" colspan="2" bgcolor="#000000"> |
|
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="140" bgcolor="$tablecolor"> |
|
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td align="right"><b>Phone #:</b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
<input type="text" size="15" name="phone"><br> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="100%" colspan="2" bgcolor="#000000"> |
|
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="140" bgcolor="$tablecolor"> |
|
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td align="right"><b>Course Details:</b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table border="0" cellpadding="3" cellspacing="3"> |
|
<tr> |
|
<td> |
|
END |
|
if ($coursecodes{$cnum}) { |
|
foreach (@codetitles) { |
|
$r->print('<i>'.$_.'</i>: '.$codes{$cnum}{$_}); |
|
} |
|
$r->print('. <input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />'); |
|
} else { |
|
$r->print('Enter institutional course code: |
|
<input type="text" name="coursecode" size="15" value="" />'); |
|
} |
|
if ($ctitle) { |
|
$r->print('<br /><i>Title</i>: '.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />'); |
|
} else { |
|
$r->print('<br />Enter course title: |
|
<input type="text" name="title" size="15" value="" />'); |
|
} |
|
$r->print(<<END); |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="100%" colspan="2" bgcolor="#000000"> |
|
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="140" bgcolor="$tablecolor"> |
|
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td align="right"><b>Section Number: </b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
END |
|
if ($sectionlist) { |
|
$r->print("<select name=\"section\">"); |
|
foreach (sort keys %groupid) { |
|
if ($_ eq $groupid{$_} || $groupid{$_} eq '') { |
|
$r->print("<option value=\"$_\" />$_"); |
|
} else { |
} else { |
$r->print("<option value=\"$_\" />$_ - (LON-CAPA sec: $groupid{$_}"); |
$output .= $lt{'enin'}.': |
|
<input type="text" name="coursecode" size="15" value="" />'; |
|
} |
|
} else { |
|
if ($totcodes > 0) { |
|
my $numtitles = @codetitles; |
|
if ($numtitles == 0) { |
|
$output .= $lt{'enin'}.': |
|
<input type="text" name="coursecode" size="15" value="" />'; |
|
} else { |
|
my $lasttitle = $numtitles; |
|
if ($numtitles > 4) { |
|
$lasttitle = 4; |
|
} |
|
$output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n". |
|
'<select name="'.$codetitles[0].'" onchange="courseSet('."'$codetitles[0]'".')">'."\n". |
|
' <option value="-1" />'.$lt{'sele'}."\n"; |
|
my @items = (); |
|
my @longitems = (); |
|
if ($idlist{$codetitles[0]} =~ /","/) { |
|
@items = split(/","/,$idlist{$codetitles[0]}); |
|
} else { |
|
$items[0] = $idlist{$codetitles[0]}; |
|
} |
|
if (defined($idlist_titles{$codetitles[0]})) { |
|
if ($idlist_titles{$codetitles[0]} =~ /","/) { |
|
@longitems = split(/","/,$idlist_titles{$codetitles[0]}); |
|
} else { |
|
$longitems[0] = $idlist_titles{$codetitles[0]}; |
|
} |
|
for (my $i=0; $i<@longitems; $i++) { |
|
if ($longitems[$i] eq '') { |
|
$longitems[$i] = $items[$i]; |
|
} |
|
} |
|
} else { |
|
@longitems = @items; |
|
} |
|
for (my $i=0; $i<@items; $i++) { |
|
$output .= ' <option value="'.$items[$i].'">'.$longitems[$i].'</option>'."\n"; |
|
} |
|
$output .= '</select></td>'; |
|
for (my $i=1; $i<$numtitles; $i++) { |
|
$output .= '<td>'.$codetitles[$i].'<br />'."\n". |
|
'<select name="'.$codetitles[$i].'" onchange="courseSet('."'$codetitles[$i]'".')">'."\n". |
|
'<option value="-1"><-'.$lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n". |
|
'</select>'."\n". |
|
'</td>'."\n"; |
|
} |
|
$output .= '</tr></table>'; |
|
if ($numtitles > 4) { |
|
$output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n". |
|
'<select name="'.$codetitles[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".')">'."\n". |
|
'<option value="-1"><-'.$lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n". |
|
'</select>'."\n"; |
|
} |
|
} |
|
} else { |
|
$output .= $lt{'enin'}.': |
|
<input type="text" name="coursecode" size="15" value="" />'; |
} |
} |
} |
} |
$r->print("</select>"); |
$output .= '<br />'; |
} else { |
if ($ctitle) { |
$r->print("<input type=\"text\" name=\"section\" size=\"10\"/>"); |
$output .= '<i>'.$lt{'titl'}.'</i>: '.$ctitle. |
|
'<input type="hidden" name="title" value="'. |
|
&HTML::Entities::encode($ctitle,'"<>&').'" />'."\n"; |
|
} else { |
|
$output .= $lt{'enct'}.': |
|
<input type="text" name="title" size="25" value="" />'."\n"; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_closure(); |
|
$num ++; |
|
$i = $num%2; |
|
$output .= &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,$css[$i]); |
|
if ($sectionlist) { |
|
$output .= "<select name=\"section\"\n>". |
|
" <option value=\"\" selected=\"selected\">$lt{'sele'}</option>\n"; |
|
foreach my $id (sort(keys(%groupid))) { |
|
if ($id eq $groupid{$id} || $groupid{$id} eq '') { |
|
$output .= " <option value=". |
|
&HTML::Entities::encode($id,'"<>&'). |
|
" >$id</option>\n"; |
|
} else { |
|
$output .= " <option value=". |
|
&HTML::Entities::encode($id,'"<>&'). |
|
" >$id - ($lt{'lsec'}: $groupid{$id})</option>\n"; |
|
} |
|
} |
|
$output .= "</select>"; |
|
} else { |
|
$output .= '<input type="text" name="section" size="10" />'; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_closure(); |
} |
} |
$r->print(<<END); |
$num ++; |
</td> |
$i = $num%2; |
</tr> |
$output .= &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_oddrow_value'). |
</table> |
' <input type="text" size="40" name="subject" />'."\n". |
</td> |
&Apache::lonhtmlcommon::row_closure(). |
</tr> |
&Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_evenrow_value'). |
<tr> |
' <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>'. |
<td width="100%" colspan="2" bgcolor="#000000"> |
&Apache::lonhtmlcommon::row_closure(); |
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
$num ++; |
</td> |
$i = $num%2; |
</tr> |
if (defined($env{'user.name'})) { |
<tr> |
$output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]). |
<td width="140" bgcolor="$tablecolor"> |
' <input type="file" name="screenshot" size="20" /><br />'.$lt{'uplf'}."\n". |
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
&Apache::lonhtmlcommon::row_closure(); |
<tr> |
$num ++; |
<td align="right"><b>Subject</b> |
$i = $num%2; |
</td> |
} |
</tr> |
$output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]); |
</table> |
$output .= <<END; |
</td> |
|
<td width="100%" valign="top"> |
|
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
<input type="text" size="40" name="subject"> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="100%" colspan="2" bgcolor="#000000"> |
|
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="140" bgcolor="$tablecolor"> |
|
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td align="right"><b>Detailed description:</b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td> |
|
<textarea rows="10" cols="45" name="description" wrap="virtual"></textarea> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="100%" colspan="2" bgcolor="#000000"> |
|
<img src="/adm/lonMisc/blackdot.gif" /><br /> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td width="140" bgcolor="$tablecolor"> |
|
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
|
<tr> |
|
<td align="right"><b>Finish:</b> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td width="100%" valign="top"> |
|
<table border="0" cellpadding="8" cellspacing="0"> |
<table border="0" cellpadding="8" cellspacing="0"> |
<tr> |
<tr> |
<td> |
<td> |
<input type="hidden" name="action" value="process" /> |
<input type="hidden" name="command" value="process" /> |
<input type="submit" value="Submit Request Form" /> |
<input type="button" value="$lt{'subm'}" onclick="validate()" /> |
</td> |
</td> |
<td> </td> |
<td> </td> |
<td> |
<td> |
<input type="reset" value="Clear Form"> |
<input type="reset" value="$lt{'clfm'}" /> |
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
END |
END |
|
$output .= &Apache::lonhtmlcommon::row_closure(1); |
|
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
# What do we know about this user? |
$r->print(<<END); |
# foreach (sort keys %ENV) { |
$output |
# if ($_ =~ m/^browser/) { |
</form> |
# $r->print("key is $_, value is $ENV{$_}"); |
<br /> |
# } elsif ($_ =~ m/^environment/) { |
END |
# $r->print("key is $_, value is $ENV{$_}"); |
$r->print(&Apache::loncommon::end_page()); |
# } elsif ($_ =~ m/^request/) { |
return; |
# $r->print("key is $_, value is $ENV{$_}"); |
|
# } elsif ($_ =~ m/^user\.(domain|home|name)/) { |
|
# $r->print("key is $_, value is $ENV{$_}"); |
|
# } elsif ($_ =~ /^[A-Z]/) { |
|
# $r->print("key is $_, value is $ENV{$_}"); |
|
# } |
|
# } |
|
return |
|
} |
} |
|
|
sub print_request_receipt { |
sub print_request_receipt { |
my ($r,$url,$function) = @_; |
my ($r,$url,$function) = @_; |
my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role'); |
my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME'); |
my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1); |
my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role'); |
my $to = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id'); |
|
my @cookievars = ('lonID'); |
|
|
|
my $admin = $Apache::lonnet::perlvar{'lonAdminMail'}; |
|
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
|
my $defdom = &get_domain(); |
|
my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', |
|
$defdom,$origmail); |
|
my $from = $admin; |
my $reporttime = &Apache::lonlocal::locallocaltime(time); |
my $reporttime = &Apache::lonlocal::locallocaltime(time); |
my $fontcolor = &Apache::loncommon::designparm($function.'.font'); |
my @formvars = ('username','email','uname','udom','sourceurl'); |
my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink'); |
if (&Apache::loncommon::check_for_gci_dc()) { |
my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); |
push(@formvars,('phone','section','coursecode','title')); |
my @formvars = ('username','email','uname','udom','origurl','phone','section','coursecode','title','subject','description'); |
} |
|
push(@formvars,('subject','description','screenshot')); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); |
|
my $coursecode = $env{'form.coursecode'}; |
|
if (&Apache::loncommon::check_for_gci_dc()) { |
|
if ($coursecode eq '') { |
|
if (defined($env{'form.Year'})) { |
|
$coursecode .= $env{'form.Year'}; |
|
} |
|
if (defined($env{'form.Semester'})) { |
|
$coursecode .= $env{'form.Semester'}; |
|
} |
|
if (defined($env{'form.Department'})) { |
|
$coursecode .= $env{'form.Department'}; |
|
} |
|
if (defined($env{'form.Number'})) { |
|
$coursecode .= $env{'form.Number'}; |
|
} |
|
} |
|
} |
|
my %lt = &Apache::lonlocal::texthash ( |
|
username => 'Name', |
|
email => 'E-mail', |
|
cc => 'Cc', |
|
user => 'Username/domain', |
|
phone => 'Phone', |
|
crsi => 'Course Information', |
|
subject => 'Subject', |
|
description => 'Description', |
|
sourceurl => 'URL', |
|
date => 'Date/Time', |
|
secn => 'Section', |
|
asup => 'A support request has been sent to', |
|
warn => 'Warning: Problem with support e-mail address', |
|
your => 'Your support request contained the following information', |
|
sect => 'section', |
|
info => 'Information supplied', |
|
adin => 'Additional information recorded', |
|
); |
|
|
|
my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist); |
|
if ((defined($env{'user.name'})) && (defined($env{'form.cc'}))) { |
|
my @ccs; |
|
if ($env{'form.cc'} =~ /,/) { |
|
@ccs = split(/,/,$env{'form.cc'}); |
|
} else { |
|
$env{'form.cc'} =~ s/^\s+//; |
|
$env{'form.cc'} =~ s/\s+$//; |
|
@ccs = $env{'form.cc'}; |
|
} |
|
foreach my $cc (@ccs) { |
|
$cc =~ s/^\s+//g; |
|
$cc =~ s/\s+$//g; |
|
if ($cc =~ m/^[^\@]+\@[^\@]+$/) { |
|
if (!(grep(/^\Q$cc\E$/,@ok_ccs))) { |
|
push(@ok_ccs,$cc); |
|
} |
|
} else { |
|
if (!(grep(/^\Q$cc\E$/,@bad_ccs))) { |
|
push(@bad_ccs,$cc); |
|
} |
|
} |
|
} |
|
if (@ok_ccs > 0) { |
|
$okcclist = join(', ',@ok_ccs); |
|
} |
|
if (@bad_ccs == 1) { |
|
$badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0]; |
|
} elsif (@bad_ccs > 1) { |
|
my $bad_cc_string = join(', ',@bad_ccs); |
|
$badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string; |
|
} |
|
} |
|
$env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'"; |
|
if (&Apache::loncommon::check_for_gci_dc()) { |
|
$env{'form.csri'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'}; |
|
} |
|
my $supportmsg = <<END; |
|
$lt{'username'}: $env{'form.username'} |
|
$lt{'email'}: $env{'form.email'} |
|
$lt{'cc'}: $okcclist |
|
$lt{'user'}: $env{'form.user'} |
|
END |
|
if (&Apache::loncommon::check_for_gci_dc()) { |
|
$supportmsg .= <<END |
|
$lt{'phone'}: $env{'form.phone'} |
|
$lt{'crsi'}: $env{'form.csri'} |
|
END |
|
} |
|
$supportmsg = <<END; |
|
$lt{'subject'}: $env{'form.subject'} |
|
$lt{'description'}: $env{'form.description'} |
|
$lt{'sourceurl'}: $env{'form.sourceurl'} |
|
$lt{'date'}: $reporttime |
|
|
# if ($ENV{'request.course.fn'}) { |
|
# my $formdatafile = $ENV{'request.course.fn'}.'.formdata'; |
|
# if (-e $formdatafile) { |
|
# open(FILE,"<$formdatafile"); |
|
# my @buffer =<FILE>; |
|
# close(FILE); |
|
# foreach (@buffer) { |
|
# print STDERR $_; |
|
# } |
|
# } |
|
# } |
|
|
|
my $supportmsg = qq| |
|
Name: $ENV{'form.username'} |
|
Email: $ENV{'form.email'} |
|
Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'} |
|
Tel: $ENV{'form.phone'} |
|
Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'} |
|
Subject: $ENV{'form.subject'} |
|
Description: $ENV{'form.description'} |
|
URL: $ENV{'form.origurl'} |
|
Date/Time: $reporttime |
|
|
|
|; |
|
if ($to =~ m/^[^\@]+\@[^\@]+$/) { |
|
$r->print(<<END); |
|
<html> |
|
<head> |
|
<title>LON-CAPA support request recorded</title> |
|
</head> |
|
$bodytag |
|
<h3>A support request has been sent to $to</h3> |
|
END |
END |
} else { |
my $displaymsg; |
$to = 'helpdesk@lon-capa.org'; |
my @items = ('username','email','cc','user'); |
$r->print(<<END); |
if (&Apache::loncommon::check_for_gci_dc()) { |
<html> |
push(@items,'phone','crsi'); |
<head> |
} |
<title>LON-CAPA support request recorded</title> |
push(@items,('subject','description','sourceurl')); |
</head> |
foreach my $item (@items) { |
$bodytag |
if ($env{'form.'.$item} ne '') { |
<h3>Warning: Problem with support e-mail address</h3> |
if ($item eq 'description') { |
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 at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. |
my $descrip = $env{'form.description'}; |
|
$descrip = &cleanup_html($descrip); |
|
$descrip =~ s|[\n\r\f]|<br />|g; |
|
$displaymsg .= |
|
'<span class="LC_helpform_receipt_cat">'. |
|
"$lt{$item}</span>: $descrip<br />\n"; |
|
} elsif ($item eq 'sourceurl') { |
|
my $showurl = $env{'form.sourceurl'}; |
|
$showurl =~ s/\?.*$//; |
|
$showurl = &cleanup_html($showurl); |
|
$displaymsg .= |
|
'<span class="LC_helpform_receipt_cat">'. |
|
"$lt{$item}</span>: $showurl<br />\n"; |
|
} elsif ($item eq 'cc') { |
|
$displaymsg .= |
|
'<span class="LC_helpform_receipt_cat">'. |
|
"$lt{$item}</span>: $okcclist<br />\n"; |
|
} else { |
|
my $showitem = $env{'form.'.$item}; |
|
$showitem = &cleanup_html($showitem); |
|
$displaymsg .= |
|
'<span class="LC_helpform_receipt_cat">'. |
|
"$lt{$item}</span>: $showitem<br />\n"; |
|
} |
|
} |
|
} |
|
$displaymsg .= '<span class="LC_helpform_receipt_cat">'. |
|
$lt{'date'}.'</span>: '.$reporttime.'<br />'."\n"; |
|
|
|
my $start_page = |
|
&Apache::loncommon::start_page('Support request recorded',undef, |
|
{'function' => $function, |
|
'add_entries' => { |
|
topmargin => "0", |
|
marginheight => "0", |
|
}, |
|
'only_body' => 1,}); |
|
|
|
$r->print(<<"END"); |
|
$start_page |
|
<form name="logproblem"> |
|
<input type="hidden" name="command" value="result" /> |
|
</form> |
END |
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 { |
|
$bad_email = 1; |
|
} |
|
} elsif ($to !~ m/^[^\@]+\@[^\@]+$/) { |
|
if ($admin =~ m/^[^\@]+\@[^\@]+$/) { |
|
$to = $admin; |
|
} else { |
|
$bad_email = 1; |
|
} |
|
} |
|
if ($bad_email) { |
|
$r->print(' |
|
<h3>'.$lt{'warn'}.'</h3>'. |
|
&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 <b>not</b> 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.')); |
|
$to = 'helpdesk@lon-capa.org'; |
|
} else { |
|
$r->print('<h3>'.$lt{'asup'}.' '.$to.'</h3>'); |
|
} |
|
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.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 $fname; |
|
|
|
my $attachmentpath = ''; |
|
my $attachmentsize = ''; |
|
if (defined($env{'user.name'})) { |
|
if ($env{'form.screenshot.filename'}) { |
|
$attachmentsize = length($env{'form.screenshot'}); |
|
if ($attachmentsize > 131072) { |
|
$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); |
|
} 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 .= '<br />' |
|
.&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].' |
|
,'<span class="LC_filename">'.$fname.'<span>' |
|
,$attachmentsize |
|
,$env{'user.name'}.':'.$env{'user.domain'} |
|
); |
|
$supportmsg .= "\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"; |
|
} |
|
} |
|
|
|
my $msg = MIME::Lite->new( |
|
From => $from, |
|
To => $to, |
|
Subject => $subject, |
|
Type =>'TEXT', |
|
Data => $supportmsg, |
|
); |
|
if (@ok_ccs > 0) { |
|
my $cc_string = join(', ',@ok_ccs); |
|
$msg->add("Cc" => $cc_string); |
|
} |
|
|
|
if ($attachmentpath) { |
|
my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); |
|
$msg->attach(Type => $type, |
|
Path => $attachmentpath, |
|
Filename => $fname |
|
); |
|
|
|
} else { |
|
my $envdata = ''; |
|
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 my $var (@loncvars) { |
|
$envdata .= "$var: $env{$var}\n"; |
|
} |
|
$msg->attach(Type => 'TEXT', |
|
Data => $envdata); |
} |
} |
my $msg = new Mail::Send; |
|
$msg->to($to); |
### Send it: |
# if (defined($ENV{'form.email'})) { |
$msg->send('sendmail'); |
# if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) { |
|
# $msg->from($ENV{'form.email'}); |
if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { |
# } |
unlink($attachmentpath); |
# } |
} |
$msg->subject('[LON-CAPA] - support request'); |
$r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n"); |
# ->open can cause an sh launch which can pass all of %ENV allong |
$r->print('<div style="width:620px;">'. |
# which can be to large for /bin/sh's little mind |
&Apache::lonhtmlcommon::start_pick_box(). |
my %oldENV=%ENV; |
&Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n". |
undef(%ENV); |
&Apache::lonhtmlcommon::row_closure(). |
if (my $fh = $msg->open()) { |
&Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value')); |
print $fh $supportmsg; |
my $envmsg; |
$fh->close; |
foreach my $var (@cookievars) { |
|
if ($cookies{$var} ne '') { |
|
$envmsg.= '<span class="LC_helpform_receipt_cat">'. |
|
$var.'</span>: '.$cookies{$var}.', '; |
|
} |
|
} |
|
foreach my $var (@ENVvars) { |
|
if ($ENV{$var} ne '') { |
|
$envmsg .= '<span class="LC_helpform_receipt_cat">'. |
|
$var.'</span>: '.$ENV{$var}.', '; |
|
} |
|
} |
|
foreach my $var (@envvars) { |
|
if ($env{$var} ne '') { |
|
$envmsg .= '<span class="LC_helpform_receipt_cat">'. |
|
$var.'</span>: '.$env{$var}.', '; |
|
} |
|
} |
|
$envmsg =~ s/, $//; |
|
$r->print($envmsg."\n". |
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::end_pick_box(). |
|
"</div>\n". |
|
&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub print_header { |
|
my ($r,$origurl,$command) = @_; |
|
my $location=&Apache::loncommon::lonhttpdurl("/adm"); |
|
my ($component_url); |
|
my $helpdesk_link = '<a href="javascript:validate()">'; |
|
if ($command eq 'process') { |
|
$helpdesk_link = '<a href="/adm/helpdesk">'; |
|
} |
|
my %lt = &Apache::lonlocal::texthash ( |
|
login => 'Log-in help', |
|
ask => 'Ask helpdesk', |
|
getst => 'Getting started guide', |
|
back => 'Back to last location', |
|
headline => 'help/support', |
|
); |
|
my ($getstartlink,$reviewtext); |
|
if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') { |
|
$getstartlink = qq|<td align="center"> <b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|; |
|
$reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.'); |
|
} else { |
|
$reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.'); |
} |
} |
%ENV=%oldENV; |
|
undef(%oldENV); |
|
$r->print(<<END); |
$r->print(<<END); |
<b>Your support request contained the following information</b>:<br /><br /> |
<table width="620" border="0" cellspacing="0" cellpadding="0" height="55"> <tr height="50"> <td width='5'> </td> |
<table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"> |
|
<tr> |
|
<td> |
<td> |
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"> |
<fieldset> |
<tr> |
<legend> |
<td> |
<img src="$location/lonIcons/minilogo.gif" height="20" width="29" valign="bottom" /> |
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff"> |
LON-CAPA $lt{'headline'} |
<tr> |
</legend> |
<td> |
<table id="LC_helpmenu_links"> |
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff"> |
<tr> |
<tr> |
<td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" valign="middle" /> <b><a href="/adm/loginproblems.html">$lt{'login'}</a></b> </span></td> |
<td width="140" bgcolor="$tablecolor"> |
<td align="center"><span class="LC_nobreak"> <b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" valign="middle" /> $lt{'ask'}</a></b> </span></td>$getstartlink |
<table width="140" border="0" cellpadding="8" cellspacing="0"> |
<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'})" valign="middle" /> $lt{'back'}</a></b> </span></td> |
<tr> |
</tr> |
<td align="right"><b>Information supplied</b> |
</table> |
</td> |
</fieldset> |
</tr> |
</td> |
</table> |
<td width='5'> </td> |
</td> |
</tr> |
<td width="100%" valign="top"> |
<tr height='5'> |
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
<td colspan='3' height='5'> </td> |
<tr> |
</tr> |
<td> |
|
END |
END |
my @textmsg = split/\n/,$supportmsg; |
if ($command ne 'process') { |
foreach my $line (@textmsg) { |
$r->print(' |
$line =~ s|^|<font color="$fontcolor">|; |
<tr> |
$line =~ s|:|:</font><font color="$vlinkcolor">|; |
<td colspan="3">'.$reviewtext.' ' |
$r->print("$line</font><br />"); |
.&mt('If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.').'<br />' |
} |
.'<font size="-1"><b>'.&mt('Students').'</b>: '.&mt('Do <b>not</b> use this form to ask questions about course content.').' ' |
$r->print('</td> |
.&mt('Contact your instructor instead.') |
</tr> |
.'</font><br /><br /> |
</table> |
</td> |
</td> |
</tr>'); |
</tr> |
} |
<tr> |
$r->print(' |
<td width="130" bgcolor="'.$tablecolor.'"> |
</table>'); |
<table width="130" border="0" cellpadding="8" cellspacing="0"> |
return; |
<tr> |
} |
<td align="right"><b>Additional information recorded</b> |
|
</td> |
sub get_domain { |
</tr> |
my $codedom; |
</table> |
if (exists($env{'form.codedom'})) { |
</td> |
$codedom = $env{'form.codedom'}; |
<td width="100%" valign="top"> |
} elsif ($env{'request.course.id'}) { |
<table width="100%" border="0" cellpadding="8" cellspacing="0"> |
$codedom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
<tr> |
} elsif ($env{'request.role.domain'}) { |
<td> |
$codedom = $env{'request.role.domain'}; |
'); |
} else { |
foreach (@envvars) { |
$codedom = &Apache::lonnet::default_login_domain(); |
$r->print("$_: <font color='$vlinkcolor>$ENV{$_}</font>, "); |
|
$supportmsg .= "$_: $ENV{$_}\n"; |
|
} |
} |
$r->print(" |
return $codedom; |
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
"); |
|
} |
} |
|
|
sub retrieve_instcodes { |
sub cleanup_html { |
my ($coursecodes,$codedom,$totcodes) = @_; |
my ($incoming) = @_; |
my %courses = &Apache::lonnet::courseiddump($codedom,'.',1); |
my $outgoing; |
foreach my $course (keys %courses) { |
if ($incoming ne '') { |
if ($courses{$course} =~ m/^[^:]*:([^:]+)$/) { |
$outgoing = $incoming; |
$$coursecodes{$course} = &Apache::lonnet::unescape($1); |
$outgoing =~ s/\#/#/g; |
$totcodes ++; |
$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 $totcodes; |
return $outgoing; |
} |
} |
|
|
1; |
1; |