Allow search by Supporter only.

This commit is contained in:
Bradley M. Kuhn 2022-06-21 10:08:25 -07:00
parent 36c1d11d1f
commit aece96946d

View file

@ -1633,19 +1633,20 @@ sub findDonor($$) {
return keys %$rr; return keys %$rr;
} }
my @donorIds; my(@donorIds, $sql);
if (not defined $params->{emailAddress}) { if (not defined $params->{emailAddress}) {
my $ledgerEntityId = $params->{ledgerEntityId}; my $ledgerEntityId = $params->{ledgerEntityId};
# Simple case: just lookup without a join. # Simple case: just lookup without a join.
my $val = $self->dbh()->selectall_hashref("SELECT id, ledger_entity_id from donor where ledger_entity_id = " . $sql = "SELECT id, ledger_entity_id from donor where ledger_entity_id = " .
$self->dbh->quote($ledgerEntityId), $self->dbh->quote($ledgerEntityId);
"ledger_entity_id"); $sql .= " AND is_supporter" if defined $params->{isSupporter} and $params->{isSupporter};
my $val = $self->dbh()->selectall_hashref($sql, "ledger_entity_id");
# As Connor MacLeod said, "There can be only one!" # As Connor MacLeod said, "There can be only one!"
# (because of "ledger_entity_id" varchar(300) NOT NULL UNIQUE,) # (because of "ledger_entity_id" varchar(300) NOT NULL UNIQUE,)
push(@donorIds, $val->{$ledgerEntityId}{id}) push(@donorIds, $val->{$ledgerEntityId}{id})
if (defined $val and defined $val->{$ledgerEntityId} and defined $val->{$ledgerEntityId}{id}); if (defined $val and defined $val->{$ledgerEntityId} and defined $val->{$ledgerEntityId}{id});
} else { } else {
my $sql = "SELECT d.id from donor d, email_address ea, donor_email_address_mapping eam " . $sql = "SELECT d.id from donor d, email_address ea, donor_email_address_mapping eam " .
"WHERE eam.email_address_id = ea.id AND d.id = eam.donor_id AND " . "WHERE eam.email_address_id = ea.id AND d.id = eam.donor_id AND " .
"ea.email_address = " . $self->dbh->quote($params->{emailAddress}); "ea.email_address = " . $self->dbh->quote($params->{emailAddress});