--- loncom/interface/lonsupportreq.pm 2007/09/05 05:46:19 1.44 +++ loncom/interface/lonsupportreq.pm 2007/12/04 04:43:21 1.45 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.44 2007/09/05 05:46:19 raeburn Exp $ +# $Id: lonsupportreq.pm,v 1.45 2007/12/04 04:43:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -171,11 +171,8 @@ 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'}; - } + my $codedom = &get_domain(); my $details_title; if ($codedom) { $details_title = '
('.$codedom.')'; @@ -197,9 +194,6 @@ function initialize_codes() { return; } |; - if ($cdom) { - $codedom = $cdom; - } if ($cnum) { $coursecodes{$cnum} = $ccode; if ($ccode eq '') { @@ -450,7 +444,10 @@ sub print_request_receipt { my @cookievars = ('lonID'); my $admin = $Apache::lonnet::perlvar{'lonAdminMail'}; - my $to = $Apache::lonnet::perlvar{'lonSupportEMail'}; + my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; + my $defdom = &get_domain(); + my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', + $defdom,$origmail); my $from = $admin; my $reporttime = &Apache::lonlocal::locallocaltime(time); my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot'); @@ -547,18 +544,35 @@ END if ($r->uri eq '/adm/helpdesk') { &print_header($r,$url,'process'); } - if ($to =~ m/^[^\@]+\@[^\@]+$/) { - $r->print('

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

'); - } else { - $to = $admin; - if ($to =~ m/^[^\@]+\@[^\@]+$/) { - $r->print('

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

'); + my $bad_email = 0; + if ($to =~ /,/) { + my @ok_email; + foreach my $email (split(/,/,$to)) { + if ($email =~ m/^[^\@]+\@[^\@]+$/) { + push(@ok_email,$email); + } + } + if (@ok_email > 0) { + $to = join(',',@ok_email); + } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) { + $to = $admin; } else { - $r->print(' + $bad_email = 1; + } + } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) { + if ($admin =~ m/^[^\@]+\@[^\@]+$/) { + $to = $admin; + } else { + $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'; - } + } else { + $r->print('

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

'); } if (defined($env{'form.email'})) { if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) { @@ -730,4 +744,18 @@ Please review the information in "Log-in return; } +sub get_domain { + my $codedom; + if (exists($env{'form.codedom'})) { + $codedom = $env{'form.codedom'}; + } elsif ($env{'request.course.id'}) { + $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + } elsif ($env{'request.role.domain'}) { + $codedom = $env{'request.role.domain'}; + } else { + $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; + } + return $codedom; +} + 1;