X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fufbuilder.inc.php;h=09dc307dd242d65d99d33b487764710a42fa4024;hb=0b5aebe16a9eb47158fce84e84d16206d2789f31;hp=9385cb15d117b0330302993e5541b5cce9a65e01;hpb=4e8d54a74e22fe9763fd112bc98fe82b09d76778;p=platal.git diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 9385cb1..09dc307 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -140,6 +140,18 @@ class UserFilterBuilder return Env::blank($key, $strict); } + public function hasAlnum($key) + { + $str = $this->s($key); + return preg_match('/[a-z0-9]/i', $str); + } + + public function hasAlpha($key) + { + $str = $this->s($key); + return preg_match('/[a-z]/i', $str); + } + public function isOn($key) { return $this->has($key) && $this->t($key) == 'on'; @@ -181,6 +193,7 @@ class UFB_AdvancedSearch extends UserFilterBuilder new UFBF_JobSector('sector', 'Poste'), new UFBF_JobDescription('jobdescription', 'Fonction'), new UFBF_JobCv('cv', 'CV'), + new UFBF_JobTerms('jobterm', 'Mots-clefs'), new UFBF_Nationality('nationaliteTxt', 'nationalite', 'Nationalité'), new UFBF_Binet('binetTxt', 'binet', 'Binet'), @@ -194,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); } @@ -206,9 +221,8 @@ class UFB_MentorSearch extends UserFilterBuilder public function __construct($envprefix = '') { $fields = array( - new UFBF_MentorCountry('pays_sel'), - new UFBF_MentorSectorization('sector', '', UFC_Mentor_Sectorization::SECTOR), - new UFBF_MentorSectorization('subSector', '', UFC_Mentor_Sectorization::SUBSECTOR), + new UFBF_MentorCountry('country'), + new UFBF_MentorTerm('jobterm', 'jobtermText'), new UFBF_MentorExpertise('expertise'), ); parent::__construct($fields, $envprefix); @@ -308,7 +322,7 @@ abstract class UFBF_Text extends UFB_Field return $this->raise("Le champ %s est trop court (minimum {$this->minlength})."); } else if (strlen($this->val) > $this->maxlength) { return $this->raise("Le champ %s est trop long (maximum {$this->maxlength})."); - } else if (preg_match(":[\]\[<>{}~/§_`|%$^=+]|\*\*:u", $this->val)) { + } else if (preg_match(":[\]\[<>{}~§_`|%$^=]|\*\*:u", $this->val)) { return $this->raise('Le champ %s contient un caractère interdit rendant la recherche impossible.'); } @@ -436,7 +450,7 @@ abstract class UFBF_Mixed extends UFB_Field protected function check(UserFilterBuilder &$ufb) { - if ($ufb->blank($this->envfieldindex) && $ufb->blank($this->envfield)) { + if ($ufb->blank($this->envfieldindex) && !$ufb->hasAlnum($this->envfield)) { $this->empty = true; return true; } @@ -450,7 +464,7 @@ abstract class UFBF_Mixed extends UFB_Field } $this->val = array($index); } else { - $indexes = DirEnum::getIDs($this->direnum, $ufb->t($this->envfield), + $indexes = DirEnum::getIDs($this->direnum, $ufb->t($this->envfield), $ufb->b('exact') ? XDB::WILDCARD_EXACT : XDB::WILDCARD_CONTAINS); if (count($indexes) == 0) { return false; @@ -487,8 +501,7 @@ class UFBF_Quick extends UFB_Field if (S::admin() && strpos($s, '@') !== false) { return new UFC_Email($s); } else if (S::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) { - $this->conds->addChild(new UFC_Ip($s)); - return; + return new UFC_Ip($s); } $conds = new PFC_And(); @@ -604,8 +617,8 @@ class UFBF_Promo extends UFB_Field return true; } - $this->val = $ubf->i($this->envfield); - $this->comp = $ubf->v($this->envfieldcomp); + $this->val = $ufb->i($this->envfield); + $this->comp = $ufb->v($this->envfieldcomp); if (!in_array($this->comp, self::$validcomps)) { return $this->raise("Le critère {$this->comp} n'est pas valide pour le champ %s"); @@ -621,7 +634,7 @@ class UFBF_Promo extends UFB_Field } protected function buildUFC(UserFilterBuilder &$ufb) { - return new UFC_Promo($this->comp, UserFilter::DISPLAY, 'X' . $this->val); + return new UFC_Promo($this->comp, UserFilter::GRADE_ING, $this->val); } } // }}} @@ -666,7 +679,7 @@ class UFBF_Registered extends UFBF_Enum if ($this->val == 1) { return new UFC_Registered(); } else if ($this->val == 2) { - return new PFC_Not(UFC_Registered()); + return new PFC_Not(new UFC_Registered()); } } } @@ -683,7 +696,7 @@ class UFBF_Dead extends UFBF_Enum protected function buildUFC(UserFilterBuilder &$ufb) { if ($this->val == 1) { - return new PFC_Not(UFC_Dead()); + return new PFC_Not(new UFC_Dead()); } else if ($this->val == 2) { return new UFC_Dead(); } @@ -725,7 +738,7 @@ class UFBF_Town extends UFBF_Text return new PFC_False(); } } else { - $byname = new UFC_AddressText(null, UFC_Address::CONTAINS, UFC_Address::TYPE_ANY, $flags, null, $this->val); + $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); @@ -843,6 +856,16 @@ class UFBF_JobSector extends UFBF_Mixed } // }}} +// {{{ class UFBF_JobTerms +class UFBF_JobTerms extends UFBF_Index +{ + protected function buildUFC(UserFilterBuilder &$ufb) + { + return new UFC_Job_Terms($this->val); + } +} +// }}} + // {{{ class UFBF_JobDescription class UFBF_JobDescription extends UFBF_Text { @@ -1028,8 +1051,18 @@ 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_Index +class UFBF_MentorCountry extends UFBF_Text { protected function buildUFC(UserFilterBuilder &$ufb) { @@ -1038,6 +1071,16 @@ class UFBF_MentorCountry extends UFBF_Index } // }}} +// {{{ class UFBF_Mentorterm +class UFBF_MentorTerm extends UFBF_Index +{ + protected function buildUFC(UserFilterBuilder &$ufb) + { + return new UFC_Mentor_Terms($this->val); + } +} +// }}} + // {{{ class UFBF_MentorSectorization class UFBF_MentorSectorization extends UFBF_Index {