Support email settings for donors.
This change, which is not properly documented nor tests present, adds support for making sure those who don't want emails from us do not receive them. I believe I've caught most of the places we want this change supported.
This commit is contained in:
parent
7d39d40e61
commit
1a6cb14254
3 changed files with 39 additions and 0 deletions
|
@ -1468,6 +1468,42 @@ sub findDonor($$) {
|
||||||
}
|
}
|
||||||
return(@donorIds);
|
return(@donorIds);
|
||||||
}
|
}
|
||||||
|
######################################################################
|
||||||
|
# FIXME: docs
|
||||||
|
|
||||||
|
sub emailOk($$) {
|
||||||
|
my($self, $donorId) = @_;
|
||||||
|
|
||||||
|
confess "lastGave: donorId, \"$donorId\" not found in supporter database"
|
||||||
|
unless $self->_verifyId($donorId);
|
||||||
|
|
||||||
|
my $contactSetting;
|
||||||
|
|
||||||
|
my $req = $self->getRequest({donorId => $donorId,
|
||||||
|
requestType => 'contact-settings'});
|
||||||
|
$contactSetting =$req->{requestConfiguration}
|
||||||
|
if defined $req and defined $req->{requestConfiguration};
|
||||||
|
return ((not defined $contactSetting) or
|
||||||
|
($contactSetting eq 'no-paper-but-email-ok'));
|
||||||
|
}
|
||||||
|
|
||||||
|
sub paperMailOk($$) {
|
||||||
|
my($self, $donorId) = @_;
|
||||||
|
|
||||||
|
confess "lastGave: donorId, \"$donorId\" not found in supporter database"
|
||||||
|
unless $self->_verifyId($donorId);
|
||||||
|
|
||||||
|
my $contactSetting;
|
||||||
|
|
||||||
|
my $req = $self->getRequest({donorId => $donorId,
|
||||||
|
requestType => 'contact-settings'});
|
||||||
|
$contactSetting =$req->{requestConfiguration}
|
||||||
|
if defined $req and defined $req->{requestConfiguration};
|
||||||
|
return ((not defined $contactSetting) or
|
||||||
|
($contactSetting eq 'no-email-but-paper-ok'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
=begin donorLastGave
|
=begin donorLastGave
|
||||||
|
|
|
@ -120,6 +120,7 @@ foreach my $supporterId (sort @supporterIds) {
|
||||||
|
|
||||||
my $displayName = $sp->getDisplayName($supporterId);
|
my $displayName = $sp->getDisplayName($supporterId);
|
||||||
if ($isPaper) {
|
if ($isPaper) {
|
||||||
|
next unless $sp->paperMailOk($donorId);
|
||||||
my $latexDisplayName = latex_encode($displayName);
|
my $latexDisplayName = latex_encode($displayName);
|
||||||
$latexDisplayName =~ s/\\unmatched\{0141\}/\L{}/g;
|
$latexDisplayName =~ s/\\unmatched\{0141\}/\L{}/g;
|
||||||
$latexDisplayName =~ s/\\unmatched\{0142\}/\l{}/g;
|
$latexDisplayName =~ s/\\unmatched\{0142\}/\l{}/g;
|
||||||
|
@ -158,6 +159,7 @@ foreach my $supporterId (sort @supporterIds) {
|
||||||
close LETTER;
|
close LETTER;
|
||||||
close MESSAGE;
|
close MESSAGE;
|
||||||
} else {
|
} else {
|
||||||
|
next unless $sp->emailOk($donorId);
|
||||||
open(MESSAGE, "<", $EMAIL_TEMPLATE);
|
open(MESSAGE, "<", $EMAIL_TEMPLATE);
|
||||||
my @message;
|
my @message;
|
||||||
while (my $line = <MESSAGE> ) {
|
while (my $line = <MESSAGE> ) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ foreach my $id (sort keys %idsSent) {
|
||||||
$sp->fulfillRequest({ donorId => $id, requestType => $request->{requestType},
|
$sp->fulfillRequest({ donorId => $id, requestType => $request->{requestType},
|
||||||
who => $WHO, how => $HOW});
|
who => $WHO, how => $HOW});
|
||||||
|
|
||||||
|
next unless $sp->emailOk($donorId);
|
||||||
my $emailTo = $sp->getPreferredEmailAddress($id);
|
my $emailTo = $sp->getPreferredEmailAddress($id);
|
||||||
if (not defined $emailTo) {
|
if (not defined $emailTo) {
|
||||||
my(@addr) = $sp->getEmailAddresses($id);
|
my(@addr) = $sp->getEmailAddresses($id);
|
||||||
|
|
Loading…
Reference in a new issue