2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 // {{{ class UserFilterBuilder
23 class UserFilterBuilder
27 private $valid = true
;
29 private $orders = array();
32 * @param $fields An array of UFB_Field objects
33 * @param $envprefix Prefix to use for parts of the query
35 public function __construct($fields, $envprefix = '')
37 $this->fields
= $fields;
38 $this->envprefix
= $envprefix;
41 /** Builds the UFC; returns as soon as a field says it is invalid
43 private function buildUFC()
45 if ($this->ufc
!= null
) {
48 $this->ufc
= new PFC_And();
50 foreach ($this->fields
as $field) {
51 $this->valid
= $field->apply(&$this);
58 public function addCond(PlFilterCondition
&$cond)
60 $this->ufc
->addChild($cond);
63 public function addOrder(PlFilterOrder
&$order)
65 $this->order
[] = $order;
68 public function isValid()
74 public function isEmpty()
77 foreach ($this->fields
as $field) {
78 if (! $field->isEmpty()) {
85 /** Returns the built UFC
86 * @return The UFC, or PFC_False() if an error happened
88 public function getUFC()
94 return new PFC_False();
98 /** Returns adequate orders
100 public function getOrders()
103 return $this->orders
;
106 /** Wrappers around Env::i/s/..., to add envprefix
108 public function s($key, $def = '')
110 return Env
::s($this->envprefix
. $key, $def);
113 public function t($key, $def = '')
115 return Env
::t($this->envprefix
. $key, $def);
118 public function i($key, $def = 0)
120 return Env
::i($this->envprefix
. $key, $def);
123 public function v($key, $def = null
)
125 return Env
::v($this->envprefix
. $key, $def);
128 public function b($key, $def = false
)
130 return Env
::b($this->envprefix
. $key, $def);
133 public function has($key)
135 return Env
::has($this->envprefix
. $key);
138 public function blank($key, $strict = false
)
140 return Env
::blank($key, $strict);
143 public function hasAlnum($key)
145 $str = $this->s($key);
146 return preg_match('/[a-z0-9]/i', $str);
149 public function hasAlpha($key)
151 $str = $this->s($key);
152 return preg_match('/[a-z]/i', $str);
155 public function isOn($key)
157 return $this->has($key) && $this->t($key) == 'on';
162 // {{{ class UFB_QuickSearch
163 class UFB_QuickSearch
extends UserFilterBuilder
165 public function __construct($envprefix = '')
168 new UFBF_Quick('quick', 'Recherche rapide'),
170 parent
::__construct($fields, $envprefix);
175 // {{{ class UFB_AdvancedSearch
176 class UFB_AdvancedSearch
extends UserFilterBuilder
178 public function __construct($envprefix = '')
181 new UFBF_Name('name', 'Nom'),
182 new UFBF_Promo('promo1', 'Promotion', 'egal1'),
183 new UFBF_Promo('promo2', 'Promotion', 'egal2'),
184 new UFBF_Sex('woman', 'Sexe'),
185 new UFBF_Registered('subscriber', 'Inscrit'),
186 new UFBF_Dead('alive', 'En vie'),
188 new UFBF_Town('city', 'Ville / Code Postal'),
189 new UFBF_Country('countryTxt', 'country', 'Pays'),
190 new UFBF_AdminArea('administrativearea', 'Région'),
191 new UFBF_SubAdminArea('subadministrativearea', 'Département'),
193 new UFBF_JobCompany('entreprise', 'Entreprise'),
194 new UFBF_JobDescription('jobdescription', 'Fonction'),
195 new UFBF_JobCv('cv', 'CV'),
196 new UFBF_JobTerms('jobterm', 'Mots-clefs'),
198 new UFBF_Nationality('nationaliteTxt', 'nationalite', 'Nationalité'),
199 new UFBF_Binet('binetTxt', 'binet', 'Binet'),
200 new UFBF_Group('groupexTxt', 'groupex', 'Groupe X'),
201 new UFBF_Section('sectionTxt', 'section', 'Section'),
203 new UFBF_EducationSchool('schoolTxt', 'school', "École d'application"),
204 new UFBF_EducationDegree('diplomaTxt', 'diploma', 'Diplôme'),
205 new UFBF_EducationField('fieldTxt', 'field', "Domaine d'études"),
207 new UFBF_Comment('free', 'Commentaire'),
208 new UFBF_Phone('phone_number', 'Téléphone'),
209 new UFBF_Networking('networking_address', 'networking_type', 'Networking et sites webs'),
211 new UFBF_Mentor('only_referent', 'Référent'),
213 parent
::__construct($fields, $envprefix);
218 // {{{ class UFB_MentorSearch
219 class UFB_MentorSearch
extends UserFilterBuilder
221 public function __construct($envprefix = '')
224 new UFBF_MentorCountry('country'),
225 new UFBF_MentorTerm('jobterm', 'jobtermText'),
226 new UFBF_MentorExpertise('expertise'),
228 parent
::__construct($fields, $envprefix);
233 // {{{ class UFB_Field
234 abstract class UFB_Field
239 protected $empty = false
;
240 protected $val = null
;
243 * @param $envfield Name of the field in the environment
244 * @param $formtext User-friendly name of that field
246 public function __construct($envfield, $formtext = '')
248 $this->envfield
= $envfield;
249 if ($formtext != '') {
250 $this->formtext
= $formtext;
252 $formtext = ucfirst($envfield);
256 /** Prints the given error message to the user, and returns false
257 * in order to be used as return $this->raise('ERROR');
259 * All %s in the $msg will be replaced with the formtext.
261 protected function raise($msg)
263 Platal
::page()->trigError(str_replace('%s', $this->formtext
, $msg));
267 public function apply(UserFilterBuilder
&$ufb) {
268 if (!$this->check($ufb)) {
272 if (!$this->isEmpty()) {
273 $ufc = $this->buildUFC($ufb);
281 public function isEmpty()
286 /** Create the UFC associated to the field; won't be called
287 * if the field is "empty"
288 * @param &$ufb UFB to which fields must be added
291 abstract protected function buildUFC(UserFilterBuilder
&$ufb);
293 /** This function is intended to run consistency checks on the value
294 * @return boolean Whether the input is valid
296 abstract protected function check(UserFilterBuilder
&$ufb);
300 // {{{ class UFBF_Text
301 abstract class UFBF_Text
extends UFB_Field
306 public function __construct($envfield, $formtext = '', $minlength = 2, $maxlength = 255)
308 parent
::__construct($envfield, $formtext);
309 $this->minlength
= $minlength;
310 $this->maxlength
= $maxlength;
313 protected function check(UserFilterBuilder
&$ufb)
315 if ($ufb->blank($this->envfield
)) {
320 $this->val
= $ufb->t($this->envfield
);
321 if (strlen($this->val
) < $this->minlength
) {
322 return $this->raise("Le champ %s est trop court (minimum {$this->minlength}).");
323 } else if (strlen($this->val
) > $this->maxlength
) {
324 return $this->raise("Le champ %s est trop long (maximum {$this->maxlength}).");
325 } else if (preg_match(":[\]\[<>{}~§_`|%$^=]|\*\*:u", $this->val
)) {
326 return $this->raise('Le champ %s contient un caractère interdit rendant la recherche impossible.');
334 // {{{ class UFBF_Range
335 /** Subclass to use for fields which only allow integers within a range
337 abstract class UFBF_Range
extends UFB_Field
343 public function __construct($envfield, $formtext = '', $min = 0, $max = 65535)
345 parent
::__construct($envfield, $formtext);
350 protected function check(UserFilterBuilder
&$ufb)
352 if ($ufb->blank($this->envfield
)) {
357 $this->val
= $ufb->i($this->envfield
);
358 if ($this->val
< $this->min
) {
359 return $this->raise("Le champs %s est inférieur au minimum ({$this->min}).");
360 } else if ($this->val
> $this->max
) {
361 return $this->raise("Le champ %s est supérieur au maximum ({$this->max}).");
368 // {{{ class UFBF_Index
369 /** Subclass to use for indexed fields
371 abstract class UFBF_Index
extends UFB_Field
373 protected function check(UserFilterBuilder
&$ufb)
375 if ($ufb->blank($this->envfield
)) {
378 $this->val
= $ufb->i($this->envfield
);
384 // {{{ class UFBF_Enum
385 /** Subclass to use for fields whose value must belong to a specific set of values
387 abstract class UFBF_Enum
extends UFB_Field
389 protected $allowedvalues;
391 public function __construct($envfield, $formtext = '', $allowedvalues = array(), $strict = false
)
393 parent
::__construct($envfield, $formtext);
394 $this->allowedvalues
= $allowedvalues;
395 $this->strict
= $strict;
398 protected function check(UserFilterBuilder
&$ufb)
400 if ($ufb->blank($this->envfield
)) {
405 $this->val
= $ufb->v($this->envfield
);
406 if (! in_array($this->val
, $this->allowedvalues
)) {
408 return $this->raise("La valeur {$this->val} n'est pas valide pour le champ %s.");
418 // {{{ class UFBF_Bool
419 abstract class UFBF_Bool
extends UFB_Field
421 protected function check(UserFilterBuilder
&$ufb)
423 if ($ufb->blank($this->envfield
)) {
428 $this->val
= $ufb->b($this->envfield
);
434 // {{{ class UFBF_Mixed
435 /** A class for building UFBFs when the user can input either a text or an ID
437 abstract class UFBF_Mixed
extends UFB_Field
439 /** Name of the DirEnum on which class is based
443 protected $envfieldindex;
445 public function __construct($envfieldtext, $envfieldindex, $formtext = '')
447 parent
::__construct($envfieldtext, $formtext);
448 $this->envfieldindex
= $envfieldindex;
451 protected function check(UserFilterBuilder
&$ufb)
453 if ($ufb->blank($this->envfieldindex
) && !$ufb->hasAlnum($this->envfield
)) {
458 if (!$ufb->blank($this->envfieldindex
)) {
459 $index = $ufb->v($this->envfieldindex
);
460 if (is_int($index)) {
461 $index = intval($index);
463 $index = strtoupper($index);
465 $this->val
= array($index);
467 $indexes = DirEnum
::getIDs($this->direnum
, $ufb->t($this->envfield
),
468 $ufb->b('exact') ? XDB
::WILDCARD_EXACT
: XDB
::WILDCARD_CONTAINS
);
469 if (count($indexes) == 0) {
472 $this->val
= $indexes;
479 // {{{ class UFBF_Quick
480 class UFBF_Quick
extends UFB_Field
482 protected function check(UserFilterBuilder
&$ufb)
484 if ($ufb->blank($this->envfield
)) {
489 $this->val
= str_replace('*', '%', replace_accent($ufb->t($this->envfield
)));
494 protected function buildUFC(UserFilterBuilder
&$ufb)
497 $r = $s = $this->val
;
501 if (S
::admin() && strpos($s, '@') !== false
) {
502 return new UFC_Email($s);
503 } else if (S
::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
504 return new UFC_Ip($s);
507 $conds = new PFC_And();
511 $s = preg_replace('!\d+!', ' ', $s);
512 $strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY
);
513 if (count($strings) > 5) {
514 Platal
::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
515 $strings = array_slice($strings, 0, 5);
518 if (count($strings)) {
522 $flags = array('public');
524 $exact =$ufb->b('exact');
525 $conds->addChild(new UFC_NameTokens($strings, $flags, $ufb->b('with_soundex'), $exact));
527 $ufb->addOrder(new UFO_Score());
532 $s = preg_replace('! *- *!', '-', $r);
533 $s = preg_replace('!([<>]) *!', ' \1', $s);
534 $s = preg_replace('![^0-9\-><]!', ' ', $s);
535 $s = preg_replace('![<>\-] !', '', $s);
536 $ranges = preg_split('! +!', $s, -1, PREG_SPLIT_NO_EMPTY
);
537 foreach ($ranges as $r) {
538 if (preg_match('!^\d{4}$!', $r)) {
539 $conds->addChild(new UFC_Promo('=', UserFilter
::DISPLAY
, 'X' . $r));
540 } elseif (preg_match('!^(\d{4})-(\d{4})$!', $r, $matches)) {
541 $p1=min(intval($matches[1]), intval($matches[2]));
542 $p2=max(intval($matches[1]), intval($matches[2]));
543 $conds->addChild(new PFC_And(
544 new UFC_Promo('>=', UserFilter
::DISPLAY
, 'X' . $p1),
545 new UFC_Promo('<=', UserFilter
::DISPLAY
, 'X' . $p2)
547 } elseif (preg_match('!^<(\d{4})!', $r, $matches)) {
548 $conds->addChild(new UFC_Promo('<=', UserFilter
::DISPLAY
, 'X' . $matches[1]));
549 } elseif (preg_match('!^>(\d{4})!', $r, $matches)) {
550 $conds->addChild(new UFC_Promo('>=', UserFilter
::DISPLAY
, 'X' . $matches[1]));
556 $t = preg_replace('!(\d{4}-\d{4}|>\d{4}|<\d{4})!', '', $s);
557 $t = preg_replace('![<>\- ]!', '', $t);
558 if (strlen($t) > 4) {
559 $conds->addChild(new UFC_Phone($t));
567 // {{{ class UFBF_Name
568 class UFBF_Name
extends UFBF_Text
570 protected function check(UserFilterBuilder
&$ufb)
572 if (!parent
::check($ufb)) {
576 $this->val
= preg_split('/[[:space:]]/', $this->val
);
577 if (count($this->val
) == 0) {
583 protected function buildUFC(UserFilterBuilder
&$ufb)
585 return new UFC_NameTokens($this->val
, array(), $ufb->b('with_soundex'), $ufb->b('exact'));
590 // {{{ class UFBF_Promo
591 class UFBF_Promo
extends UFB_Field
593 private static $validcomps = array('<', '<=', '=', '>=', '>');
595 private $envfieldcomp;
597 public function __construct($envfield, $fromtext = '', $envfieldcomp)
599 parent
::__construct($envfield, $fromtext);
600 $this->envfieldcomp
= $envfieldcomp;
603 protected function check(UserFilterBuilder
&$ufb)
605 if ($ufb->blank($this->envfield
) ||
$ufb->blank($this->envfieldcomp
)) {
610 $this->val
= $ufb->i($this->envfield
);
611 $this->comp
= $ufb->v($this->envfieldcomp
);
613 if (!in_array($this->comp
, self
::$validcomps)) {
614 return $this->raise("Le critère {$this->comp} n'est pas valide pour le champ %s");
617 if (preg_match('/^[0-9]{2}$/', $this->val
)) {
620 if ($this->val
< 1900 ||
$this->val
> 9999) {
621 return $this->raise("Le champ %s doit être une année à 4 chiffres.");
626 protected function buildUFC(UserFilterBuilder
&$ufb) {
627 return new UFC_Promo($this->comp
, UserFilter
::GRADE_ING
, $this->val
);
632 // {{{ class UFBF_Sex
633 class UFBF_Sex
extends UFBF_Enum
635 public function __construct($envfield, $formtext = '')
637 parent
::__construct($envfield, $formtext, array(1, 2));
640 private static function getVal($id)
644 return User
::GENDER_MALE
;
647 return User
::GENDER_FEMALE
;
652 protected function buildUFC(UserFilterBuilder
&$ufb)
654 return new UFC_Sex(self
::getVal($this->val
));
659 // {{{ class UFBF_Registered
660 class UFBF_Registered
extends UFBF_Enum
662 public function __construct($envfield, $formtext = '')
664 parent
::__construct($envfield, $formtext, array(1, 2));
667 protected function buildUFC(UserFilterBuilder
&$ufb)
669 if ($this->val
== 1) {
670 return new UFC_Registered();
671 } else if ($this->val
== 2) {
672 return new PFC_Not(new UFC_Registered());
678 // {{{ class UFBF_Dead
679 class UFBF_Dead
extends UFBF_Enum
681 public function __construct($envfield, $formtext = '')
683 parent
::__construct($envfield, $formtext, array(1, 2));
686 protected function buildUFC(UserFilterBuilder
&$ufb)
688 if ($this->val
== 1) {
689 return new PFC_Not(new UFC_Dead());
690 } else if ($this->val
== 2) {
691 return new UFC_Dead();
697 // {{{ class UFBF_Town
698 /** Retrieves a town, either from a postal code or a town name
700 class UFBF_Town
extends UFBF_Text
707 private $onlycurrentfield;
709 public function __construct($envfield, $formtext = '', $type = self
::TYPE_ANY
, $onlycurrentfield = 'only_current')
712 $this->onlycurrentfield
= $onlycurrentfield;
713 parent
::__construct($envfield, $formtext, 2, 30);
716 protected function buildUFC(UserFilterBuilder
&$ufb)
718 if ($ufb->isOn($this->onlycurrentfield
)) {
719 $flags = UFC_Address
::FLAG_CURRENT
;
721 $flags = UFC_Address
::FLAG_ANY
;
724 if (preg_match('/[0-9]/', $this->val
)) {
725 if ($this->type
& self
::TYPE_ZIP
) {
726 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ZIPCODE
, UFC_Address
::TYPE_ANY
, $flags);
728 return new PFC_False();
731 $byname = new UFC_AddressText(null
, XDB
::WILDCARD_CONTAINS
, UFC_Address
::TYPE_ANY
, $flags, null
, $this->val
);
732 $byzip = new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ZIPCODE
, UFC_Address
::TYPE_ANY
, $flags);
733 if ($this->type
& self
::TYPE_ANY
) {
734 return new PFC_Or($byname, $byzip);
735 } else if ($this->type
& self
::TYPE_TEXT
) {
745 // {{{ class UFBF_Country
746 class UFBF_Country
extends UFBF_Mixed
748 protected $direnum = DirEnum
::COUNTRIES
;
749 protected $onlycurrentfield;
751 public function __construct($envfieldtext, $envfieldindex, $formtext = '', $onlycurrentfield = 'only_current')
753 parent
::__construct($envfieldtext, $envfieldindex, $formtext);
754 $this->onlycurrentfield
= $onlycurrentfield;
757 protected function buildUFC(UserFilterBuilder
&$ufb)
759 if ($ufb->isOn($this->onlycurrentfield
)) {
760 $flags = UFC_Address
::FLAG_CURRENT
;
762 $flags = UFC_Address
::FLAG_ANY
;
765 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_COUNTRY
, UFC_Address
::TYPE_ANY
, $flags);
770 // {{{ class UFBF_AdminArea
771 class UFBF_AdminArea
extends UFBF_Index
773 protected $direnum = DirEnum
::ADMINAREAS
;
774 protected $onlycurrentfield;
776 public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current')
778 parent
::__construct($envfield, $formtext);
779 $this->onlycurrentfield
= $onlycurrentfield;
783 protected function buildUFC(UserFilterBuilder
&$ufb)
785 if ($ufb->isOn($this->onlycurrentfield
)) {
786 $flags = UFC_Address
::FLAG_CURRENT
;
788 $flags = UFC_Address
::FLAG_ANY
;
791 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ADMAREA
, UFC_Address
::TYPE_ANY
, $flags);
796 // {{{ class UFBF_SubAdminArea
797 class UFBF_SubAdminArea
extends UFBF_Index
799 protected $direnum = DirEnum
::SUBADMINAREAS
;
800 protected $onlycurrentfield;
802 public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current')
804 parent
::__construct($envfield, $formtext);
805 $this->onlycurrentfield
= $onlycurrentfield;
809 protected function buildUFC(UserFilterBuilder
&$ufb)
811 if ($ufb->isOn($this->onlycurrentfield
)) {
812 $flags = UFC_Address
::FLAG_CURRENT
;
814 $flags = UFC_Address
::FLAG_ANY
;
817 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_SUBADMAREA
, UFC_Address
::TYPE_ANY
, $flags);
822 // {{{ class UFBF_JobCompany
823 class UFBF_JobCompany
extends UFBF_Text
825 private $onlymentorfield;
827 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
829 parent
::__construct($envfield, $formtext);
830 $this->onlymentorfield
= $onlymentorfield;
833 public function check(UserFilterBuilder
&$ufb) {
834 if (parent
::check($ufb)) {
835 # No company check for mentors
836 if ($ufb->isOn($this->onlymentorfield
)) {
845 protected function buildUFC(UserFilterBuilder
&$ufb)
847 return new UFC_Job_Company(UFC_Job_Company
::JOBNAME
, $this->val
);
852 // {{{ class UFBF_JobTerms
853 class UFBF_JobTerms
extends UFBF_Index
855 protected function buildUFC(UserFilterBuilder
&$ufb)
857 return new UFC_Job_Terms($this->val
);
862 // {{{ class UFBF_JobDescription
863 class UFBF_JobDescription
extends UFBF_Text
865 private $onlymentorfield;
867 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
869 parent
::__construct($envfield, $formtext);
870 $this->onlymentorfield
= $onlymentorfield;
873 protected function buildUFC(UserFilterBuilder
&$ufb)
875 if ($ufb->isOn($this->onlymentorfield
)) {
876 return new UFC_Mentor_Expertise($this->val
);
878 return new UFC_Job_Description($this->val
, UserFilter
::JOB_USERDEFINED
);
884 // {{{ class UFBF_JobCv
885 class UFBF_JobCv
extends UFBF_Text
887 private $onlymentorfield;
889 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
891 parent
::__construct($envfield, $formtext);
892 $this->onlymentorfield
= $onlymentorfield;
895 protected function buildUFC(UserFilterBuilder
&$ufb)
897 if ($ufb->isOn($this->onlymentorfield
)) {
898 return new UFC_Mentor_Expertise($this->val
);
900 return new UFC_Job_Description($this->val
, UserFilter
::JOB_CV
);
906 // {{{ class UFBF_Nationality
907 class UFBF_Nationality
extends UFBF_Mixed
909 protected $direnum = DirEnum
::NATIONALITIES
;
911 protected function buildUFC(UserFilterBuilder
&$ufb)
913 return new UFC_Nationality($this->val
);
918 // {{{ class UFBF_Binet
919 class UFBF_Binet
extends UFBF_Mixed
921 protected $direnum = DirEnum
::BINETS
;
923 protected function buildUFC(UserFilterBuilder
&$ufb)
925 return new UFC_Binet($this->val
);
930 // {{{ class UFBF_Group
931 class UFBF_Group
extends UFBF_Mixed
933 protected $direnum = DirEnum
::GROUPESX
;
935 protected function buildUFC(UserFilterBuilder
&$ufb)
937 if (count($this->val
) == 1) {
938 return new UFC_Group($this->val
[0]);
942 foreach ($this->val
as $grp) {
943 $or->addChild(new UFC_Group($grp));
950 // {{{ class UFBF_Section
951 class UFBF_Section
extends UFBF_Mixed
953 protected $direnum = DirEnum
::SECTIONS
;
955 protected function buildUFC(UserFilterBuilder
&$ufb)
957 return new UFC_Section($this->val
);
962 // {{{ class UFBF_EducationSchool
963 class UFBF_EducationSchool
extends UFBF_Mixed
965 protected $direnum = DirEnum
::EDUSCHOOLS
;
967 protected function buildUFC(UserFilterBuilder
&$ufb)
969 return new UFC_EducationSchool($this->val
);
974 // {{{ class UFBF_EducationDegree
975 class UFBF_EducationDegree
extends UFBF_Mixed
977 protected $direnum = DirEnum
::EDUDEGREES
;
979 protected function buildUFC(UserFilterBuilder
&$ufb)
981 return new UFC_EducationDegree($this->val
);
986 // {{{ class UFBF_EducationField
987 class UFBF_EducationField
extends UFBF_Mixed
989 protected $direnum = DirEnum
::EDUFIELDS
;
991 protected function buildUFC(UserFilterBuilder
&$ufb)
993 return new UFC_EducationField($this->val
);
998 // {{{ class UFBF_Comment
999 class UFBF_Comment
extends UFBF_Text
1001 protected function buildUFC(UserFilterBuilder
&$ufb)
1003 return new UFC_Comment($this->val
);
1008 // {{{ class UFBF_Phone
1009 class UFBF_Phone
extends UFBF_Text
1011 protected function buildUFC(UserFilterBuilder
&$ufb)
1013 return new UFC_Phone($this->val
);
1018 // {{{ class UFBF_Networking
1019 class UFBF_Networking
extends UFBF_Text
1021 private $networktypefield;
1024 public function __construct($envfield, $networktypefield, $formtext = '')
1026 parent
::__construct($envfield, $formtext);
1027 $this->networktypefield
= $networktypefield;
1030 public function check(UserFilterBuilder
&$ufb)
1032 if (parent
::check($ufb)) {
1033 $this->nwtype
= $ufb->i($this->networktypefield
);
1040 public function isEmpty()
1042 return parent
::isEmpty() ||
$this->nwtype
== 0;
1045 public function buildUFC(UserFilterBuilder
&$ufb)
1047 return new UFC_Networking($this->nwtype
, $this->val
);
1052 // {{{ class UFBF_Mentor
1053 class UFBF_Mentor
extends UFBF_Bool
1055 protected function buildUFC(UserFilterBuilder
&$ufb)
1057 return new UFC_Mentor();
1062 // {{{ class UFBF_MentorCountry
1063 class UFBF_MentorCountry
extends UFBF_Text
1065 protected function buildUFC(UserFilterBuilder
&$ufb)
1067 return new UFC_Mentor_Country($this->val
);
1072 // {{{ class UFBF_Mentorterm
1073 class UFBF_MentorTerm
extends UFBF_Index
1075 protected function buildUFC(UserFilterBuilder
&$ufb)
1077 return new UFC_Mentor_Terms($this->val
);
1082 // {{{ class UFBF_MentorExpertise
1083 class UFBF_MentorExpertise
extends UFBF_Text
1085 protected function buildUFC(UserFilterBuilder
&$ufb)
1087 return new UFC_Mentor_Expertise($this->val
);
1092 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: