--- loncom/interface/loncommon.pm 2007/12/03 22:58:46 1.618 +++ loncom/interface/loncommon.pm 2007/12/04 04:43:21 1.619 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.618 2007/12/03 22:58:46 raeburn Exp $ +# $Id: loncommon.pm,v 1.619 2007/12/04 04:43:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -7649,12 +7649,14 @@ sub restore_settings { Build recipient lists for three types of e-mail: (a) Error Reports, (b) Package Updates, (c) Help requests, generated by -lonerrorhandler.pm, CHECKRPMS and lonhelpdesk.pm respectively. +lonerrorhandler.pm, CHECKRPMS and lonsupportreq.pm respectively. Inputs: -Request object, defmail (scalar - email address of default recipient), +defmail (scalar - email address of default recipient), mailing type (scalar - errormail, packagesmail, or helpdeskmail), -defdom (domain for which to retrieve configuration settings). +defdom (domain for which to retrieve configuration settings), +origmail (scalar - email address of recipient from loncapa.conf, +i.e., predates configuration by DC via domainprefs.pm Returns: comma separated list of addresses to which to send e-mail. @@ -7663,10 +7665,9 @@ Returns: comma separated list of address ############################################################ ############################################################ sub build_recipient_list { - my ($r,$defmail,$mailing,$defdom) = @_; + my ($defmail,$mailing,$defdom,$origmail) = @_; my @recipients; my $otheremails; - my $defdom = $r->dir_config('lonDefDomain'); my %domconfig = &Apache::lonnet::get_dom('configuration',['contacts'],$defdom); if (ref($domconfig{'contacts'}) eq 'HASH') { @@ -7674,25 +7675,34 @@ sub build_recipient_list { my @contacts = ('adminemail','supportemail'); foreach my $item (@contacts) { if ($domconfig{'contacts'}{$mailing}{$item}) { - push(@recipients,$domconfig{'contacts'}{$item}); + my $addr = $domconfig{'contacts'}{$item}; + if (!grep(/^\Q$addr\E$/,@recipients)) { + push(@recipients,$addr); + } } $otheremails = $domconfig{'contacts'}{$mailing}{'others'}; } - } else { - push(@recipients,$r->dir_config('lonAdmEMail')); } + } elsif ($origmail ne '') { + push(@recipients,$origmail); } if ($defmail ne '') { push(@recipients,$defmail); } - my $recipientlist = join(',',@recipients); if ($otheremails) { - if ($recipientlist ne '') { - $recipientlist .= ','.$otheremails; + my @others; + if ($otheremails =~ /,/) { + @others = split(/,/,$otheremails); } else { - $recipientlist = $otheremails; + push(@others,$otheremails); + } + foreach my $addr (@others) { + if (!grep(/^\Q$addr\E$/,@recipients)) { + push(@recipients,$addr); + } } } + my $recipientlist = join(',',@recipients); return $recipientlist; }