From 2daf7250dcf3f67bd979a2658efed67f8d823ced Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Tue, 27 Apr 2010 13:29:32 +0200 Subject: [PATCH] Fix UserFilter->getTotalCount MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Split it into getTotalUserCount and getTotalProfileCount Signed-off-by: Raphaël Barrois --- classes/userfilter.php | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/classes/userfilter.php b/classes/userfilter.php index 4458cca..245d89d 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -1549,7 +1549,8 @@ class UserFilter extends PlFilter private $query = null; private $orderby = null; - private $lastcount = null; + private $lastusercount = null; + private $lastprofilecount = null; public function __construct($cond = null, $sort = null) { @@ -1623,7 +1624,7 @@ class UserFilter extends PlFilter GROUP BY a.uid ' . $this->orderby . ' ' . $lim); - $this->lastcount = (int)XDB::fetchOneCell('SELECT FOUND_ROWS()'); + $this->lastusercount = (int)XDB::fetchOneCell('SELECT FOUND_ROWS()'); return $fetched; } @@ -1641,7 +1642,7 @@ class UserFilter extends PlFilter GROUP BY p.pid ' . $this->orderby . ' ' . $lim); - $this->lastcount = (int)XDB::fetchOneCell('SELECT FOUND_ROWS()'); + $this->lastprofilecount = (int)XDB::fetchOneCell('SELECT FOUND_ROWS()'); return $fetched; } @@ -1814,17 +1815,30 @@ class UserFilter extends PlFilter public function getTotalCount() { - if (is_null($this->lastcount)) { + return $this->getTotalUserCount(); + } + + public function getTotalUserCount() + { + if (is_null($this->lastusercount)) { + $this->requireAccounts(); $this->buildQuery(); - if ($this->with_accounts) { - $field = 'a.uid'; - } else { - $field = 'p.pid'; - } - return (int)XDB::fetchOneCell('SELECT COUNT(DISTINCT ' . $field . ') + return (int)XDB::fetchOneCell('SELECT COUNT(DISTINCT a.uid) + ' . $this->query); + } else { + return $this->lastusercount; + } + } + + public function getTotalProfileCount() + { + if (is_null($this->lastprofilecount)) { + $this->requireProfiles(); + $this->buildQuery(); + return (int)XDB::fetchOneCell('SELECT COUNT(DISTINCT p.pid) ' . $this->query); } else { - return $this->lastcount; + return $this->lastprofilecount; } } @@ -2654,6 +2668,16 @@ class ProfileFilter extends UserFilter { return $this->getProfiles($limit); } + + public function filter(array $profiles, $limit = null) + { + return $this->filterProfiles($profiles, self::defaultLimit($limit)); + } + + public function getTotalCount() + { + return $this->getTotalProfileCount(); + } } // }}} -- 2.1.4