X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fufbuilder.inc.php;h=5785ea7783356e409b03083481cff38a71687943;hb=3ccb060db98c00b4de687f0d262132e89293103c;hp=e329bbc24d207c46b0385d43ad0908833ec1b0e0;hpb=5600b2feb94fb836d9d0359d74ab8d6f729908c0;p=platal.git diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index e329bbc..5785ea7 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -347,10 +347,12 @@ class UFB_AdvancedSearch extends UserFilterBuilder new UFBF_HasEmailRedirect('has_email_redirect', 'A une redirection active'), new UFBF_Dead('alive', 'En vie'), - new UFBF_Town('city', 'Ville / Code Postal'), - new UFBF_Country('countryTxt', 'country', 'Pays'), - new UFBF_AdminArea('administrativearea', 'Région'), - new UFBF_SubAdminArea('subadministrativearea', 'Département'), + new UFBF_AddressIndex('postal_code', 'Code postal', 'POSTALCODES'), + new UFBF_AddressIndex('administrative_area_level_3', 'Canton', 'ADMNISTRATIVEAREAS3'), + new UFBF_AddressIndex('administrative_area_level_2', 'Département', 'ADMNISTRATIVEAREAS2'), + new UFBF_AddressIndex('administrative_area_level_1', 'Région', 'ADMNISTRATIVEAREAS1'), + new UFBF_AddressMixed('locality_text', 'locality', 'Ville', 'LOCALITIES'), + new UFBF_AddressMixed('country_text', 'country', 'Pays', 'COUNTRIES'), new UFBF_JobCompany('entreprise', 'Entreprise'), new UFBF_JobDescription('jobdescription', 'Fonction'), @@ -361,14 +363,14 @@ class UFB_AdvancedSearch extends UserFilterBuilder new UFBF_CurrentCorps('current_corps', 'Corps actuel'), new UFBF_CorpsRank('corps_rank', 'Grade'), - new UFBF_Nationality('nationaliteTxt', 'nationalite', 'Nationalité'), - new UFBF_Binet('binetTxt', 'binet', 'Binet'), - new UFBF_Group('groupexTxt', 'groupex', 'Groupe X'), - new UFBF_Section('sectionTxt', 'section', 'Section'), + new UFBF_Nationality('nationalite_text', 'nationalite', 'Nationalité'), + new UFBF_Binet('binet_text', 'binet', 'Binet'), + new UFBF_Group('groupex_text', 'groupex', 'Groupe X'), + new UFBF_Section('section_text', 'section', 'Section'), - new UFBF_EducationSchool('schoolTxt', 'school', "École d'application"), - new UFBF_EducationDegree('diplomaTxt', 'diploma', 'Diplôme'), - new UFBF_EducationField('fieldTxt', 'field', "Domaine d'études"), + new UFBF_EducationSchool('school_text', 'school', "École d'application"), + new UFBF_EducationDegree('diploma_text', 'diploma', 'Diplôme'), + new UFBF_EducationField('field_text', 'field', "Domaine d'études"), new UFBF_Comment('free', 'Commentaire'), new UFBF_Phone('phone_number', 'Téléphone'), @@ -401,6 +403,38 @@ class UFB_MentorSearch extends UserFilterBuilder } // }}} +// {{{ class UFB_DeltaTenSearch +class UFB_DeltaTenSearch extends UserFilterBuilder +{ + public function __construct($envprefix = '') + { + $fields = array( + new UFBF_DeltaTenMessage('deltaten_message'), + + new UFBF_AddressIndex('administrative_area_level_2', 'Département', 'ADMNISTRATIVEAREAS2'), + new UFBF_AddressIndex('administrative_area_level_1', 'Région', 'ADMNISTRATIVEAREAS1'), + new UFBF_AddressMixed('locality_text', 'locality', 'Ville', 'LOCALITIES'), + new UFBF_AddressMixed('country_text', 'country', 'Pays', 'COUNTRIES'), + + new UFBF_EducationSchool('schoolTxt', 'school', "École d'application"), + new UFBF_EducationDegree('diplomaTxt', 'diploma', 'Diplôme'), + new UFBF_EducationField('fieldTxt', 'field', "Domaine d'études"), + + new UFBF_JobCompany('entreprise', 'Entreprise'), + new UFBF_JobDescription('jobdescription', 'Fonction'), + new UFBF_JobTerms('jobterm', 'Mots-clefs'), + + new UFBF_Nationality('nationaliteTxt', 'nationalite', 'Nationalité'), + new UFBF_Binet('binetTxt', 'binet', 'Binet'), + new UFBF_Group('groupexTxt', 'groupex', 'Groupe X'), + new UFBF_Section('sectionTxt', 'section', 'Section'), + new UFBF_Sex('woman', 'Sexe'), + ); + parent::__construct($fields, $envprefix); + } +} +// }}} + // {{{ class UFB_NewsLetter class UFB_NewsLetter extends UserFilterBuilder { @@ -412,8 +446,8 @@ class UFB_NewsLetter extends UserFilterBuilder { $fields = array(); if ($flags->hasFlag(self::FIELDS_PROMO)) { - $fields[] = new UFBF_Promo('promo1', 'Promotion', 'egal1'); - $fields[] = new UFBF_Promo('promo2', 'Promotion', 'egal2'); + $fields[] = new UFBF_Promo('promo1', 'Promotion', 'egal1', 'edu_type'); + $fields[] = new UFBF_Promo('promo2', 'Promotion', 'egal2', 'edu_type'); } if ($flags->hasFlag(self::FIELDS_AXID)) { $fields[] = new UFBF_SchoolIds('axid', 'Matricule AX', UFC_SchoolId::AX); @@ -805,9 +839,10 @@ class UFBF_SchoolIds extends UFB_Field } $value = $ufb->t($this->envfield); - $values = explode("\r\n", $value); + $values = explode("\n", $value); $ids = array(); foreach ($values as $val) { + $val = trim($val); if (preg_match('/^[0-9A-Z]{0,8}$/', $val)) { $ids[] = $val; } @@ -1032,69 +1067,16 @@ class UFBF_Dead extends UFBF_Enum } // }}} -// {{{ class UFBF_Town -/** Retrieves a town, either from a postal code or a town name - */ -class UFBF_Town extends UFBF_Text +// {{{ class UFBF_AddressMixed +class UFBF_AddressMixed extends UFBF_Mixed { - const TYPE_TEXT = 1; - const TYPE_ZIP = 2; - const TYPE_ANY = 3; - - private $type; - private $onlycurrentfield; - - public function __construct($envfield, $formtext = '', $type = self::TYPE_ANY, $onlycurrentfield = 'only_current') - { - $this->type = $type; - $this->onlycurrentfield = $onlycurrentfield; - parent::__construct($envfield, $formtext, 2, 30); - } - - protected function buildUFC(UserFilterBuilder $ufb) - { - if ($ufb->isOn($this->onlycurrentfield)) { - $flags = UFC_Address::FLAG_CURRENT; - } else { - $flags = UFC_Address::FLAG_ANY; - } - - if (preg_match('/[0-9]/', $this->val)) { - if ($this->type & self::TYPE_ZIP) { - return new UFC_AddressField($this->val, UFC_AddressField::FIELD_ZIPCODE, UFC_Address::TYPE_ANY, $flags); - } else { - return new PFC_False(); - } - } else { - $byname = new UFC_AddressText(null, XDB::WILDCARD_CONTAINS, UFC_Address::TYPE_ANY, $flags, null, $this->val); - $byzip = new UFC_AddressField($this->val, UFC_AddressField::FIELD_ZIPCODE, UFC_Address::TYPE_ANY, $flags); - if ($this->type & self::TYPE_ANY) { - return new PFC_Or($byname, $byzip); - } else if ($this->type & self::TYPE_TEXT) { - return $byname; - } else { - return $byzip; - } - } - } - - public function getEnvFieldNames() - { - return array($this->envfield, $this->onlycurrentfield); - } -} -// }}} - -// {{{ class UFBF_Country -class UFBF_Country extends UFBF_Mixed -{ - protected $direnum = DirEnum::COUNTRIES; protected $onlycurrentfield; - public function __construct($envfieldtext, $envfieldindex, $formtext = '', $onlycurrentfield = 'only_current') + public function __construct($envfieldtext, $envfieldindex, $formtext = '', $addressfield, $onlycurrentfield = 'only_current') { parent::__construct($envfieldtext, $envfieldindex, $formtext); $this->onlycurrentfield = $onlycurrentfield; + $this->direnum = constant('DirEnum::' . $addressfield); } protected function buildUFC(UserFilterBuilder $ufb) @@ -1105,7 +1087,7 @@ class UFBF_Country extends UFBF_Mixed $flags = UFC_Address::FLAG_ANY; } - return new UFC_AddressField($this->val, UFC_AddressField::FIELD_COUNTRY, UFC_Address::TYPE_ANY, $flags); + return new UFC_AddressComponent($this->val, $this->envfieldindex, UFC_Address::TYPE_NON_HQ, $flags); } public function getEnvFieldNames() @@ -1115,47 +1097,17 @@ class UFBF_Country extends UFBF_Mixed } // }}} -// {{{ class UFBF_AdminArea -class UFBF_AdminArea extends UFBF_Index +// {{{ class UFBF_AddressIndex +class UFBF_AddressIndex extends UFBF_Index { - protected $direnum = DirEnum::ADMINAREAS; - protected $onlycurrentfield; - - public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current') - { - parent::__construct($envfield, $formtext); - $this->onlycurrentfield = $onlycurrentfield; - } - - - protected function buildUFC(UserFilterBuilder $ufb) - { - if ($ufb->isOn($this->onlycurrentfield)) { - $flags = UFC_Address::FLAG_CURRENT; - } else { - $flags = UFC_Address::FLAG_ANY; - } - - return new UFC_AddressField($this->val, UFC_AddressField::FIELD_ADMAREA, UFC_Address::TYPE_ANY, $flags); - } - - public function getEnvFieldNames() - { - return array($this->envfield, $this->onlycurrentfield); - } -} -// }}} - -// {{{ class UFBF_SubAdminArea -class UFBF_SubAdminArea extends UFBF_Index -{ - protected $direnum = DirEnum::SUBADMINAREAS; + protected $direnum; protected $onlycurrentfield; - public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current') + public function __construct($envfield, $formtext = '', $addressfield, $onlycurrentfield = 'only_current') { parent::__construct($envfield, $formtext); $this->onlycurrentfield = $onlycurrentfield; + $this->direnum = constant('DirEnum::' . $addressfield); } @@ -1167,7 +1119,7 @@ class UFBF_SubAdminArea extends UFBF_Index $flags = UFC_Address::FLAG_ANY; } - return new UFC_AddressField($this->val, UFC_AddressField::FIELD_SUBADMAREA, UFC_Address::TYPE_ANY, $flags); + return new UFC_AddressComponent($this->val, $this->envfield, UFC_Address::TYPE_NON_HQ, $flags); } public function getEnvFieldNames() @@ -1180,35 +1132,10 @@ class UFBF_SubAdminArea extends UFBF_Index // {{{ class UFBF_JobCompany class UFBF_JobCompany extends UFBF_Text { - private $onlymentorfield; - - public function __construct($envfield, $formtext = '', $onlymentorfield = 'only_referent') - { - parent::__construct($envfield, $formtext); - $this->onlymentorfield = $onlymentorfield; - } - - public function check(UserFilterBuilder $ufb) { - if (parent::check($ufb)) { - # No company check for mentors - if ($ufb->isOn($this->onlymentorfield)) { - $this->empty = true; - } - return true; - } else { - return false; - } - } - protected function buildUFC(UserFilterBuilder $ufb) { return new UFC_Job_Company(UFC_Job_Company::JOBNAME, $this->val); } - - public function getEnvFieldNames() - { - return array($this->envfield, $this->onlymentorfield); - } } // }}} @@ -1503,5 +1430,15 @@ class UFBF_MentorExpertise extends UFBF_Text } // }}} +// {{{ class UFBF_DeltaTenMessage +class UFBF_DeltaTenMessage extends UFBF_Text +{ + protected function buildUFC(UserFilterBuilder $ufb) + { + return new UFC_DeltaTen_Message($this->val); + } +} +// }}} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>