--- loncom/interface/lonsupportreq.pm 2010/02/13 00:09:20 1.55.4.2 +++ loncom/interface/lonsupportreq.pm 2011/03/03 00:33:38 1.65 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.55.4.2 2010/02/13 00:09:20 raeburn Exp $ +# $Id: lonsupportreq.pm,v 1.65 2011/03/03 00:33:38 raeburn 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,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 ($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'}; - $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'}; @@ -172,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) { @@ -225,7 +244,7 @@ function initialize_codes() { } my $js = ''; + $loaditems.''; my %add_entries = (topmargin => "0", marginheight => "0", onLoad =>"initialize_codes()",); @@ -266,7 +285,7 @@ function initialize_codes() { &Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; - if (defined($env{'user.name'})) { + if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]). '
'."\n". &Apache::lonhtmlcommon::row_closure(); @@ -278,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; } @@ -335,12 +357,13 @@ function initialize_codes() { $output .= $lt{'enin'}.':  '; } else { + my @standardnames = &Apache::loncommon::get_standard_codeitems(); my $lasttitle = $numtitles; if ($numtitles > 4) { $lasttitle = 4; } $output .= ''; for (my $i=1; $i<$numtitles; $i++) { $output .= ''."\n"; @@ -377,7 +400,7 @@ function initialize_codes() { $output .= '
'.$codetitles[0].'
'."\n". - ''."\n". '
'.$codetitles[$i].'
'."\n". - ''."\n". ''."\n". ''."\n". '
'; if ($numtitles > 4) { $output .= '

'.$codetitles[$numtitles].'
'."\n". - ''."\n". ''."\n". ''."\n"; } @@ -428,7 +451,7 @@ function initialize_codes() { &Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; - if (defined($env{'user.name'})) { + if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]). '
'.$lt{'uplf'}."\n". &Apache::lonhtmlcommon::row_closure(); @@ -474,23 +497,53 @@ sub print_request_receipt { my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', $defdom,$origmail); my $from = $admin; + my $bcc; + my %domconfig = + &Apache::lonnet::get_dom('configuration',['contacts'],$defdom); + if (ref($domconfig{'contacts'}) eq 'HASH') { + if (exists($domconfig{'contacts'}{'helpdeskmail'})) { + if (ref($domconfig{'contacts'}{'helpdeskmail'}) eq 'HASH') { + my $bccmail = $domconfig{'contacts'}{'helpdeskmail'}{'bcc'}; + if ($bccmail ne '') { + my @bccs = split(/,/,$bccmail); + my @ok_bccs; + foreach my $bcc (@bccs) { + $bcc =~ s/^\s+//g; + $bcc =~ s/\s+$//g; + if ($bcc =~ m/^[^\@]+\@[^\@]+$/) { + if (!(grep(/^\Q$bcc\E$/,@ok_bccs))) { + push(@ok_bccs,$bcc); + } + } + } + if (@ok_bccs > 0) { + $bcc = join(', ',@ok_bccs); + } + } + } + } + } my $reporttime = &Apache::lonlocal::locallocaltime(time); my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot'); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); my $coursecode = $env{'form.coursecode'}; if ($coursecode eq '') { - if (defined($env{'form.Year'})) { - $coursecode .= $env{'form.Year'}; - } - if (defined($env{'form.Semester'})) { - $coursecode .= $env{'form.Semester'}; - } - if (defined($env{'form.Department'})) { - $coursecode .= $env{'form.Department'}; - } - if (defined($env{'form.Number'})) { - $coursecode .= $env{'form.Number'}; + my $totcodes = 0; + my %coursecodes; + $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom,$totcodes); + my @standardnames = &Apache::loncommon::get_standard_codeitems(); + if ($totcodes > 0) { + my $noregexps = 1; + $coursecode = + &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps); + } + if ($coursecode eq '') { + foreach my $item (@standardnames) { + if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) { + $coursecode .= $env{'form.'.$item}; + } + } } } my %lt = &Apache::lonlocal::texthash ( @@ -530,7 +583,7 @@ sub print_request_receipt { if (!(grep(/^\Q$cc\E$/,@ok_ccs))) { push(@ok_ccs,$cc); } - } else { + } elsif ($cc ne '') { if (!(grep(/^\Q$cc\E$/,@bad_ccs))) { push(@bad_ccs,$cc); } @@ -547,14 +600,14 @@ sub print_request_receipt { } } $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'"; - $env{'form.csri'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'}; + $env{'form.crsi'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'}; my $supportmsg = < 131072) { @@ -717,6 +771,11 @@ END my $cc_string = join(', ',@ok_ccs); $msg->add("Cc" => $cc_string); } + if ($bcc ne '') { + $msg->add("Bcc" => $bcc); + } + $msg->attr("content-type" => "text/plain"); + $msg->attr("content-type.charset" => "UTF-8"); if ($attachmentpath) { my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); @@ -804,13 +863,16 @@ 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(<  
-    - LON-CAPA $lt{'headline'} + + LON-CAPA $lt{'headline'}