From: Florent Bruneau Date: Wed, 4 Feb 2009 07:33:03 +0000 (+0100) Subject: Add stuff to enable sort of result. X-Git-Tag: xorg/1.0.0~332^2~394 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=24e08e33cff3f567f8603dc576d103819e2349a2;p=platal.git Add stuff to enable sort of result. Signed-off-by: Florent Bruneau --- diff --git a/classes/userfilter.php b/classes/userfilter.php index 00f9ce9..7a4dd3b 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -287,7 +287,7 @@ class UFC_Sex implements UserFilterCondition if ($this->sex != User::GENDER_MALE && $this->sex != User::GENDER_FEMALE) { return self::COND_FALSE; } else { - return XDB::format('p.sex = {?}', $this->sex); + return XDB::format('p.sex = {?}', $this->sex == User::GENDER_FEMALE ? 'female' : 'male'); } } } @@ -316,15 +316,22 @@ class UFC_Group implements UserFilterCondition class UserFilter { private $root; + private $sort = array(); private $query = null; + private $orderby = null; - public function __construct($cond = null) + public function __construct($cond = null, $sort = null) { if (!is_null($cond)) { if ($cond instanceof UserFilterCondition) { $this->setCondition($cond); } } + if (!is_null($sort)) { + if ($sort instanceof UserFilterOrder) { + $this->addSort($sort); + } + } } private function buildQuery() @@ -338,6 +345,9 @@ class UserFilter ' . $joins . ' WHERE (' . $where . ')'; } + if (is_null($this->sortby)) { + $this->sortby = ''; + } } private function formatJoin(array $joins) @@ -418,6 +428,12 @@ class UserFilter $this->query = null; } + public function addSort(UserFilterOrder &$sort) + { + $this->sort[] =& $sort; + $this->sortby = null; + } + static public function getLegacy($promo_min, $promo_max) { if ($promo_min != 0) {