--- loncom/interface/lonsupportreq.pm 2009/01/27 15:59:30 1.52 +++ loncom/interface/lonsupportreq.pm 2010/04/14 07:31:21 1.55.4.3 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.52 2009/01/27 15:59:30 schafran Exp $ +# $Id: lonsupportreq.pm,v 1.55.4.3 2010/04/14 07:31:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -77,8 +77,11 @@ sub print_request_form { $browser = $env{'browser.type'}; $bversion = $env{'browser.version'}; $uhost = $env{'request.host'}; - $uname = $env{'user.name'}; - $udom = $env{'user.domain'}; + my ($uname,$udom); + if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) { + $uname = $env{'user.name'}; + $udom = $env{'user.domain'}; + } $uhome = $env{'user.home'}; $urole = $env{'request.role'}; $usec = $env{'request.course.sec'}; @@ -266,7 +269,7 @@ function initialize_codes() { &Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; - if (defined($env{'user.name'})) { + if (defined($uname)) { $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]). '
'."\n". &Apache::lonhtmlcommon::row_closure(); @@ -428,7 +431,7 @@ function initialize_codes() { &Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; - if (defined($env{'user.name'})) { + if (defined($uname)) { $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]). '
'.$lt{'uplf'}."\n". &Apache::lonhtmlcommon::row_closure(); @@ -474,6 +477,32 @@ 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'); @@ -566,13 +595,15 @@ END if ($env{'form.'.$item} ne '') { if ($item eq 'description') { my $descrip = $env{'form.description'}; - $descrip =~ s|\n|
|g; + $descrip = &cleanup_html($descrip); + $descrip =~ s|[\n\r\f]|
|g; $displaymsg .= ''. "$lt{$item}: $descrip
\n"; } elsif ($item eq 'sourceurl') { my $showurl = $env{'form.sourceurl'}; $showurl =~ s/\?.*$//; + $showurl = &cleanup_html($showurl); $displaymsg .= ''. "$lt{$item}: $showurl
\n"; @@ -581,9 +612,11 @@ END ''. "$lt{$item}: $okcclist
\n"; } else { + my $showitem = $env{'form.'.$item}; + $showitem = &cleanup_html($showitem); $displaymsg .= ''. - "$lt{$item}: $env{'form.'.$item}
\n"; + "$lt{$item}: $showitem
\n"; } } } @@ -665,7 +698,8 @@ END my $attachmentpath = ''; my $attachmentsize = ''; - if (defined($env{'user.name'})) { + if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public') + && ($env{'user.domain'} ne 'public')) { if ($env{'form.screenshot.filename'}) { $attachmentsize = length($env{'form.screenshot'}); if ($attachmentsize > 131072) { @@ -713,6 +747,9 @@ END my $cc_string = join(', ',@ok_ccs); $msg->add("Cc" => $cc_string); } + if ($bcc ne '') { + $msg->add("Bcc" => $bcc); + } if ($attachmentpath) { my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); @@ -746,7 +783,8 @@ END unlink($attachmentpath); } $r->print(''.$lt{'your'}.':

'."\n"); - $r->print(&Apache::lonhtmlcommon::start_pick_box('LC_helpform_receipt'). + $r->print('
'. + &Apache::lonhtmlcommon::start_pick_box(). &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n". &Apache::lonhtmlcommon::row_closure(). &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value')); @@ -772,7 +810,8 @@ END $envmsg =~ s/, $//; $r->print($envmsg."\n". &Apache::lonhtmlcommon::row_closure(1)."\n". - &Apache::lonhtmlcommon::end_pick_box()."\n". + &Apache::lonhtmlcommon::end_pick_box(). + "
\n". &Apache::loncommon::end_page()); } @@ -801,7 +840,11 @@ sub print_header { $r->print(<   -
  LON-CAPA $lt{'headline'} +
+ +    + LON-CAPA $lt{'headline'} + @@ -842,9 +885,27 @@ sub get_domain { } elsif ($env{'request.role.domain'}) { $codedom = $env{'request.role.domain'}; } else { - $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; + $codedom = &Apache::lonnet::default_login_domain(); } return $codedom; } +sub cleanup_html { + my ($incoming) = @_; + my $outgoing; + if ($incoming ne '') { + $outgoing = $incoming; + $outgoing =~ s/\#/#/g; + $outgoing =~ s/\&/&/g; + $outgoing =~ s//>/g; + $outgoing =~ s/\(/(/g; + $outgoing =~ s/\)/)/g; + $outgoing =~ s/"/"/g; + $outgoing =~ s/'/'/g; + $outgoing =~ s/\$/$/g; + } + return $outgoing; +} + 1;