+ /** Helper function, calls buildFilter with the adequate condition/orders.
+ * @param $orders Additional orders to use before the default ones.
+ * @return A newly created PlFilter.
+ */
+ private function buildFilterHelper($orders = array(), $extra_cond=null)
+ {
+ if (!is_array($orders)) {
+ $orders = array($orders);
+ }
+ $orders = array_merge($orders, $this->orders);
+
+ if ($extra_cond != null) {
+ $conds = clone $this->conds;
+ $conds->addChild($extra_cond);
+ } else {
+ $conds = $this->conds;
+ }
+ return $this->buildFilter($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);
+ }
+ $pf_res = $this->buildFilterHelper($orders);
+ $pf_groups = $pf_res;
+ $this->total_count = $pf_res->getTotalCount();
+ if ($this->restrict_to != null
+ && count($this->orders)
+ && $this->orders[0] instanceof PlFilterGroupableOrder)
+ {
+ $main_order = $this->orders[0];
+ $pf_res = $this->buildFilterHelper($orders, $main_order->getCondition($this->restrict_to));
+ }
+
+ $it = $this->getFilterResults($pf_res, $limit);
+ $this->count = $pf_res->getTotalCount();
+ if ($pf_groups->hasGroups()) {
+ $this->groups = $pf_groups->getGroups();
+ } else {
+ $this->groups = null;
+ }