Adds search on masters and doctorates.
authorStéphane Jacob <sj@m4x.org>
Wed, 20 Apr 2011 09:33:31 +0000 (11:33 +0200)
committerStéphane Jacob <sj@m4x.org>
Thu, 21 Apr 2011 16:33:53 +0000 (18:33 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/ufbuilder.inc.php
templates/search/adv.form.tpl

index 13cb8fc..564879a 100644 (file)
@@ -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);
     }
 }
 // }}}
index ee04684..81e08bb 100644 (file)
@@ -306,6 +306,11 @@ function cleanForm(f) {
         &nbsp;et&nbsp;
         <input type="text" name="egal2" size="1" style="text-align:center" value="{if t($smarty.request.egal2) eq '&lt;'}&lt;{else}&gt;{/if}" readonly="readonly" />
         <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
+        <select name="edu_type" style="text-align:center">
+          <option value="{#UserFilter::GRADE_ING#}" {if $smarty.request.edu_type eq #UserFilter::GRADE_ING#}selected="selected"{/if}>X</option>
+          <option value="{#UserFilter::GRADE_MST#}" {if $smarty.request.edu_type eq #UserFilter::GRADE_MST#}selected="selected"{/if}>Master</option>
+          <option value="{#UserFilter::GRADE_PHD#}" {if $smarty.request.edu_type eq #UserFilter::GRADE_PHD#}selected="selected"{/if}>Docteur</option>
+        </select>
       </td>
     </tr>
     <tr>