[LON-CAPA-cvs] cvs: loncom /build CHECKRPMS /interface loncommon.pm lonerrorhandler.pm lonsupportreq.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 04 Dec 2007 04:43:25 -0000
This is a MIME encoded message
--raeburn1196743405
Content-Type: text/plain
raeburn Mon Dec 3 23:43:25 2007 EDT
Modified files:
/loncom/interface loncommon.pm lonsupportreq.pm lonerrorhandler.pm
/loncom/build CHECKRPMS
Log:
- Make loncommon::build_recipient_list() more generally applicable.
- Eliminate duplicate addresses in recipient list
- Use loncommon::build_recipient_list() to provide recipient email list for
help support form and package update alerts.
--raeburn1196743405
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20071203234325.txt"
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.618 loncom/interface/loncommon.pm:1.619
--- loncom/interface/loncommon.pm:1.618 Mon Dec 3 17:58:46 2007
+++ loncom/interface/loncommon.pm Mon Dec 3 23:43:21 2007
@@ -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 @@
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 @@
############################################################
############################################################
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 @@
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;
}
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.44 loncom/interface/lonsupportreq.pm:1.45
--- loncom/interface/lonsupportreq.pm:1.44 Wed Sep 5 01:46:19 2007
+++ loncom/interface/lonsupportreq.pm Mon Dec 3 23:43:21 2007
@@ -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 @@
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 = '<br />('.$codedom.')';
@@ -197,9 +194,6 @@
return;
}
|;
- if ($cdom) {
- $codedom = $cdom;
- }
if ($cnum) {
$coursecodes{$cnum} = $ccode;
if ($ccode eq '') {
@@ -450,7 +444,10 @@
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 @@
if ($r->uri eq '/adm/helpdesk') {
&print_header($r,$url,'process');
}
- if ($to =~ m/^[^\@]+\@[^\@]+$/) {
- $r->print('<h3>'.$lt{'asup'}.' '.$to.'</h3>');
- } else {
- $to = $admin;
- if ($to =~ m/^[^\@]+\@[^\@]+$/) {
- $r->print('<h3>'.$lt{'asup'}.' '.$to.'</h3>');
+ 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('
<h3>'.$lt{'warn'}.'</h3>'.
&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 <b>not</b> 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('<h3>'.$lt{'asup'}.' '.$to.'</h3>');
}
if (defined($env{'form.email'})) {
if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
@@ -730,4 +744,18 @@
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;
Index: loncom/interface/lonerrorhandler.pm
diff -u loncom/interface/lonerrorhandler.pm:1.13 loncom/interface/lonerrorhandler.pm:1.14
--- loncom/interface/lonerrorhandler.pm:1.13 Mon Dec 3 17:58:46 2007
+++ loncom/interface/lonerrorhandler.pm Mon Dec 3 23:43:21 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Internal Server Error Handler
#
-# $Id: lonerrorhandler.pm,v 1.13 2007/12/03 22:58:46 raeburn Exp $
+# $Id: lonerrorhandler.pm,v 1.14 2007/12/04 04:43:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -81,8 +81,9 @@
ENDMESSAGE
my $sysmail = $r->dir_config('lonSysEMail');
my $defdom = $r->dir_config('lonDefDomain');
- my $recipients = &Apache::loncommon::build_recipient_list($r,$sysmail,
- 'errormail',$defdom);
+ my $origmail = $r->dir_config('lonAdmEMail');
+ my $recipients = &Apache::loncommon::build_recipient_list($sysmail,
+ 'errormail',$defdom,$origmail);
if ($recipients ne '') {
&Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
$r->print('<h2>'.&mt('Report submitted').'</h2>'.&mt('Thank you!'));
Index: loncom/build/CHECKRPMS
diff -u loncom/build/CHECKRPMS:1.9 loncom/build/CHECKRPMS:1.10
--- loncom/build/CHECKRPMS:1.9 Thu Sep 13 17:50:37 2007
+++ loncom/build/CHECKRPMS Mon Dec 3 23:43:24 2007
@@ -55,12 +55,16 @@
use strict;
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
+use Apache::loncommon();
my $tmpfile = '/tmp/CHECKRPMS.'.$$;
my $perlvar= LONCAPA::Configuration::read_conf('loncapa.conf');
# Determine who we email
-my $emailto = "$perlvar->{'lonAdmEMail'}";
+my $defdom = $perlvar->{'lonDefDomain'};
+my $origmail = $perlvar->{'lonAdmEMail'};
+my $emailto = &Apache::loncommon::build_recipient_list(undef,
+ 'packagesmail',$defdom,$origmail);
my $subj = $perlvar->{'lonHostID'};
# Get Linux distro
@@ -125,7 +129,7 @@
}
if ($send) {
$subj .= $addsubj;
- system(qq{mail -s '$subj' $emailto < $tmpfile});
+ system(qq{mail -s '$subj' "$emailto" < $tmpfile});
}
sub prepare_msg {
--raeburn1196743405--