+ /** Adds a new sort (on the PlFilter)
+ */
+ public function addSort(PlFilterOrder $order)
+ {
+ $this->orders[] = $order;
+ }
+
+ /** Adds a new condition to the PlFilter
+ */
+ public function addCond(PlFilterCondition $cond)
+ {
+ $this->conds->addChild($cond);
+ }
+
+ /** Restricts a PlFilter to values of a given PlFilterOrder
+ */
+ public function restrictTo($value)
+ {
+ $this->restrict_to = $value;
+ }
+
+ /** This function builds the right kind of PlFilter from given data
+ * @param $cond The PlFilterCondition for the filter
+ * @param $orders An array of PlFilterOrder for the filter
+ * @return a PlFilter
+ */
+ abstract protected function buildFilter(PlFilterCondition $cond, $orders);
+
+ /** This function returns the results of the given filter
+ * within $limit; can be use to replace the default $pf->get call.
+ * @param $pf The filter
+ * @param $limit The PlLimit
+ * @return The results of the filter
+ */
+ protected function &getFilterResults(PlFilter $pf, PlLimit $limit)
+ {
+ $res = $pf->get($limit);
+ return $res;
+ }
+
+ /** 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())