2 /***************************************************************************
3 * Copyright (C) 2003-2011 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'),
169 new UFBF_NotRegistered('nonins', 'Non inscrits'),
171 parent
::__construct($fields, $envprefix);
176 // {{{ class UFB_AdvancedSearch
177 class UFB_AdvancedSearch
extends UserFilterBuilder
179 /** Create a UFB_AdvancedSearch.
180 * @param $include_admin Whether to include 'admin-only' fields
181 * @param $include_ax Whether to include 'ax-only' fields
182 * @param $envprefix Optional prefix for form field names.
184 public function __construct($include_admin = false
, $include_ax = false
, $envprefix = '')
187 new UFBF_Name('name', 'Nom'),
188 new UFBF_Promo('promo1', 'Promotion', 'egal1'),
189 new UFBF_Promo('promo2', 'Promotion', 'egal2'),
190 new UFBF_Sex('woman', 'Sexe'),
191 new UFBF_Registered('subscriber', 'Inscrit'),
192 new UFBF_Dead('alive', 'En vie'),
194 new UFBF_Town('city', 'Ville / Code Postal'),
195 new UFBF_Country('countryTxt', 'country', 'Pays'),
196 new UFBF_AdminArea('administrativearea', 'Région'),
197 new UFBF_SubAdminArea('subadministrativearea', 'Département'),
199 new UFBF_JobCompany('entreprise', 'Entreprise'),
200 new UFBF_JobDescription('jobdescription', 'Fonction'),
201 new UFBF_JobCv('cv', 'CV'),
202 new UFBF_JobTerms('jobterm', 'Mots-clefs'),
204 new UFBF_Nationality('nationaliteTxt', 'nationalite', 'Nationalité'),
205 new UFBF_Binet('binetTxt', 'binet', 'Binet'),
206 new UFBF_Group('groupexTxt', 'groupex', 'Groupe X'),
207 new UFBF_Section('sectionTxt', 'section', 'Section'),
209 new UFBF_EducationSchool('schoolTxt', 'school', "École d'application"),
210 new UFBF_EducationDegree('diplomaTxt', 'diploma', 'Diplôme'),
211 new UFBF_EducationField('fieldTxt', 'field', "Domaine d'études"),
213 new UFBF_Comment('free', 'Commentaire'),
214 new UFBF_Phone('phone_number', 'Téléphone'),
215 new UFBF_Networking('networking_address', 'networking_type', 'Networking et sites webs'),
217 new UFBF_Mentor('only_referent', 'Référent'),
220 if ($include_admin ||
$include_ax) {
221 $fields[] = new UFBF_SchoolIds('schoolid_ax', 'Matricule AX', UFC_SchoolId
::AX
);
224 parent
::__construct($fields, $envprefix);
229 // {{{ class UFB_MentorSearch
230 class UFB_MentorSearch
extends UserFilterBuilder
232 public function __construct($envprefix = '')
235 new UFBF_MentorCountry('country'),
236 new UFBF_MentorTerm('jobterm', 'jobtermText'),
237 new UFBF_MentorExpertise('expertise'),
239 parent
::__construct($fields, $envprefix);
244 // {{{ class UFB_Field
245 abstract class UFB_Field
250 protected $empty = false
;
251 protected $val = null
;
254 * @param $envfield Name of the field in the environment
255 * @param $formtext User-friendly name of that field
257 public function __construct($envfield, $formtext = '')
259 $this->envfield
= $envfield;
260 if ($formtext != '') {
261 $this->formtext
= $formtext;
263 $formtext = ucfirst($envfield);
267 /** Prints the given error message to the user, and returns false
268 * in order to be used as return $this->raise('ERROR');
270 * All %s in the $msg will be replaced with the formtext.
272 protected function raise($msg)
274 Platal
::page()->trigError(str_replace('%s', $this->formtext
, $msg));
278 public function apply(UserFilterBuilder
&$ufb) {
279 if (!$this->check($ufb)) {
283 if (!$this->isEmpty()) {
284 $ufc = $this->buildUFC($ufb);
292 public function isEmpty()
297 /** Create the UFC associated to the field; won't be called
298 * if the field is "empty"
299 * @param &$ufb UFB to which fields must be added
302 abstract protected function buildUFC(UserFilterBuilder
&$ufb);
304 /** This function is intended to run consistency checks on the value
305 * @return boolean Whether the input is valid
307 abstract protected function check(UserFilterBuilder
&$ufb);
311 // {{{ class UFBF_Text
312 abstract class UFBF_Text
extends UFB_Field
317 public function __construct($envfield, $formtext = '', $minlength = 2, $maxlength = 255)
319 parent
::__construct($envfield, $formtext);
320 $this->minlength
= $minlength;
321 $this->maxlength
= $maxlength;
324 protected function check(UserFilterBuilder
&$ufb)
326 if ($ufb->blank($this->envfield
)) {
331 $this->val
= $ufb->t($this->envfield
);
332 if (strlen($this->val
) < $this->minlength
) {
333 return $this->raise("Le champ %s est trop court (minimum {$this->minlength}).");
334 } else if (strlen($this->val
) > $this->maxlength
) {
335 return $this->raise("Le champ %s est trop long (maximum {$this->maxlength}).");
336 } else if (preg_match(":[\]\[<>{}~§_`|%$^=]|\*\*:u", $this->val
)) {
337 return $this->raise('Le champ %s contient un caractère interdit rendant la recherche impossible.');
345 // {{{ class UFBF_Range
346 /** Subclass to use for fields which only allow integers within a range
348 abstract class UFBF_Range
extends UFB_Field
354 public function __construct($envfield, $formtext = '', $min = 0, $max = 65535)
356 parent
::__construct($envfield, $formtext);
361 protected function check(UserFilterBuilder
&$ufb)
363 if ($ufb->blank($this->envfield
)) {
368 $this->val
= $ufb->i($this->envfield
);
369 if ($this->val
< $this->min
) {
370 return $this->raise("Le champs %s est inférieur au minimum ({$this->min}).");
371 } else if ($this->val
> $this->max
) {
372 return $this->raise("Le champ %s est supérieur au maximum ({$this->max}).");
379 // {{{ class UFBF_Index
380 /** Subclass to use for indexed fields
382 abstract class UFBF_Index
extends UFB_Field
384 protected function check(UserFilterBuilder
&$ufb)
386 if ($ufb->blank($this->envfield
)) {
389 $this->val
= $ufb->i($this->envfield
);
395 // {{{ class UFBF_Enum
396 /** Subclass to use for fields whose value must belong to a specific set of values
398 abstract class UFBF_Enum
extends UFB_Field
400 protected $allowedvalues;
402 public function __construct($envfield, $formtext = '', $allowedvalues = array(), $strict = false
)
404 parent
::__construct($envfield, $formtext);
405 $this->allowedvalues
= $allowedvalues;
406 $this->strict
= $strict;
409 protected function check(UserFilterBuilder
&$ufb)
411 if ($ufb->blank($this->envfield
)) {
416 $this->val
= $ufb->v($this->envfield
);
417 if (! in_array($this->val
, $this->allowedvalues
)) {
419 return $this->raise("La valeur {$this->val} n'est pas valide pour le champ %s.");
429 // {{{ class UFBF_Bool
430 abstract class UFBF_Bool
extends UFB_Field
432 protected function check(UserFilterBuilder
&$ufb)
434 if ($ufb->blank($this->envfield
)) {
439 $this->val
= $ufb->b($this->envfield
);
445 // {{{ class UFBF_Mixed
446 /** A class for building UFBFs when the user can input either a text or an ID
448 abstract class UFBF_Mixed
extends UFB_Field
450 /** Name of the DirEnum on which class is based
454 protected $envfieldindex;
456 public function __construct($envfieldtext, $envfieldindex, $formtext = '')
458 parent
::__construct($envfieldtext, $formtext);
459 $this->envfieldindex
= $envfieldindex;
462 protected function check(UserFilterBuilder
&$ufb)
464 if ($ufb->blank($this->envfieldindex
) && !$ufb->hasAlnum($this->envfield
)) {
469 if (!$ufb->blank($this->envfieldindex
)) {
470 $index = $ufb->v($this->envfieldindex
);
471 if (is_int($index)) {
472 $index = intval($index);
474 $index = strtoupper($index);
476 $this->val
= array($index);
478 $indexes = DirEnum
::getIDs($this->direnum
, $ufb->t($this->envfield
),
479 $ufb->b('exact') ? XDB
::WILDCARD_EXACT
: XDB
::WILDCARD_CONTAINS
);
480 if (count($indexes) == 0) {
483 $this->val
= $indexes;
490 // {{{ class UFBF_Quick
491 class UFBF_Quick
extends UFB_Field
493 protected function check(UserFilterBuilder
&$ufb)
495 if ($ufb->blank($this->envfield
)) {
500 $this->val
= str_replace('*', '%', replace_accent($ufb->t($this->envfield
)));
505 protected function buildUFC(UserFilterBuilder
&$ufb)
508 $r = $s = $this->val
;
512 if (S
::admin() && strpos($s, '@') !== false
) {
513 return new UFC_Email($s);
514 } else if (S
::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
515 return new UFC_Ip($s);
518 $conds = new PFC_And();
522 $s = preg_replace('!\d+!', ' ', $s);
523 $strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY
);
524 if (count($strings) > 5) {
525 Platal
::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
526 $strings = array_slice($strings, 0, 5);
529 if (count($strings)) {
533 $flags = array('public');
535 $exact =$ufb->b('exact');
536 $conds->addChild(new UFC_NameTokens($strings, $flags, $ufb->b('with_soundex'), $exact));
538 $ufb->addOrder(new UFO_Score());
543 $s = preg_replace('! *- *!', '-', $r);
544 $s = preg_replace('!([<>]) *!', ' \1', $s);
545 $s = preg_replace('![^0-9\-><]!', ' ', $s);
546 $s = preg_replace('![<>\-] !', '', $s);
547 $ranges = preg_split('! +!', $s, -1, PREG_SPLIT_NO_EMPTY
);
548 foreach ($ranges as $r) {
549 if (preg_match('!^\d{4}$!', $r)) {
550 $conds->addChild(new UFC_Promo('=', UserFilter
::DISPLAY
, 'X' . $r));
551 } elseif (preg_match('!^(\d{4})-(\d{4})$!', $r, $matches)) {
552 $p1=min(intval($matches[1]), intval($matches[2]));
553 $p2=max(intval($matches[1]), intval($matches[2]));
554 $conds->addChild(new PFC_And(
555 new UFC_Promo('>=', UserFilter
::DISPLAY
, 'X' . $p1),
556 new UFC_Promo('<=', UserFilter
::DISPLAY
, 'X' . $p2)
558 } elseif (preg_match('!^<(\d{4})!', $r, $matches)) {
559 $conds->addChild(new UFC_Promo('<=', UserFilter
::DISPLAY
, 'X' . $matches[1]));
560 } elseif (preg_match('!^>(\d{4})!', $r, $matches)) {
561 $conds->addChild(new UFC_Promo('>=', UserFilter
::DISPLAY
, 'X' . $matches[1]));
567 $t = preg_replace('!(\d{4}-\d{4}|>\d{4}|<\d{4})!', '', $s);
568 $t = preg_replace('![<>\- ]!', '', $t);
569 if (strlen($t) > 4) {
570 $conds->addChild(new UFC_Phone($t));
578 // {{{ class UFBF_SchoolIds
579 class UFBF_SchoolIds
extends UFB_Field
581 // One of UFC_SchoolId types
584 public function __construct($envfield, $formtext, $type = UFC_SchoolId
::AX
)
586 parent
::__construct($envfield, $formtext);
590 protected function check(UserFilterBuilder
&$ufb)
592 if ($ufb->blank($this->envfield
)) {
597 $value = $ufb->t($this->envfield
);
598 $values = explode("\n", $value);
600 foreach ($values as $val) {
601 if (preg_match('/^[0-9A-Z]{0,8}$/', $val)) {
605 if (count($ids) == 0) {
606 return $this->raise("Le champ %s ne contient aucune valeur valide.");
613 protected function buildUFC(UserFilterBuilder
&$ufb)
615 return new UFC_SchoolId($this->type
, $this->val
);
620 // {{{ class UFBF_Name
621 class UFBF_Name
extends UFBF_Text
623 protected function check(UserFilterBuilder
&$ufb)
625 if (!parent
::check($ufb)) {
629 $this->val
= preg_split('/[[:space:]]/', $this->val
);
630 if (count($this->val
) == 0) {
636 protected function buildUFC(UserFilterBuilder
&$ufb)
638 return new UFC_NameTokens($this->val
, array(), $ufb->b('with_soundex'), $ufb->b('exact'));
643 // {{{ class UFBF_Promo
644 class UFBF_Promo
extends UFB_Field
646 private static $validcomps = array('<', '<=', '=', '>=', '>');
648 private $envfieldcomp;
650 public function __construct($envfield, $fromtext = '', $envfieldcomp)
652 parent
::__construct($envfield, $fromtext);
653 $this->envfieldcomp
= $envfieldcomp;
656 protected function check(UserFilterBuilder
&$ufb)
658 if ($ufb->blank($this->envfield
) ||
$ufb->blank($this->envfieldcomp
)) {
663 $this->val
= $ufb->i($this->envfield
);
664 $this->comp
= $ufb->v($this->envfieldcomp
);
666 if (!in_array($this->comp
, self
::$validcomps)) {
667 return $this->raise("Le critère {$this->comp} n'est pas valide pour le champ %s");
670 if (preg_match('/^[0-9]{2}$/', $this->val
)) {
673 if ($this->val
< 1900 ||
$this->val
> 9999) {
674 return $this->raise("Le champ %s doit être une année à 4 chiffres.");
679 protected function buildUFC(UserFilterBuilder
&$ufb) {
680 return new UFC_Promo($this->comp
, UserFilter
::GRADE_ING
, $this->val
);
685 // {{{ class UFBF_Sex
686 class UFBF_Sex
extends UFBF_Enum
688 public function __construct($envfield, $formtext = '')
690 parent
::__construct($envfield, $formtext, array(1, 2));
693 private static function getVal($id)
697 return User
::GENDER_MALE
;
700 return User
::GENDER_FEMALE
;
705 protected function buildUFC(UserFilterBuilder
&$ufb)
707 return new UFC_Sex(self
::getVal($this->val
));
712 // {{{ class UFBF_NotRegistered
713 // Simple field for selecting only alive, not registered users (for quick search)
714 class UFBF_NotRegistered
extends UFBF_Bool
716 protected function buildUFC(UserFilterBuilder
&$ufb)
720 new PFC_Not(new UFC_Dead()),
721 new PFC_Not(new UFC_Registered())
728 // {{{ class UFBF_Registered
729 class UFBF_Registered
extends UFBF_Enum
731 public function __construct($envfield, $formtext = '')
733 parent
::__construct($envfield, $formtext, array(1, 2));
736 protected function buildUFC(UserFilterBuilder
&$ufb)
738 if ($this->val
== 1) {
739 return new UFC_Registered();
740 } else if ($this->val
== 2) {
741 return new PFC_Not(new UFC_Registered());
747 // {{{ class UFBF_Dead
748 class UFBF_Dead
extends UFBF_Enum
750 public function __construct($envfield, $formtext = '')
752 parent
::__construct($envfield, $formtext, array(1, 2));
755 protected function buildUFC(UserFilterBuilder
&$ufb)
757 if ($this->val
== 1) {
758 return new PFC_Not(new UFC_Dead());
759 } else if ($this->val
== 2) {
760 return new UFC_Dead();
766 // {{{ class UFBF_Town
767 /** Retrieves a town, either from a postal code or a town name
769 class UFBF_Town
extends UFBF_Text
776 private $onlycurrentfield;
778 public function __construct($envfield, $formtext = '', $type = self
::TYPE_ANY
, $onlycurrentfield = 'only_current')
781 $this->onlycurrentfield
= $onlycurrentfield;
782 parent
::__construct($envfield, $formtext, 2, 30);
785 protected function buildUFC(UserFilterBuilder
&$ufb)
787 if ($ufb->isOn($this->onlycurrentfield
)) {
788 $flags = UFC_Address
::FLAG_CURRENT
;
790 $flags = UFC_Address
::FLAG_ANY
;
793 if (preg_match('/[0-9]/', $this->val
)) {
794 if ($this->type
& self
::TYPE_ZIP
) {
795 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ZIPCODE
, UFC_Address
::TYPE_ANY
, $flags);
797 return new PFC_False();
800 $byname = new UFC_AddressText(null
, XDB
::WILDCARD_CONTAINS
, UFC_Address
::TYPE_ANY
, $flags, null
, $this->val
);
801 $byzip = new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ZIPCODE
, UFC_Address
::TYPE_ANY
, $flags);
802 if ($this->type
& self
::TYPE_ANY
) {
803 return new PFC_Or($byname, $byzip);
804 } else if ($this->type
& self
::TYPE_TEXT
) {
814 // {{{ class UFBF_Country
815 class UFBF_Country
extends UFBF_Mixed
817 protected $direnum = DirEnum
::COUNTRIES
;
818 protected $onlycurrentfield;
820 public function __construct($envfieldtext, $envfieldindex, $formtext = '', $onlycurrentfield = 'only_current')
822 parent
::__construct($envfieldtext, $envfieldindex, $formtext);
823 $this->onlycurrentfield
= $onlycurrentfield;
826 protected function buildUFC(UserFilterBuilder
&$ufb)
828 if ($ufb->isOn($this->onlycurrentfield
)) {
829 $flags = UFC_Address
::FLAG_CURRENT
;
831 $flags = UFC_Address
::FLAG_ANY
;
834 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_COUNTRY
, UFC_Address
::TYPE_ANY
, $flags);
839 // {{{ class UFBF_AdminArea
840 class UFBF_AdminArea
extends UFBF_Index
842 protected $direnum = DirEnum
::ADMINAREAS
;
843 protected $onlycurrentfield;
845 public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current')
847 parent
::__construct($envfield, $formtext);
848 $this->onlycurrentfield
= $onlycurrentfield;
852 protected function buildUFC(UserFilterBuilder
&$ufb)
854 if ($ufb->isOn($this->onlycurrentfield
)) {
855 $flags = UFC_Address
::FLAG_CURRENT
;
857 $flags = UFC_Address
::FLAG_ANY
;
860 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_ADMAREA
, UFC_Address
::TYPE_ANY
, $flags);
865 // {{{ class UFBF_SubAdminArea
866 class UFBF_SubAdminArea
extends UFBF_Index
868 protected $direnum = DirEnum
::SUBADMINAREAS
;
869 protected $onlycurrentfield;
871 public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current')
873 parent
::__construct($envfield, $formtext);
874 $this->onlycurrentfield
= $onlycurrentfield;
878 protected function buildUFC(UserFilterBuilder
&$ufb)
880 if ($ufb->isOn($this->onlycurrentfield
)) {
881 $flags = UFC_Address
::FLAG_CURRENT
;
883 $flags = UFC_Address
::FLAG_ANY
;
886 return new UFC_AddressField($this->val
, UFC_AddressField
::FIELD_SUBADMAREA
, UFC_Address
::TYPE_ANY
, $flags);
891 // {{{ class UFBF_JobCompany
892 class UFBF_JobCompany
extends UFBF_Text
894 private $onlymentorfield;
896 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
898 parent
::__construct($envfield, $formtext);
899 $this->onlymentorfield
= $onlymentorfield;
902 public function check(UserFilterBuilder
&$ufb) {
903 if (parent
::check($ufb)) {
904 # No company check for mentors
905 if ($ufb->isOn($this->onlymentorfield
)) {
914 protected function buildUFC(UserFilterBuilder
&$ufb)
916 return new UFC_Job_Company(UFC_Job_Company
::JOBNAME
, $this->val
);
921 // {{{ class UFBF_JobTerms
922 class UFBF_JobTerms
extends UFBF_Index
924 protected function buildUFC(UserFilterBuilder
&$ufb)
926 return new UFC_Job_Terms($this->val
);
931 // {{{ class UFBF_JobDescription
932 class UFBF_JobDescription
extends UFBF_Text
934 private $onlymentorfield;
936 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
938 parent
::__construct($envfield, $formtext);
939 $this->onlymentorfield
= $onlymentorfield;
942 protected function buildUFC(UserFilterBuilder
&$ufb)
944 if ($ufb->isOn($this->onlymentorfield
)) {
945 return new UFC_Mentor_Expertise($this->val
);
947 return new UFC_Job_Description($this->val
, UserFilter
::JOB_USERDEFINED
);
953 // {{{ class UFBF_JobCv
954 class UFBF_JobCv
extends UFBF_Text
956 private $onlymentorfield;
958 public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent')
960 parent
::__construct($envfield, $formtext);
961 $this->onlymentorfield
= $onlymentorfield;
964 protected function buildUFC(UserFilterBuilder
&$ufb)
966 if ($ufb->isOn($this->onlymentorfield
)) {
967 return new UFC_Mentor_Expertise($this->val
);
969 return new UFC_Job_Description($this->val
, UserFilter
::JOB_CV
);
975 // {{{ class UFBF_Nationality
976 class UFBF_Nationality
extends UFBF_Mixed
978 protected $direnum = DirEnum
::NATIONALITIES
;
980 protected function buildUFC(UserFilterBuilder
&$ufb)
982 return new UFC_Nationality($this->val
);
987 // {{{ class UFBF_Binet
988 class UFBF_Binet
extends UFBF_Mixed
990 protected $direnum = DirEnum
::BINETS
;
992 protected function buildUFC(UserFilterBuilder
&$ufb)
994 return new UFC_Binet($this->val
);
999 // {{{ class UFBF_Group
1000 class UFBF_Group
extends UFBF_Mixed
1002 protected $direnum = DirEnum
::GROUPESX
;
1004 protected function buildUFC(UserFilterBuilder
&$ufb)
1006 if (count($this->val
) == 1) {
1007 return new UFC_Group($this->val
[0]);
1011 foreach ($this->val
as $grp) {
1012 $or->addChild(new UFC_Group($grp));
1019 // {{{ class UFBF_Section
1020 class UFBF_Section
extends UFBF_Mixed
1022 protected $direnum = DirEnum
::SECTIONS
;
1024 protected function buildUFC(UserFilterBuilder
&$ufb)
1026 return new UFC_Section($this->val
);
1031 // {{{ class UFBF_EducationSchool
1032 class UFBF_EducationSchool
extends UFBF_Mixed
1034 protected $direnum = DirEnum
::EDUSCHOOLS
;
1036 protected function buildUFC(UserFilterBuilder
&$ufb)
1038 return new UFC_EducationSchool($this->val
);
1043 // {{{ class UFBF_EducationDegree
1044 class UFBF_EducationDegree
extends UFBF_Mixed
1046 protected $direnum = DirEnum
::EDUDEGREES
;
1048 protected function buildUFC(UserFilterBuilder
&$ufb)
1050 return new UFC_EducationDegree($this->val
);
1055 // {{{ class UFBF_EducationField
1056 class UFBF_EducationField
extends UFBF_Mixed
1058 protected $direnum = DirEnum
::EDUFIELDS
;
1060 protected function buildUFC(UserFilterBuilder
&$ufb)
1062 return new UFC_EducationField($this->val
);
1067 // {{{ class UFBF_Comment
1068 class UFBF_Comment
extends UFBF_Text
1070 protected function buildUFC(UserFilterBuilder
&$ufb)
1072 return new UFC_Comment($this->val
);
1077 // {{{ class UFBF_Phone
1078 class UFBF_Phone
extends UFBF_Text
1080 protected function buildUFC(UserFilterBuilder
&$ufb)
1082 return new UFC_Phone($this->val
);
1087 // {{{ class UFBF_Networking
1088 class UFBF_Networking
extends UFBF_Text
1090 private $networktypefield;
1093 public function __construct($envfield, $networktypefield, $formtext = '')
1095 parent
::__construct($envfield, $formtext);
1096 $this->networktypefield
= $networktypefield;
1099 public function check(UserFilterBuilder
&$ufb)
1101 if (parent
::check($ufb)) {
1102 $this->nwtype
= $ufb->i($this->networktypefield
);
1109 public function isEmpty()
1111 return parent
::isEmpty() ||
$this->nwtype
== 0;
1114 public function buildUFC(UserFilterBuilder
&$ufb)
1116 return new UFC_Networking($this->nwtype
, $this->val
);
1121 // {{{ class UFBF_Mentor
1122 class UFBF_Mentor
extends UFBF_Bool
1124 protected function buildUFC(UserFilterBuilder
&$ufb)
1126 return new UFC_Mentor();
1131 // {{{ class UFBF_MentorCountry
1132 class UFBF_MentorCountry
extends UFBF_Text
1134 protected function buildUFC(UserFilterBuilder
&$ufb)
1136 return new UFC_Mentor_Country($this->val
);
1141 // {{{ class UFBF_Mentorterm
1142 class UFBF_MentorTerm
extends UFBF_Index
1144 protected function buildUFC(UserFilterBuilder
&$ufb)
1146 return new UFC_Mentor_Terms($this->val
);
1151 // {{{ class UFBF_MentorExpertise
1152 class UFBF_MentorExpertise
extends UFBF_Text
1154 protected function buildUFC(UserFilterBuilder
&$ufb)
1156 return new UFC_Mentor_Expertise($this->val
);
1161 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: