From 332cf4b955ef4c61587d612953305919155e7598 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 3 Nov 2011 10:53:17 +0100 Subject: [PATCH] Uses UserFilters to count NL members. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/newsletter.inc.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index b9e51dc..7733f02 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -400,23 +400,16 @@ class NewsLetter */ public function subscriberCount() { - return XDB::fetchOneCell('SELECT COUNT(uid) - FROM newsletter_ins - WHERE nlid = {?}', $this->id); + $uf = new UserFilter(new UFC_NLSubscribed($this->id)); + return $uf->getTotalCount(); } /** Get the count of subscribers with non valid redirection. */ public function lostSubscriberCount() { - return XDB::fetchOneCell('SELECT COUNT(DISTINCT(n.uid)) - FROM newsletter_ins AS n - INNER JOIN accounts AS a ON (n.uid = a.uid) - INNER JOIN account_types AS t ON (t.type = a.type) - LEFT JOIN email_redirect_account AS r ON (r.uid = a.uid AND r.flags = \'active\' AND r.broken_level < 3 - AND r.type != \'imap\' AND r.type != \'homonym\') - WHERE n.nlid = {?} AND r.redirect IS NULL AND a.state = \'active\' AND FIND_IN_SET(\'mail\', t.perms)', - $this->id); + $uf = new UserFilter(new PFC_And(new UFC_NLSubscribed($this->id), new PFC_Not(new UFC_HasEmailRedirect()))); + return $uf->getTotalCount(); } /** Get the number of subscribers to the NL whose last received mailing was $last. -- 2.1.4