From 4f4f166c817d12c39fe65aa5ceafc43e580e9fcc Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 20 Dec 2010 21:39:39 +0100 Subject: [PATCH] Retrieves ids from a PlSet. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/plfilter.php | 8 ++++++++ classes/plset.php | 42 +++++++++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/classes/plfilter.php b/classes/plfilter.php index af8141d..79a9a1b 100644 --- a/classes/plfilter.php +++ b/classes/plfilter.php @@ -319,6 +319,14 @@ abstract class PlFilter */ public abstract function get($limit = null); + /** Get ids, selecting only those within a limit + * @param $limit The portion of the matching objects to select + */ + public function getIds($limit = null) + { + return $this->get($limit); + } + /** PRIVATE FUNCTIONS */ diff --git a/classes/plset.php b/classes/plset.php index 106c18a..837a327 100644 --- a/classes/plset.php +++ b/classes/plset.php @@ -113,30 +113,54 @@ abstract class PlSet return $res; } - /** This function returns the values of the set, and sets $count with the - * total number of results. - * @param $limit A PlLimit for selecting users - * @param $orders An optional array of PFO to use before the "default" ones - * @return The result of $pf->get(); + /** Helper function, calls buildFilter with the adequate condition/orders. + * @param $orders Additional orders to use before the default ones. + * @return A newly created PlFilter. */ - public function &get(PlLimit $limit = null, $orders = array()) + private function buildFilterHelper($orders = array()) { if (!is_array($orders)) { $orders = array($orders); } - $orders = array_merge($orders, $this->orders); - $pf = $this->buildFilter($this->conds, $orders); + return $this->buildFilter($this->conds, $orders); + } + /** This function returns the values of the set, and sets $count with the + * total number of results. + * @param $limit A PlLimit for selecting users + * @param $orders An optional array of PFO to use before the "default" ones + * @return The result of $pf->get(); + */ + public function &get(PlLimit $limit = null, $orders = array()) + { if (is_null($limit)) { $limit = new PlLimit(self::DEFAULT_MAX_RES, 0); } - $it = $this->getFilterResults($pf, $limit); + $pf = $this->buildFilterHelper($orders); + $it = $this->getFilterResults($pf, $limit); $this->count = $pf->getTotalCount(); return $it; } + /** This function returns the ids of the set, and sets $count with the + * total number of results. + * @param $limit A PlLimit for selecting profiles + * @param $orders An optional array of PFO to use before the "default" ones + * @return The result of $pf->getId(); + */ + public function &getIds(PlLimit $limit = null, $orders = array()) + { + if (is_null($limit)) { + $limit = new PlLimit(self::DEFAULT_MAX_RES, 0); + } + $pf = $this->buildFilterHelper($orders); + $result = $pf->getIds($limit); + $this->count = count($result); + return $result; + } + /** Return an array containing all pertinent parameters for this page * Generated from $_GET, after some cleanup (remove 'n' (plat/al field * for the handler path) -- 2.1.4