【发布时间】:2014-02-14 09:22:37
【问题描述】:
我正在尝试修改 Concrete5 插件,该插件会在用户订阅即将到期时向用户发送警告电子邮件。它的工作原理是首先过滤掉已经收到通知的用户,然后选择截至今天订阅距到期日期 (expirationDate) 给定天数 (emailOnExpirationDays) 的用户。
我的问题是我需要能够通知用户 3 次而不是一次。我想提前 30 天、5 天和 1 天通知他们。我的第一个障碍是只过滤掉 5 天内通知的用户(25 天前没有故意通知)。如何修改下面的 PHP 和 SQL 来完成此操作?注释掉的代码是我尝试过的东西。过滤功能信息为here。
集合在这里被实例化:
$expiringTxns = new LMemTxnList();
$expiringTxns->filterByProductWithExpirationEmailsThatShouldBeWarned();
......
public function filterByProductWithExpirationEmailsThatShouldBeWarned() {
$this->setupProductExpirationQueries();//displays all with account
//we haven't already sent out an expiration warning or, for that matter, a notice
$this->filter('notifiedDate', null);
$this->filter('warnedDate', null); //Caitlin commented out to allow more than one warning
//$this->filter('warnedDate', '!= BETWEEN DATE_SUB(NOW(), INTERVAL 5 DAY) AND NOW()');
// the emailOnExpirationDays has been properly configured
$this->filter('emailOnExpirationDays', null, '!=');
$this->filter('emailOnExpirationDays', 0, '>');
//the expirationDate - warning is between 5 days ago (don't want to send a bunch of emails) and now
// the warning code should be getting run after the notice code, so we shouldn't have to worry about 3 day warnings and sending warning and notice at the same time
$this->filter(null, 'DATE_SUB(expirationDate, INTERVAL emailOnExpirationDays DAY) BETWEEN DATE_SUB(NOW(), INTERVAL 5 DAY) AND NOW()');
//$this->filter(null, 'DATE_SUB(expirationDate, INTERVAL 30 DAY) BETWEEN DATE_SUB(NOW(), INTERVAL 5 DAY) AND NOW()');
}
protected function setupProductExpirationQueries() {
$this->addToQuery(' INNER JOIN LMemProducts ON txns.productID = LMemProducts.ID');
// the expiration date exists (some products don't expire)
$this->filter('expirationDate', null, '!=');
// we're supposed to send emails
$this->filter('emailOnExpiration', true);
$this->filter('emailOnExpirationDays', null, '!=');
$this->filter('emailOnExpirationDays', 0, '!=');
}
}
【问题讨论】: