Add UFC_Mentor for adv. search restriction 'only_referent'
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 5 Sep 2010 23:33:08 +0000 (01:33 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 5 Sep 2010 23:33:08 +0000 (01:33 +0200)
Partial fix for #1206.

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/userfilter.php
include/ufbuilder.inc.php

index 1c757b7..050c663 100644 (file)
@@ -1219,6 +1219,18 @@ class UFC_Photo implements UserFilterCondition
 }
 // }}}
 
+// {{{ class UFC_Mentor
+class UFC_Mentor implements UserFilterCondition
+{
+    public function buildCondition(PlFilter &$uf)
+    {
+        $sub = $uf->addMentorFilter(UserFilter::MENTOR);
+        return $sub . '.expertise IS NOT NULL';
+    }
+}
+// }}}
+
+
 // {{{ class UFC_Mentor_Expertise
 /** Filters users by mentoring expertise
  * @param $expertise Domain of expertise
@@ -2748,15 +2760,19 @@ class UserFilter extends PlFilter
 
     private $pms = array();
     private $mjtr = false;
-    const MENTOR_EXPERTISE  = 1;
-    const MENTOR_COUNTRY    = 2;
-    const MENTOR_SECTOR     = 3;
-    const MENTOR_TERM       = 4;
+    const MENTOR = 1;
+    const MENTOR_EXPERTISE = 2;
+    const MENTOR_COUNTRY = 3;
+    const MENTOR_SECTOR = 4;
+    const MENTOR_TERM = 5;
 
     public function addMentorFilter($type)
     {
         $this->requireAccounts();
         switch($type) {
+        case self::MENTOR:
+            $this->pms['pm'] = 'profile_mentor';
+            return 'pm';
         case self::MENTOR_EXPERTISE:
             $this->pms['pme'] = 'profile_mentor';
             return 'pme';
index b95aff0..6b437d8 100644 (file)
@@ -207,6 +207,8 @@ class UFB_AdvancedSearch extends UserFilterBuilder
             new UFBF_Comment('free', 'Commentaire'),
             new UFBF_Phone('phone_number', 'Téléphone'),
             new UFBF_Networking('networking_address', 'networking_type', 'Networking et sites webs'),
+
+            new UFBF_Mentor('only_referent', 'Référent'),
         );
         parent::__construct($fields, $envprefix);
     }
@@ -1049,6 +1051,16 @@ class UFBF_Networking extends UFBF_Text
 }
 // }}}
 
+// {{{ class UFBF_Mentor
+class UFBF_Mentor extends UFBF_Bool
+{
+    protected function buildUFC(UserFilterBuilder &$ufb)
+    {
+        return new UFC_Mentor();
+    }
+}
+// }}}
+
 // {{{ class UFBF_MentorCountry
 class UFBF_MentorCountry extends UFBF_Text
 {