--- loncom/interface/lonsupportreq.pm 2006/12/12 16:04:40 1.40
+++ loncom/interface/lonsupportreq.pm 2012/08/27 06:28:06 1.69
@@ -1,5 +1,5 @@
#
-# $Id: lonsupportreq.pm,v 1.40 2006/12/12 16:04:40 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.69 2012/08/27 06:28:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,17 +27,18 @@
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 Apache::lonauth();
use Apache::courseclassifier;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub handler {
@@ -48,15 +49,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 $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);
@@ -66,22 +71,35 @@ 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,$urole,$usec,$email,$cid,
+ $cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,
+ $formname,$public,$homeserver);
+ $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'};
- $uhome = $env{'user.home'};
- $urole = $env{'request.role'};
- $usec = $env{'request.course.sec'};
- $cid = $env{'request.course.id'};
+ if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
+ $public = 1;
+ } else {
+ if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
+ $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
+ $env{'user.domain'});
+ if ($homeserver eq 'no_host') {
+ undef($homeserver);
+ } else {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ }
+ }
+ }
+ if ($homeserver) {
+ $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?://-) {
@@ -89,6 +107,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',
@@ -96,10 +116,13 @@ 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',
@@ -113,7 +136,7 @@ sub print_request_form {
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',
);
@@ -135,31 +158,10 @@ 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
-
- 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);
@@ -167,17 +169,21 @@ END
$ccode = $csettings{'internal.coursecode'};
$sectionlist = $csettings{'internal.sectionnums'};
}
- if ($env{'environment.critnotification'}) {
- $email = $env{'environment.critnotification'};
- }
- if (!$email && $env{'environment.notification'}) {
- $email = $env{'environment.notification'};
- }
- if ($env{'environment.lastname'}) {
- $lastname = $env{'environment.lastname'};
- }
- if ($env{'environment.firstname'}) {
- $firstname = $env{'environment.firstname'};
+
+ if ($homeserver) {
+ if ($env{'environment.permanentemail'}) {
+ $email = $env{'environment.permanentemail'};
+ } elsif ($env{'environment.critnotification'}) {
+ $email = $env{'environment.critnotification'};
+ } elsif ($env{'environment.notification'}) {
+ $email = $env{'environment.notification'};
+ }
+ if ($env{'environment.lastname'}) {
+ $lastname = $env{'environment.lastname'};
+ }
+ if ($env{'environment.firstname'}) {
+ $firstname = $env{'environment.firstname'};
+ }
}
my @sections = split(/,/,$sectionlist);
my %groupid;
@@ -185,11 +191,21 @@ END
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 $codedom = &get_domain();
my $details_title;
if ($codedom) {
$details_title = '
('.$codedom.')';
@@ -211,9 +227,6 @@ function initialize_codes() {
return;
}
|;
- if ($cdom) {
- $codedom = $cdom;
- }
if ($cnum) {
$coursecodes{$cnum} = $ccode;
if ($ccode eq '') {
@@ -243,228 +256,142 @@ function initialize_codes() {
}
}
- my $js = '';
- my %add_entries = (topmargin => "0",
- marginheight => "0",
- onLoad =>"initialize_codes()",);
+ my $js = <<"ENDJS";
+
+ENDJS
+ my %add_entries = (
+ style => "margin-top:0px;margin-bottom:0px;",
+ 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");
-