--- loncom/interface/lonsupportreq.pm 2006/07/11 15:37:59 1.36
+++ loncom/interface/lonsupportreq.pm 2010/02/13 00:04:57 1.55.4.1
@@ -1,5 +1,5 @@
#
-# $Id: lonsupportreq.pm,v 1.36 2006/07/11 15:37:59 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.55.4.1 2010/02/13 00:04:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,16 +27,16 @@
package Apache::lonsupportreq;
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::loncommon();
+use Apache::lonhtmlcommon;
use Apache::lonnet;
use Apache::lonlocal;
use Apache::lonacc();
-use lib '/home/httpd/lib/perl/';
+use Apache::courseclassifier;
use LONCAPA;
@@ -48,15 +48,19 @@ sub handler {
if ($r->header_only) {
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 $action = $env{'form.action'};
+ 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);
@@ -67,10 +71,7 @@ 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';
- }
+ $function = &Apache::loncommon::get_users_function() if (!$function);
$ccode = '';
$os = $env{'browser.os'};
$browser = $env{'browser.type'};
@@ -83,44 +84,67 @@ sub print_request_form {
$usec = $env{'request.course.sec'};
$cid = $env{'request.course.id'};
$formname = 'logproblem';
- if ($origurl =~ m-^http://-) {
+ my $machine = &Apache::lonnet::absolute_url();
+ if ($origurl =~ m-^https?://-) {
$server = $origurl;
} else {
- $server = 'http://'.$ENV{'SERVER_NAME'}.$origurl;
+ $server = $machine.$origurl;
}
- my $scripttag = (<<'END');
+ 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("The e-mail address you entered: "+document.logproblem.email.value+" is not a valid e-mail address.");
+ 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();
}
-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
-
- if ($cid =~ m/_/) {
- ($cdom,$cnum) = split/_/,$cid;
+ $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);
@@ -128,10 +152,12 @@ END
$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'}) {
@@ -140,29 +166,26 @@ END
if ($env{'environment.firstname'}) {
$firstname = $env{'environment.firstname'};
}
- my @sections = split/,/,$sectionlist;
- my %groupid = ();
- foreach (@sections) {
- my ($sec,$grp) = split/:/,$_;
+ 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'};
- }
+ my $codedom = &get_domain();
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 %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;
@@ -172,265 +195,163 @@ function initialize_codes() {
return;
}
|;
- if ($cdom) {
- $codedom = $cdom;
- }
if ($cnum) {
$coursecodes{$cnum} = $ccode;
if ($ccode eq '') {
- $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
+ $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
} else {
$coursecodes{$cnum} = $ccode;
$caller = $cnum;
$totcodes ++;
}
} else {
- $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
+ $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;
- &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
- &javascript_code_selections($formname,$numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@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 %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");
-