Add ProfileSet / ProfileFilter, fix orders
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Fri, 5 Feb 2010 15:34:03 +0000 (16:34 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sat, 13 Feb 2010 23:34:00 +0000 (00:34 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/userfilter.php
include/userset.inc.php

index 843de8f..34f3b0f 100644 (file)
@@ -2469,5 +2469,15 @@ class UserFilter extends PlFilter
 }
 // }}}
 
+// {{{ class ProfileFilter
+class ProfileFilter extends UserFilter
+{
+    public function get(PlLimit &$limit)
+    {
+        return $this->getProfiles($limit);
+    }
+}
+// }}}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 56dac4b..92a5531 100644 (file)
@@ -21,7 +21,7 @@
 
 class UserSet extends PlSet
 {
-    public function __construct(PlFilterCondition &$cond, $orders)
+    public function __construct(PlFilterCondition &$cond, $orders = null)
     {
         parent::__construct($cond, $orders);
     }
@@ -32,12 +32,24 @@ class UserSet extends PlSet
     }
 }
 
-class SearchSet extends UserSet
+class ProfileSet extends PlSet
+{
+    public function __construct(PlFilterCondition &$cond, $orders = null)
+    {
+        parent::__construct($cond, $orders);
+    }
+
+    protected function buildFilter(PlFilterCondition &$cond, $orders)
+    {
+        return new ProfileFilter($cond, $orders);
+    }
+}
+
+class SearchSet extends ProfileSet
 {
     public  $advanced = false;
     private $score    = null;
     private $conds    = null;
-    private $orders   = null;
     private $quick    = false;
 
     public function __construct($quick = false, $no_search = false, PlFilterCondition $cond = null)
@@ -107,9 +119,11 @@ class SearchSet extends UserSet
         $this->conds->addChild($ufb->getUFC());
     }
 
-    public function &get(PlLimit $limit = null)
+    public function &get(PlLimit $limit = null, $orders = array())
     {
-        $uf = $this->buildFilter($this->conds, $this->orders);
+        $orders = array_merge($orders, $this->orders);
+
+        $uf = $this->buildFilter($this->conds, $orders);
         if (is_null($limit)) {
             $limit = new PlLimit(20, 0);
         }