From e4937ecc7d6fed02a61056894db9151c3df1aa29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 20 Apr 2011 11:33:31 +0200 Subject: [PATCH] Adds search on masters and doctorates. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/ufbuilder.inc.php | 21 +++++++++++++++------ templates/search/adv.form.tpl | 5 +++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 13cb8fc..564879a 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -340,8 +340,8 @@ class UFB_AdvancedSearch extends UserFilterBuilder { $fields = array( new UFBF_Name('name', 'Nom'), - new UFBF_Promo('promo1', 'Promotion', 'egal1'), - new UFBF_Promo('promo2', 'Promotion', 'egal2'), + new UFBF_Promo('promo1', 'Promotion', 'egal1', 'edu_type'), + new UFBF_Promo('promo2', 'Promotion', 'egal2', 'edu_type'), new UFBF_Sex('woman', 'Sexe'), new UFBF_Registered('subscriber', 'Inscrit'), new UFBF_HasEmailRedirect('has_email_redirect', 'A une redirection active'), @@ -856,24 +856,33 @@ class UFBF_Name extends UFBF_Text class UFBF_Promo extends UFB_Field { private static $validcomps = array('<', '<=', '=', '>=', '>'); + private static $validtypes = array(UserFilter::GRADE_ING, UserFilter::GRADE_PHD, UserFilter::GRADE_MST); private $comp; + private $type; private $envfieldcomp; + private $envfieldtype; - public function __construct($envfield, $formtext = '', $envfieldcomp) + public function __construct($envfield, $formtext = '', $envfieldcomp, $envfieldtype) { parent::__construct($envfield, $formtext); $this->envfieldcomp = $envfieldcomp; + $this->envfieldtype = $envfieldtype; } protected function check(UserFilterBuilder $ufb) { - if ($ufb->blank($this->envfield) || $ufb->blank($this->envfieldcomp)) { + if ($ufb->blank($this->envfield) || $ufb->blank($this->envfieldcomp) || $ufb->blank($this->envfieldtype)) { $this->empty = true; return true; } $this->val = $ufb->i($this->envfield); $this->comp = $ufb->v($this->envfieldcomp); + $this->type = $ufb->v($this->envfieldtype); + + if (!in_array($this->type, self::$validtypes)) { + return $this->raise("Le critère {$this->type} n'est pas valide pour le champ %s"); + } if (!in_array($this->comp, self::$validcomps)) { return $this->raise("Le critère {$this->comp} n'est pas valide pour le champ %s"); @@ -889,12 +898,12 @@ class UFBF_Promo extends UFB_Field } protected function buildUFC(UserFilterBuilder $ufb) { - return new UFC_Promo($this->comp, UserFilter::GRADE_ING, $this->val); + return new UFC_Promo($this->comp, $this->type, $this->val); } public function getEnvFieldNames() { - return array($this->envfield, $this->envfieldcomp); + return array($this->envfield, $this->envfieldcomp, $this->envfieldtype); } } // }}} diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index ee04684..81e08bb 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -306,6 +306,11 @@ function cleanForm(f) {  et  + -- 2.1.4