--- loncom/interface/lonsupportreq.pm 2010/11/10 14:44:50 1.58 +++ loncom/interface/lonsupportreq.pm 2011/03/03 17:29:29 1.66 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.58 2010/11/10 14:44:50 bisitz Exp $ +# $Id: lonsupportreq.pm,v 1.66 2011/03/03 17:29:29 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,7 @@ use Apache::lonnet; use Apache::lonlocal; use Apache::lonacc(); use Apache::courseclassifier; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); sub handler { @@ -57,7 +57,7 @@ sub handler { &Apache::lonacc::get_posted_cgi($r); } my $function = $env{'form.function'}; - my $origurl = &unescape($env{'form.origurl'}); + my $origurl = $env{'form.origurl'}; my $command = $env{'form.command'}; if ($command eq 'process') { @@ -70,15 +70,18 @@ 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); $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'}; - my ($uname,$udom); - if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) { + if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) { + $public = 1; + } else { $uname = $env{'user.name'}; $udom = $env{'user.domain'}; } @@ -175,7 +178,20 @@ END my ($sec,$grp) = split(/:/,$section); $groupid{$sec} = $grp; } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['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) { @@ -228,7 +244,7 @@ function initialize_codes() { } my $js = ''; + $loaditems.''; my %add_entries = (topmargin => "0", marginheight => "0", onLoad =>"initialize_codes()",); @@ -269,7 +285,7 @@ function initialize_codes() { &Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; - if (defined($uname)) { + if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]). '
'."\n". &Apache::lonhtmlcommon::row_closure(); @@ -281,30 +297,33 @@ function initialize_codes() { &HTML::Entities::encode($udom,'"<>&').'" />'; my $uname_input = '&').'" />'; - if (defined($uname) && defined($udom)) { + if (($env{'user.name'} =~ /^$match_username$/) && + ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) { $output .= ''.$lt{'unme'}.': '.$uname.'  '.$lt{'doma'}.': '.$udom.$udom_input.$uname_input; } else { my $udomform = ''; my $unameform = ''; - if (defined($udom)) { + if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) { $output .= $lt{'entu'}; - } elsif (defined($uname)) { + } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { $output .= $lt{'chdo'}; } else { $output .= $lt{'entr'}; } $output .= '
'; - if (defined($udom)) { - $udomform = ''.$lt{'doma'}.': '.$udom.$udom_input; - } elsif (defined($uname)) { - $unameform = ''.$lt{'unme'}.': '.$uname.'  '.$uname_input; + if (!$public) { + if ($env{'user.domain'} =~ /^$match_domain$/) { + $udomform = ''.$lt{'doma'}.': '.$udom.$udom_input; + } elsif ($env{'user.name'} =~ /^$match_username$/) { + $unameform = ''.$lt{'unme'}.': '.$uname.'  '.$uname_input; + } } if ($udomform eq '') { $udomform = ''.$lt{'doma'}.': '; $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom'); } if ($unameform eq '') { - $unameform= ''.$lt{'unme'}.'  '; + $unameform= ''.$lt{'unme'}.'  '; } $output .= $unameform.$udomform; } @@ -432,7 +451,7 @@ function initialize_codes() { &Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; - if (defined($uname)) { + if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]). '
'.$lt{'uplf'}."\n". &Apache::lonhtmlcommon::row_closure(); @@ -513,10 +532,11 @@ sub print_request_receipt { my $totcodes = 0; my %coursecodes; $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom,$totcodes); - my $coursecode; my @standardnames = &Apache::loncommon::get_standard_codeitems(); if ($totcodes > 0) { - $coursecode = &Apache::courseclassifier::instcode_from_selectors($defdom); + my $noregexps = 1; + $coursecode = + &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps); } if ($coursecode eq '') { foreach my $item (@standardnames) { @@ -538,7 +558,6 @@ sub print_request_receipt { 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', @@ -669,14 +688,20 @@ END $bad_email = 1; } } - if ($bad_email) { - $r->print(' -

'.$lt{'warn'}.'

'. -&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 not 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'; + + my $message; + if (!$bad_email) { + $message = &Apache::lonhtmlcommon::confirm_success( + &mt('A support request has been sent to [_1]',''.$to.'')); } else { - $r->print('

'.$lt{'asup'}.' '.$to.'

'); + $message = &Apache::lonhtmlcommon::confirm_success( + $lt{'warn'}.'
' + .&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 [_2]not[_3] 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.'),1); + $to = 'helpdesk@lon-capa.org'; } + $r->print(&Apache::loncommon::confirmwrapper($message)); + if (defined($env{'form.email'})) { $env{'form.email'} =~ s/^\s+//; $env{'form.email'} =~ s/\s+$//; @@ -724,7 +749,7 @@ END $fname = $1; $displaymsg .= '
' .&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].' - ,''.$fname.'' + ,''.$fname.'' ,$attachmentsize ,$env{'user.name'}.':'.$env{'user.domain'} ); @@ -754,7 +779,8 @@ END if ($bcc ne '') { $msg->add("Bcc" => $bcc); } - $msg->add('Content-type','text/plain; charset=UTF-8'); + $msg->attr("content-type" => "text/plain"); + $msg->attr("content-type.charset" => "UTF-8"); if ($attachmentpath) { my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); @@ -842,6 +868,9 @@ sub print_header { } else { $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.'); } + if ($origurl eq '') { + $origurl = 'javascript:history.go(-1)'; + } $r->print(<