Properly deal with subscription status, and fix variable name bug

master
Sven Slootweg 12 years ago
parent 1fb10f6c44
commit be8b30472c

@ -143,7 +143,7 @@ class Campaign extends CPHPDatabaseRecordClass
if(!empty($cphp_config->debugmode) || $this->sLastStatisticsUpdate < time() - (60 * 5))
{
/* Update subscriber count */
if($result = $database->CachedQuery("SELECT COUNT(*) FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1", array(":CampaignId" => $this->sId)))
if($result = $database->CachedQuery("SELECT COUNT(*) FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1 AND `Active` = 1", array(":CampaignId" => $this->sId)))
{
$this->uSubscriberCount = $result->data[0]["COUNT(*)"];
}
@ -151,7 +151,7 @@ class Campaign extends CPHPDatabaseRecordClass
/* Update total monthly donations */
try
{
$sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1", array(":CampaignId" => $this->sId));
$sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1 AND `Active` = 1", array(":CampaignId" => $this->sId));
$sTotalDonations = 0;
foreach($sSubscriptions as $sSubscription)

@ -34,7 +34,7 @@ Currency::UpdateRates();
try
{
$sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `Confirmed` = 1 AND `LastEmail` IS NULL OR `LastEmail` < DATE_SUB(NOW(), INTERVAL 1 MONTH)");
$sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `Confirmed` = 1 AND `Active` = 1 AND `LastEmail` IS NULL OR `LastEmail` < DATE_SUB(NOW(), INTERVAL 1 MONTH)");
}
catch (NotFoundException $e)
{

@ -85,7 +85,8 @@ $sSubscription->uSettingsKey = random_string(25);
$sSubscription->uCurrency = $_POST['currency'];
$sSubscription->uAmount = str_replace(",", ".", $_POST['amount']);
$sSubscription->uSubscriptionDate = time();
$sSubscription->uConfirmed = False;
$sSubscription->uIsConfirmed = false;
$sSubscription->uIsActive = false;
$sSubscription->uCampaignId = $sCampaign->sId;
$sSubscription->InsertIntoDatabase();

Loading…
Cancel
Save