mirror of
https://github.com/standardebooks/web.git
synced 2025-07-05 22:30:30 -04:00
Use exists() for some SQL statements; send thank-you email to patron donors who donate again
This commit is contained in:
parent
a4910b8d67
commit
a442f92e28
3 changed files with 41 additions and 19 deletions
|
@ -74,9 +74,11 @@ try{
|
|||
$log->Write('Processing donation ' . $pendingPayment->TransactionId . ' ...');
|
||||
|
||||
if(Db::QueryInt('
|
||||
SELECT count(*)
|
||||
from Payments
|
||||
where TransactionId = ?
|
||||
SELECT exists(
|
||||
select *
|
||||
from Payments
|
||||
where TransactionId = ?
|
||||
)
|
||||
', [$pendingPayment->TransactionId]) > 0){
|
||||
$log->Write('Donation already exists in database.');
|
||||
continue;
|
||||
|
@ -201,10 +203,12 @@ try{
|
|||
if($payment->User !== null){
|
||||
// Are we already a patron?
|
||||
if(Db::QueryInt('
|
||||
SELECT count(*)
|
||||
from Patrons
|
||||
where UserId = ?
|
||||
and Ended is null
|
||||
SELECT exists(
|
||||
select *
|
||||
from Patrons
|
||||
where UserId = ?
|
||||
and Ended is null
|
||||
)
|
||||
', [$payment->UserId]) == 0){
|
||||
// Not a patron yet, add them to the Patrons Circle
|
||||
|
||||
|
@ -224,6 +228,21 @@ try{
|
|||
$log->Write('Adding donor as patron ...');
|
||||
$patron->Create();
|
||||
}
|
||||
elseif(!$payment->IsRecurring && !$payment->IsMatchingDonation){
|
||||
// User is already a patron, but they made another non-recurring, non-matching donation.
|
||||
// Send a thank-you email.
|
||||
|
||||
$log->Write('Sending thank you email to patron donor donating extra.');
|
||||
$em = new Email();
|
||||
$em->To = $payment->User->Email;
|
||||
$em->ToName = $payment->User->Name;
|
||||
$em->From = EDITOR_IN_CHIEF_EMAIL_ADDRESS;
|
||||
$em->FromName = EDITOR_IN_CHIEF_NAME;
|
||||
$em->Subject = 'Thank you for supporting Standard Ebooks!';
|
||||
$em->Body = Template::EmailDonationThankYou();
|
||||
$em->TextBody = Template::EmailDonationThankYouText();
|
||||
$em->Send();
|
||||
}
|
||||
}
|
||||
elseif(!$payment->IsRecurring && !$payment->IsMatchingDonation){
|
||||
// Fully-anonymous, non-recurring donation eligible for the Patrons Circle. We can't notify them, but do notify the admins.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue