From: Raphaël Barrois Date: Tue, 27 Apr 2010 11:29:32 +0000 (+0200) Subject: Fix UserFilter->getTotalCount X-Git-Tag: xorg/1.0.0~291 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2daf7250dcf3f67bd979a2658efed67f8d823ced;p=platal.git Fix UserFilter->getTotalCount Split it into getTotalUserCount and getTotalProfileCount Signed-off-by: Raphaël Barrois --- 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(); + } } // }}}