From 1c6441e13515d29fb5a04bff8ff2f0418a211f82 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 30 Dec 2015 17:54:37 -0800 Subject: [PATCH] setPublicAck: Implementation ok 48 - setPublicAck: fails supporterId invalid ok 49 - setPublicAck: fails supporterId is string ok 50 - setPublicAck: fails supporterId is undef ok 51 - setPublicAck: 1 failed calls changed nothing. ok 52 - setPublicAck: 1 failed calls changed nothing. ok 53 - setPublicAck: 1 failed calls changed nothing. ok 54 - setPublicAck: lives when valid id is given for undefining... ok 55 - setPublicAck: ...and suceeds in changing value. ok 56 - setPublicAck: lives when valid id is given for off... ok 57 - setPublicAck: ...and suceeds in changing value. ok 58 - setPublicAck: lives when valid id is given for on... ok 59 - setPublicAck: ...and suceeds in changing value. --- Supporters/lib/Supporters.pm | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 9ef9131..6555c78 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -491,6 +491,44 @@ sub getDisplayName($$$) { return $_[0]->_getDonorField("display_name", $_[1]); } ###################################################################### +sub _setDonorField($$$) { + my($self, $field, $donorId, $value, $type) = @_; + + die "set$field: invalid supporter id, $donorId" unless $self->_verifyId($donorId); + + $self->_beginWork(); + $self->dbh->do("UPDATE donor " . + "SET $field = " . $self->dbh->quote($value, $type) . " " . + "WHERE id = " . $self->dbh->quote($donorId, 'SQL_INTEGER')); + $self->_commit; + return $value; +} +###################################################################### + +=begin setPublicAck + +Arguments: + +=over + +=item $donorId + + Valid donor id number currently in the database. die() will occur if + the id number is not in the database already as a donor id. + +=item $publicAck + + Can be true, false, or undef and will update public acknowledgement bit + accordingly for donor identified with C<$donorId>. + +=back + +=cut + +sub setPublicAck($$$) { + return $_[0]->_setDonorField('public_ack', $_[1], $_[2], 'SQL_BOOLEAN'); +} +###################################################################### =begin addPostalAddress