X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fuserset.inc.php;h=d2e18234d07717afb6eaba70560852f154e69da1;hb=78a47eb456adb9dec306b7de02391956f98a239c;hp=c648005a4f2a8455901fba48dd9259d0149f8949;hpb=4a0746a82545651c559ea3e593c810ce6fdef6a7;p=platal.git diff --git a/include/userset.inc.php b/include/userset.inc.php index c648005..d2e1823 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -45,21 +45,15 @@ class ProfileSet extends PlSet } } +require_once "ufbuilder.inc.php"; + class SearchSet extends ProfileSet { - public $advanced = false; - private $score = null; - private $quick = false; - private $valid = true; + protected $score = null; + protected $valid = true; - public function __construct($quick = false, PlFilterCondition $cond = null) + public function __construct(UserFilterBuilder &$ufb, PlFilterCondition $cond = null) { - if (isset($no_search)) { - return; - } - - $this->quick = $quick; - if (is_null($cond)) { $conds = new PFC_And(); } else if ($cond instanceof PFC_And) { @@ -68,30 +62,6 @@ class SearchSet extends ProfileSet $conds = new PFC_And($cond); } - if ($quick) { - $this->getQuick($conds); - } else { - $this->getAdvanced($conds); - } - } - - public function isValid() - { - return $this->valid; - } - - /** Sets up the conditions for a Quick Search - * @param $conds Additional conds (as a PFC_And) - */ - private function getQuick($conds) - { - if (!S::logged()) { - Env::kill('with_soundex'); - } - - require_once 'ufbuilder.inc.php'; - $ufb = new UFB_QuickSearch(); - if (!$ufb->isValid()) { $this->valid = false; return; @@ -102,36 +72,12 @@ class SearchSet extends ProfileSet $orders = $ufb->getOrders(); - if (S::logged() && Env::has('nonins')) { - $conds = new PFC_And($conds, - new PFC_Not(new UFC_Dead()), - new PFC_Not(new UFC_Registered()) - ); - } - parent::__construct($conds, $orders); } - /** Sets up the conditions for an Advanced Search - * @param $conds Additional conds (as a PFC_And) - */ - private function getAdvanced($conds) + public function isValid() { - $this->advanced = true; - require_once 'ufbuilder.inc.php'; - $ufb = new UFB_AdvancedSearch(); - - if (!$ufb->isValid()) { - $this->valid = false; - return; - } - - $ufc = $ufb->getUFC(); - $conds->addChild($ufc); - - $orders = $ufb->getOrders(); - - parent::__construct($conds, $orders); + return $this->valid; } /** Add a "rechercher=Chercher" field to the query to simulate the POST @@ -153,6 +99,28 @@ class SearchSet extends ProfileSet } } +// Specialized SearchSet for quick search. +class QuickSearchSet extends SearchSet +{ + public function __construct(PlFilterCondition $cond = null) + { + if (!S::logged()) { + Env::kill('with_soundex'); + } + + parent::__construct(new UFB_QuickSearch(), $cond); + } +} + +// Specialized SearchSet for advanced search. +class AdvancedSearchSet extends SearchSet +{ + public function __construct(PlFilterCondition $cond = null) + { + parent::__construct(new UFB_AdvancedSearch(), $cond); + } +} + /** Simple set based on an array of User objects */ class ArraySet extends ProfileSet