--- loncom/interface/lonsupportreq.pm 2009/10/22 13:41:41 1.55 +++ loncom/interface/lonsupportreq.pm 2010/11/10 14:44:50 1.58 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.55 2009/10/22 13:41:41 bisitz Exp $ +# $Id: lonsupportreq.pm,v 1.58 2010/11/10 14:44:50 bisitz 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(); @@ -335,12 +338,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 +381,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 +432,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,23 +478,52 @@ 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 $coursecode; + my @standardnames = &Apache::loncommon::get_standard_codeitems(); + if ($totcodes > 0) { + $coursecode = &Apache::courseclassifier::instcode_from_selectors($defdom); + } + 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 +563,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 +580,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 +751,10 @@ END my $cc_string = join(', ',@ok_ccs); $msg->add("Cc" => $cc_string); } + if ($bcc ne '') { + $msg->add("Bcc" => $bcc); + } + $msg->add('Content-type','text/plain; charset=UTF-8'); if ($attachmentpath) { my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);