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('region', 'RĂ©gion'),
192 new UFBF_JobCompany('entreprise', 'Entreprise'),
193 new UFBF_JobDescription('jobdescription', 'Fonction'),
194 new UFBF_JobCv('cv', 'CV'),
195 new UFBF_JobTerms('jobterm', 'Mots-clefs'),
197 new UFBF_Nationality('nationaliteTxt', 'nationalite', 'Nationalité'),
198 new UFBF_Binet('binetTxt', 'binet', 'Binet'),
199 new UFBF_Group('groupexTxt', 'groupex', 'Groupe X'),
200 new UFBF_Section('sectionTxt', 'section', 'Section'),
202 new UFBF_EducationSchool('schoolTxt', 'school', "École d'application"),
203 new UFBF_EducationDegree('diplomaTxt', 'diploma', 'DiplĂ´me'),
204 new UFBF_EducationField('fieldTxt', 'field', "Domaine d'Ă©tudes"),
206 new UFBF_Comment('free', 'Commentaire'),
207 new UFBF_Phone('phone_number', 'Téléphone'),
208 new UFBF_Networking('networking_address', 'networking_type', 'Networking et sites webs'),
210 new UFBF_Mentor('only_referent', 'Référent'),
212 parent
::__construct($fields, $envprefix);
217 // {{{ class UFB_MentorSearch
218 class UFB_MentorSearch
extends UserFilterBuilder
220 public function __construct($envprefix = '')
223 new UFBF_MentorCountry('country'),
224 new UFBF_MentorTerm('jobterm', 'jobtermText'),
225 new UFBF_MentorExpertise('expertise'),
227 parent
::__construct($fields, $envprefix);
232 // {{{ class UFB_Field
233 abstract class UFB_Field
238 protected $empty = false
;
239 protected $val = null
;
242 * @param $envfield Name of the field in the environment
243 * @param $formtext User-friendly name of that field
245 public function __construct($envfield, $formtext = '')
247 $this->envfield
= $envfield;
248 if ($formtext != '') {
249 $this->formtext
= $formtext;
251 $formtext = ucfirst($envfield);
255 /** Prints the given error message to the user, and returns false
256 * in order to be used as return $this->raise('ERROR');
258 * All %s in the $msg will be replaced with the formtext.
260 protected function raise($msg)
262 Platal
::page()->trigError(str_replace('%s', $this->formtext
, $msg));
266 public function apply(UserFilterBuilder
&$ufb) {
267 if (!$this->check($ufb)) {
271 if (!$this->isEmpty()) {
272 $ufc = $this->buildUFC($ufb);
280 public function isEmpty()
285 /** Create the UFC associated to the field; won't be called
286 * if the field is "empty"
287 * @param &$ufb UFB to which fields must be added
290 abstract protected function buildUFC(UserFilterBuilder
&$ufb);
292 /** This function is intended to run consistency checks on the value
293 * @return boolean Whether the input is valid
295 abstract protected function check(UserFilterBuilder
&$ufb);
299 // {{{ class UFBF_Text
300 abstract class UFBF_Text
extends UFB_Field
305 public function __construct($envfield, $formtext = '', $minlength = 2, $maxlength = 255)
307 parent
::__construct($envfield, $formtext);
308 $this->minlength
= $minlength;
309 $this->maxlength
= $maxlength;
312 protected function check(UserFilterBuilder
&$ufb)
314 if ($ufb->blank($this->envfield
)) {
319 $this->val
= $ufb->t($this->envfield
);
320 if (strlen($this->val
) < $this->minlength
) {
321 return $this->raise("Le champ %s est trop court (minimum {$this->minlength}).");
322 } else if (strlen($this->val
) > $this->maxlength
) {
323 return $this->raise("Le champ %s est trop long (maximum {$this->maxlength}).");
324 } else if (preg_match(":[\]\[<>{}~§_`|%$^=]|\*\*:u", $this->val
)) {
325 return $this->raise('Le champ %s contient un caractère interdit rendant la recherche impossible.');
333 // {{{ class UFBF_Range
334 /** Subclass to use for fields which only allow integers within a range
336 abstract class UFBF_Range
extends UFB_Field
342 public function __construct($envfield, $formtext = '', $min = 0, $max = 65535)
344 parent
::__construct($envfield, $formtext);
349 protected function check(UserFilterBuilder
&$ufb)
351 if ($ufb->blank($this->envfield
)) {
356 $this->val
= $ufb->i($this->envfield
);
357 if ($this->val
< $this->min
) {
358 return $this->raise("Le champs %s est inférieur au minimum ({$this->min}).");
359 } else if ($this->val
> $this->max
) {
360 return $this->raise("Le champ %s est supérieur au maximum ({$this->max}).");
367 // {{{ class UFBF_Index
368 /** Subclass to use for indexed fields
370 abstract class UFBF_Index
extends UFB_Field
372 protected function check(UserFilterBuilder
&$ufb)
374 if ($ufb->blank($this->envfield
)) {
377 $this->val
= $ufb->i($this->envfield
);
383 // {{{ class UFBF_Enum
384 /** Subclass to use for fields whose value must belong to a specific set of values
386 abstract class UFBF_Enum
extends UFB_Field
388 protected $allowedvalues;
390 public function __construct($envfield, $formtext = '', $allowedvalues = array(), $strict = false
)
392 parent
::__construct($envfield, $formtext);
393 $this->allowedvalues
= $allowedvalues;
394 $this->strict
= $strict;
397 protected function check(UserFilterBuilder
&$ufb)
399 if ($ufb->blank($this->envfield
)) {
404 $this->val
= $ufb->v($this->envfield
);
405 if (! in_array($this->val
, $this->allowedvalues
)) {
407 return $this->raise("La valeur {$this->val} n'est pas valide pour le champ %s.");
417 // {{{ class UFBF_Bool
418 abstract class UFBF_Bool
extends UFB_Field
420 protected function check(UserFilterBuilder
&$ufb)
422 if ($ufb->blank($this->envfield
)) {
427 $this->val
= $ufb->b($this->envfield
);
433 // {{{ class UFBF_Mixed
434 /** A class for building UFBFs when the user can input either a text or an ID
436 abstract class UFBF_Mixed
extends UFB_Field
438 /** Name of the DirEnum on which class is based
442 protected $envfieldindex;
444 public function __construct($envfieldtext, $envfieldindex, $formtext = '')
446 parent
::__construct($envfieldtext, $formtext);
447 $this->envfieldindex
= $envfieldindex;
450 protected function check(UserFilterBuilder
&$ufb)
452 if ($ufb->blank($this->envfieldindex
) && !$ufb->hasAlnum($this->envfield
)) {
457 if (!$ufb->blank($this->envfieldindex
)) {
458 $index = $ufb->v($this->envfieldindex
);
459 if (is_int($index)) {
460 $index = intval($index);
462 $index = strtoupper($index);
464 $this->val
= array($index);
466 $indexes = DirEnum
::getIDs($this->direnum
, $ufb->t($this->envfield
),
467 $ufb->b('exact') ? XDB
::WILDCARD_EXACT
: XDB
::WILDCARD_CONTAINS
);
468 if (count($indexes) == 0) {
471 $this->val
= $indexes;
478 // {{{ class UFBF_Quick
479 class UFBF_Quick
extends UFB_Field
481 protected function check(UserFilterBuilder
&$ufb)
483 if ($ufb->blank($this->envfield
)) {
488 $this->val
= str_replace('*', '%', replace_accent($ufb->t($this->envfield
)));
493 protected function buildUFC(UserFilterBuilder
&$ufb)
496 $r = $s = $this->val
;
500 if (S
::admin() && strpos($s, '@') !== false
) {
501 return new UFC_Email($s);
502 } else if (S
::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
503 return new UFC_Ip($s);
506 $conds = new PFC_And();
510 $s = preg_replace('!\d+!', ' ', $s);
511 $strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY
);
512 if (count($strings) > 5) {
513 Platal
::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
514 $strings = array_slice($strings, 0, 5);
517 if (count($strings)) {
521 $flags = array('public');
523 $exact =$ufb->b('exact');
524 $conds->addChild(new UFC_NameTokens($strings, $flags, $ufb->b('with_soundex'), $exact));
526 $ufb->addOrder(new UFO_Score());
531 $s = preg_replace('! *- *!', '-', $r);
532 $s = preg_replace('!([<>]) *!', ' \1', $s);
533 $s = preg_replace('![^0-9\-><]!', ' ', $s);
534 $s = preg_replace('![<>\-] !', '', $s);
535 $ranges = preg_split('! +!', $s, -1, PREG_SPLIT_NO_EMPTY
);
536 foreach ($ranges as $r) {
537 if (preg_match('!^\d{4}$!', $r)) {
538 $conds->addChild(new UFC_Promo('=', UserFilter
::DISPLAY
, 'X' . $r));
539 } elseif (preg_match('!^(\d{4})-(\d{4})$!', $r, $matches)) {
540 $p1=min(intval($matches[1]), intval($matches[2]));
541 $p2=max(intval($matches[1]), intval($matches[2]));
542 $conds->addChild(new PFC_And(
543 new UFC_Promo('>=', UserFilter
::DISPLAY
, 'X' . $p1),
544 new UFC_Promo('<=', UserFilter
::DISPLAY
, 'X' . $p2)
546 } elseif (preg_match('!^<(\d{4})!', $r, $matches)) {
547 $conds->addChild(new UFC_Promo('<=', UserFilter
::DISPLAY
, 'X' . $matches[1]));
548 } elseif (preg_match('!^>(\d{4})!', $r, $matches)) {
549 $conds->addChild(new UFC_Promo('>=', UserFilter
::DISPLAY
, 'X' . $matches[1]));
555 $t = preg_replace('!(\d{4}-\d{4}|>\d{4}|<\d{4})!', '', $s);
556 $t = preg_replace('![<>\- ]!', '', $t);
557 if (strlen($t) > 4) {
558 $conds->addChild(new UFC_Phone($t));
566 // {{{ class UFBF_Name
567 class UFBF_Name
extends UFBF_Text
569 protected function check(UserFilterBuilder
&$ufb)
571 if (!parent
::check($ufb)) {
575 $this->val
= preg_split('/[[:space:]]/', $this->val
);
576 if (count($this->val
) == 0) {
582 protected function buildUFC(UserFilterBuilder
&$ufb)
584 return new UFC_NameTokens($this->val
, array(), $ufb->b('with_soundex'), $ufb->b('exact'));
589 // {{{ class UFBF_Promo
590 class UFBF_Promo
extends UFB_Field
592 private static $validcomps = array('<', '<=', '=', '>=', '>');
594 private $envfieldcomp;
596 public function __construct($envfield, $fromtext = '', $envfieldcomp)
598 parent
::__construct($envfield, $fromtext);
599 $this->envfieldcomp
= $envfieldcomp;
602 protected function check(UserFilterBuilder
&$ufb)
604 if ($ufb->blank($this->envfield
) ||
$ufb->blank($this->envfieldcomp
)) {
609 $this->val
= $ufb->i($this->envfield
);
610 $this->comp
= $ufb->v($this->envfieldcomp
);
612 if (!in_array($this->comp
, self
::$validcomps)) {
613 return $this->raise("Le critère {$this->comp} n'est pas valide pour le champ %s");
616 if (preg_match('/^[0-9]{2}$/', $this->val
)) {
619 if ($this->val
< 1900 ||
$this->val
> 9999) {
620 return $this->raise("Le champ %s doit Ăªtre une annĂ©e Ă 4 chiffres.");
625 protected function buildUFC(UserFilterBuilder
&$ufb) {
626 return new UFC_Promo($this->comp
, UserFilter
::GRADE_ING
, $this->val
);
631 // {{{ class UFBF_Sex
632 class UFBF_Sex
extends UFBF_Enum
634 public function __construct($envfield, $formtext = '')
636 parent
::__construct($envfield, $formtext, array(1, 2));
639 private static function getVal($id)
643 return User
::GENDER_MALE
;
646 return User
::GENDER_FEMALE
;
651 protected function buildUFC(UserFilterBuilder
&$ufb)
653 return new UFC_Sex(self
::getVal($this->val
));
658 // {{{ class UFBF_Registered
659 class UFBF_Registered
extends UFBF_Enum
661 public function __construct($envfield, $formtext = '')
663 parent
::__construct($envfield, $formtext, array(1, 2));
666 protected function buildUFC(UserFilterBuilder
&$ufb)
668 if ($this->val
== 1) {
669 return new UFC_Registered();
670 } else if ($this->val
== 2) {
671 return new PFC_Not(new UFC_Registered());
677 // {{{ class UFBF_Dead
678 class UFBF_Dead
extends UFBF_Enum
680 public function __construct($envfield, $formtext = '')
682 parent
::__construct($envfield, $formtext, array(1, 2));
685 protected function buildUFC(UserFilterBuilder
&$ufb)
687 if ($this->val
== 1) {
688 return new PFC_Not(new UFC_Dead());
689 } else if ($this->val
== 2) {
690 return new UFC_Dead();
696 // {{{ class UFBF_Town
697 /** Retrieves a town, either from a postal code or a town name
699 class UFBF_Town
extends UFBF_Text
706 private $onlycurrentfield;
708 public function __construct($envfield, $formtext = '', $type = self
::TYPE_ANY
, $onlycurrentfield = 'only_current')
711 $this->onlycurrentfield
= $onlycurrentfield;
712 parent
::__construct($envfield, $formtext, 2, 30);
715 protected function buildUFC(UserFilterBuilder
&$ufb)
717 if ($ufb->isOn($this->onlycurrentfield
)) {
718 $flags = UFC_Address
::FLAG_CURRENT
;
720 $flags = UFC_Address
::FLAG_ANY
;
723 if (preg_match('/[0-9]/', $this->val
)) {
724 if ($this->type
& self
::TYPE_ZIP
) {
725 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ZIPCODE
, UFC_Address
::TYPE_ANY
, $flags);
727 return new PFC_False();
730 $byname = new UFC_AddressText(null
, XDB
::WILDCARD_CONTAINS
, UFC_Address
::TYPE_ANY
, $flags, null
, $this->val
);
731 $byzip = new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ZIPCODE
, UFC_Address
::TYPE_ANY
, $flags);
732 if ($this->type
& self
::TYPE_ANY
) {
733 return new PFC_Or($byname, $byzip);
734 } else if ($this->type
& self
::TYPE_TEXT
) {
744 // {{{ class UFBF_Country
745 class UFBF_Country
extends UFBF_Mixed
747 protected $direnum = DirEnum
::COUNTRIES
;
748 protected $onlycurrentfield;
750 public function __construct($envfieldtext, $envfieldindex, $formtext = '', $onlycurrentfield = 'only_current')
752 parent
::__construct($envfieldtext, $envfieldindex, $formtext);
753 $this->onlycurrentfield
= $onlycurrentfield;
756 protected function buildUFC(UserFilterBuilder
&$ufb)
758 if ($ufb->isOn($this->onlycurrentfield
)) {
759 $flags = UFC_Address
::FLAG_CURRENT
;
761 $flags = UFC_Address
::FLAG_ANY
;
764 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_COUNTRY
, UFC_Address
::TYPE_ANY
, $flags);
769 // {{{ class UFBF_AdminArea
770 class UFBF_AdminArea
extends UFBF_Index
772 protected $direnum = DirEnum
::ADMINAREAS
;
773 protected $onlycurrentfield;
775 public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current')
777 parent
::__construct($envfield, $formtext);
778 $this->onlycurrentfield
= $onlycurrentfield;
782 protected function buildUFC(UserFilterBuilder
&$ufb)
784 if ($ufb->isOn($this->onlycurrentfield
)) {
785 $flags = UFC_Address
::FLAG_CURRENT
;
787 $flags = UFC_Address
::FLAG_ANY
;
790 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ADMAREA
, UFC_Address
::TYPE_ANY
, $flags);
795 // {{{ class UFBF_JobCompany
796 class UFBF_JobCompany
extends UFBF_Text
798 private $onlymentorfield;
800 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
802 parent
::__construct($envfield, $formtext);
803 $this->onlymentorfield
= $onlymentorfield;
806 public function check(UserFilterBuilder
&$ufb) {
807 if (parent
::check($ufb)) {
808 # No company check for mentors
809 if ($ufb->isOn($this->onlymentorfield
)) {
818 protected function buildUFC(UserFilterBuilder
&$ufb)
820 return new UFC_Job_Company(UFC_Job_Company
::JOBNAME
, $this->val
);
825 // {{{ class UFBF_JobTerms
826 class UFBF_JobTerms
extends UFBF_Index
828 protected function buildUFC(UserFilterBuilder
&$ufb)
830 return new UFC_Job_Terms($this->val
);
835 // {{{ class UFBF_JobDescription
836 class UFBF_JobDescription
extends UFBF_Text
838 private $onlymentorfield;
840 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
842 parent
::__construct($envfield, $formtext);
843 $this->onlymentorfield
= $onlymentorfield;
846 protected function buildUFC(UserFilterBuilder
&$ufb)
848 if ($ufb->isOn($this->onlymentorfield
)) {
849 return new UFC_Mentor_Expertise($this->val
);
851 return new UFC_Job_Description($this->val
, UserFilter
::JOB_USERDEFINED
);
857 // {{{ class UFBF_JobCv
858 class UFBF_JobCv
extends UFBF_Text
860 private $onlymentorfield;
862 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
864 parent
::__construct($envfield, $formtext);
865 $this->onlymentorfield
= $onlymentorfield;
868 protected function buildUFC(UserFilterBuilder
&$ufb)
870 if ($ufb->isOn($this->onlymentorfield
)) {
871 return new UFC_Mentor_Expertise($this->val
);
873 return new UFC_Job_Description($this->val
, UserFilter
::JOB_CV
);
879 // {{{ class UFBF_Nationality
880 class UFBF_Nationality
extends UFBF_Mixed
882 protected $direnum = DirEnum
::NATIONALITIES
;
884 protected function buildUFC(UserFilterBuilder
&$ufb)
886 return new UFC_Nationality($this->val
);
891 // {{{ class UFBF_Binet
892 class UFBF_Binet
extends UFBF_Mixed
894 protected $direnum = DirEnum
::BINETS
;
896 protected function buildUFC(UserFilterBuilder
&$ufb)
898 return new UFC_Binet($this->val
);
903 // {{{ class UFBF_Group
904 class UFBF_Group
extends UFBF_Mixed
906 protected $direnum = DirEnum
::GROUPESX
;
908 protected function buildUFC(UserFilterBuilder
&$ufb)
910 if (count($this->val
) == 1) {
911 return new UFC_Group($this->val
[0]);
915 foreach ($this->val
as $grp) {
916 $or->addChild(new UFC_Group($grp));
923 // {{{ class UFBF_Section
924 class UFBF_Section
extends UFBF_Mixed
926 protected $direnum = DirEnum
::SECTIONS
;
928 protected function buildUFC(UserFilterBuilder
&$ufb)
930 return new UFC_Section($this->val
);
935 // {{{ class UFBF_EducationSchool
936 class UFBF_EducationSchool
extends UFBF_Mixed
938 protected $direnum = DirEnum
::EDUSCHOOLS
;
940 protected function buildUFC(UserFilterBuilder
&$ufb)
942 return new UFC_EducationSchool($this->val
);
947 // {{{ class UFBF_EducationDegree
948 class UFBF_EducationDegree
extends UFBF_Mixed
950 protected $direnum = DirEnum
::EDUDEGREES
;
952 protected function buildUFC(UserFilterBuilder
&$ufb)
954 return new UFC_EducationDegree($this->val
);
959 // {{{ class UFBF_EducationField
960 class UFBF_EducationField
extends UFBF_Mixed
962 protected $direnum = DirEnum
::EDUFIELDS
;
964 protected function buildUFC(UserFilterBuilder
&$ufb)
966 return new UFC_EducationField($this->val
);
971 // {{{ class UFBF_Comment
972 class UFBF_Comment
extends UFBF_Text
974 protected function buildUFC(UserFilterBuilder
&$ufb)
976 return new UFC_Comment($this->val
);
981 // {{{ class UFBF_Phone
982 class UFBF_Phone
extends UFBF_Text
984 protected function buildUFC(UserFilterBuilder
&$ufb)
986 return new UFC_Phone($this->val
);
991 // {{{ class UFBF_Networking
992 class UFBF_Networking
extends UFBF_Text
994 private $networktypefield;
997 public function __construct($envfield, $networktypefield, $formtext = '')
999 parent
::__construct($envfield, $formtext);
1000 $this->networktypefield
= $networktypefield;
1003 public function check(UserFilterBuilder
&$ufb)
1005 if (parent
::check($ufb)) {
1006 $this->nwtype
= $ufb->i($this->networktypefield
);
1013 public function isEmpty()
1015 return parent
::isEmpty() ||
$this->nwtype
== 0;
1018 public function buildUFC(UserFilterBuilder
&$ufb)
1020 return new UFC_Networking($this->nwtype
, $this->val
);
1025 // {{{ class UFBF_Mentor
1026 class UFBF_Mentor
extends UFBF_Bool
1028 protected function buildUFC(UserFilterBuilder
&$ufb)
1030 return new UFC_Mentor();
1035 // {{{ class UFBF_MentorCountry
1036 class UFBF_MentorCountry
extends UFBF_Text
1038 protected function buildUFC(UserFilterBuilder
&$ufb)
1040 return new UFC_Mentor_Country($this->val
);
1045 // {{{ class UFBF_Mentorterm
1046 class UFBF_MentorTerm
extends UFBF_Index
1048 protected function buildUFC(UserFilterBuilder
&$ufb)
1050 return new UFC_Mentor_Terms($this->val
);
1055 // {{{ class UFBF_MentorExpertise
1056 class UFBF_MentorExpertise
extends UFBF_Text
1058 protected function buildUFC(UserFilterBuilder
&$ufb)
1060 return new UFC_Mentor_Expertise($this->val
);
1065 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: