--- loncom/interface/lonsupportreq.pm 2007/09/05 05:46:19 1.44
+++ loncom/interface/lonsupportreq.pm 2013/11/26 03:17:06 1.74
@@ -1,5 +1,5 @@
#
-# $Id: lonsupportreq.pm,v 1.44 2007/09/05 05:46:19 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.74 2013/11/26 03:17:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,9 +36,10 @@ 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);
+use HTML::Entities;
sub handler {
my ($r) = @_;
@@ -56,8 +57,19 @@ sub handler {
if ($r->uri eq '/adm/helpdesk') {
&Apache::lonacc::get_posted_cgi($r);
}
- my $function = $env{'form.function'};
- my $origurl = &unescape($env{'form.origurl'});
+ 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'};
+ $origurl =~ s{^https?://}{};
+ $origurl =~ s/(`)//g;
+ $origurl =~ s/\$/\(\$\)/g;
my $command = $env{'form.command'};
if ($command eq 'process') {
@@ -70,28 +82,40 @@ 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 ($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'};
- $formname = 'logproblem';
- my $machine = &Apache::lonnet::absolute_url();
- if ($origurl =~ m-^https?://-) {
- $server = $origurl;
+ if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
+ $public = 1;
} else {
- $server = $machine.$origurl;
+ 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'};
}
- my $showserver = $server;
- $showserver =~ s/\?.*$//;
+ $formname = 'logproblem';
+ my $machine = &Apache::lonnet::absolute_url();
+ my $sourceurl = $machine.$origurl;
+ $server = $machine.&Apache::loncommon::cleanup_html($origurl);
+ $server =~ s/\?.*$//;
my %lt = &Apache::lonlocal::texthash (
email => 'The e-mail address you entered',
notv => 'is not a valid e-mail address',
@@ -99,7 +123,8 @@ 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',
entu => 'Enter the username you use to log-in to LON-CAPA',
@@ -152,18 +177,20 @@ END
$sectionlist = $csettings{'internal.sectionnums'};
}
- 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'};
+ 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;
@@ -171,11 +198,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.')';
@@ -197,9 +234,6 @@ function initialize_codes() {
return;
}
|;
- if ($cdom) {
- $codedom = $cdom;
- }
if ($cnum) {
$coursecodes{$cnum} = $ccode;
if ($ccode eq '') {
@@ -229,11 +263,19 @@ 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();",
+ );
$r->print(&Apache::loncommon::start_page('Support Request',$js,
@@ -243,92 +285,120 @@ function initialize_codes() {
if ($r->uri eq '/adm/helpdesk') {
&print_header($r,$origurl);
}
- $r->print('