--- loncom/interface/lonsupportreq.pm 2006/12/22 20:51:27 1.42
+++ loncom/interface/lonsupportreq.pm 2012/02/08 17:49:01 1.66.6.1
@@ -1,5 +1,5 @@
#
-# $Id: lonsupportreq.pm,v 1.42 2006/12/22 20:51:27 albertel Exp $
+# $Id: lonsupportreq.pm,v 1.66.6.1 2012/02/08 17:49:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,11 +32,11 @@ use MIME::Lite;
use CGI::Cookie();
use Apache::Constants qw(:common);
use Apache::loncommon();
+use Apache::lonhtmlcommon;
use Apache::lonnet;
use Apache::lonlocal;
use Apache::lonacc();
-use Apache::courseclassifier;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub handler {
@@ -56,10 +56,10 @@ sub handler {
&Apache::lonacc::get_posted_cgi($r);
}
my $function = $env{'form.function'};
- my $origurl = &unescape($env{'form.origurl'});
- my $action = $env{'form.action'};
+ my $origurl = $env{'form.origurl'};
+ my $command = $env{'form.command'};
- if ($action eq 'process') {
+ if ($command eq 'process') {
&print_request_receipt($r,$origurl,$function);
} else {
&print_request_form($r,$origurl,$function);
@@ -69,22 +69,21 @@ sub handler {
sub print_request_form {
my ($r,$origurl,$function) = @_;
- my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname);
- my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
- if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
- $tablecolor = '#EEEE99';
- }
+ my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$email,
+ $lastname,$firstname,$server,$formname,$public);
+ $function = &Apache::loncommon::get_users_function() if (!$function);
$ccode = '';
$os = $env{'browser.os'};
$browser = $env{'browser.type'};
$bversion = $env{'browser.version'};
$uhost = $env{'request.host'};
- $uname = $env{'user.name'};
- $udom = $env{'user.domain'};
+ if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
+ $public = 1;
+ } else {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ }
$uhome = $env{'user.home'};
- $urole = $env{'request.role'};
- $usec = $env{'request.course.sec'};
- $cid = $env{'request.course.id'};
$formname = 'logproblem';
my $machine = &Apache::lonnet::absolute_url();
if ($origurl =~ m-^https?://-) {
@@ -92,6 +91,8 @@ sub print_request_form {
} 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',
@@ -99,24 +100,20 @@ sub print_request_form {
rdes => 'You must include a description',
name => 'Name',
subm => 'Submit Request',
- emad => 'E-mail address',
+ emad => 'Your e-mail address',
+ emac => 'Cc',
unme => 'username',
doma => 'domain',
- entr => 'Enter the username you use to log-in to your LON-CAPA system, and choose your 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 support request (128 KB max. size)',
+ uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (128 KB max.)',
fini => 'Finish',
clfm => 'Clear Form',
);
@@ -138,42 +135,13 @@ function validate() {
}
END
- $scripttag .= <<'END';
-function validmail(field) {
- var str = field.value;
- if (window.RegExp) {
- var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
- var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
- var reg1 = new RegExp(reg1str);
- var reg2 = new RegExp(reg2str);
- if (!reg1.test(str) && reg2.test(str)) {
- return true;
- }
- return false;
- }
- else
- {
- if(str.indexOf("@") >= 0) {
- return true;
- }
- return false;
- }
-}
-END
+ $scripttag .= &Apache::lonhtmlcommon::javascript_valid_email();
- if ($cid =~ m/_/) {
- ($cdom,$cnum) = split(/_/,$cid);
- }
- 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 ($env{'environment.critnotification'}) {
+ if ($env{'environment.permanentemail'}) {
+ $email = $env{'environment.permanentemail'};
+ } elsif ($env{'environment.critnotification'}) {
$email = $env{'environment.critnotification'};
- }
- if (!$email && $env{'environment.notification'}) {
+ } elsif ($env{'environment.notification'}) {
$email = $env{'environment.notification'};
}
if ($env{'environment.lastname'}) {
@@ -182,508 +150,159 @@ END
if ($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;
- }
- my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'};
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']);
- if (exists($env{'form.codedom'})) {
- $codedom = $env{'form.codedom'};
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',
+ 'useremail','useraccount']);
+ if ($env{'form.origurl'} eq '/adm/createaccount') {
+ if ($email eq '') {
+ if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) {
+ $email = &HTML::Entities::encode($env{'form.useremail'},'"<>&');
+ }
+ }
+ if ($uname eq '') {
+ if ($env{'form.useraccount'} =~ /^$match_username$/) {
+ $uname = &HTML::Entities::encode($env{'form.useraccount'},'"<>&');
+ }
+ }
}
- my $details_title;
- if ($codedom) {
- $details_title = '
('.$codedom.')';
- }
- my %coursecodes;
- my %codes;
- my @codetitles;
- my %cat_titles;
- my %cat_order;
- my %idlist;
- my %idnums;
- my %idlist_titles;
+ my $codedom = &get_domain();
my $caller = 'global';
- my $totcodes = 0;
my $format_reply;
my $jscript = '';
- my $loaditems = qq|
-function initialize_codes() {
- return;
-}
- |;
- if ($cdom) {
- $codedom = $cdom;
- }
- 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 = '';
+ my $js = '';
my %add_entries = (topmargin => "0",
marginheight => "0",
- onLoad =>"initialize_codes()",);
-
- my $start_page =
- &Apache::loncommon::start_page('Support Request',$js,
+ );
+
+ $r->print(&Apache::loncommon::start_page('Support Request',$js,
{ 'function' => $function,
'add_entries' => \%add_entries,
- 'only_body' => 1,});
- $r->print($start_page);
-
+ 'only_body' => 1,}));
if ($r->uri eq '/adm/helpdesk') {
&print_header($r,$origurl);
}
- $r->print(<<"END");
-