X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fufbuilder.inc.php;h=73997e9aef9b9f15812df3cd34c932b697c7956d;hb=e5b254d5b406a2ed6c15e27aa3d05e6f729178ca;hp=45c589bdf98040dcd05c9db4a7d97aec0d564d87;hpb=12ddbc2037b16496dfb9d91c4f7091850146fcde;p=platal.git diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 45c589b..73997e9 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -1,6 +1,6 @@ empty) { + if (!$this->isEmpty()) { $ufc = $this->buildUFC($ufb); if ($ufc != null) { $ufb->addCond($ufc); @@ -520,18 +532,8 @@ class UFBF_Quick extends UFB_Field } else { $flags = array('public'); } - if ($ufb->b('with_soundex')) { - $soundex = true; - $st = array(); - foreach ($strings as $string) { - $st[] = soundex_fr($string); - } - } else { - $soundex = false; - $st = $strings; - } $exact =$ufb->b('exact'); - $conds->addChild(new UFC_NameTokens($st, $flags, $soundex, $exact)); + $conds->addChild(new UFC_NameTokens($strings, $flags, $ufb->b('with_soundex'), $exact)); $ufb->addOrder(new UFO_Score()); } @@ -573,6 +575,48 @@ class UFBF_Quick extends UFB_Field } // }}} +// {{{ class UFBF_SchoolIds +class UFBF_SchoolIds extends UFB_Field +{ + // One of UFC_SchoolId types + protected $type; + + public function __construct($envfield, $formtext, $type = UFC_SchoolId::AX) + { + parent::__construct($envfield, $formtext); + $this->type = $type; + } + + protected function check(UserFilterBuilder &$ufb) + { + if ($ufb->blank($this->envfield)) { + $this->empty = true; + return true; + } + + $value = $ufb->t($this->envfield); + $values = explode("\n", $value); + $ids = array(); + foreach ($values as $val) { + if (preg_match('/^[0-9A-Z]{0,8}$/', $val)) { + $ids[] = $val; + } + } + if (count($ids) == 0) { + return $this->raise("Le champ %s ne contient aucune valeur valide."); + } + + $this->val = $ids; + return true; + } + + protected function buildUFC(UserFilterBuilder &$ufb) + { + return new UFC_SchoolId($this->type, $this->val); + } +} +// }}} + // {{{ class UFBF_Name class UFBF_Name extends UFBF_Text { @@ -665,6 +709,22 @@ class UFBF_Sex extends UFBF_Enum } // }}} +// {{{ class UFBF_NotRegistered +// Simple field for selecting only alive, not registered users (for quick search) +class UFBF_NotRegistered extends UFBF_Bool +{ + protected function buildUFC(UserFilterBuilder &$ufb) + { + if ($this->val) { + return new PFC_And( + new PFC_Not(new UFC_Dead()), + new PFC_Not(new UFC_Registered()) + ); + } + } +} +// }}} + // {{{ class UFBF_Registered class UFBF_Registered extends UFBF_Enum { @@ -802,6 +862,32 @@ class UFBF_AdminArea extends UFBF_Index } // }}} +// {{{ class UFBF_SubAdminArea +class UFBF_SubAdminArea extends UFBF_Index +{ + protected $direnum = DirEnum::SUBADMINAREAS; + 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_SUBADMAREA, UFC_Address::TYPE_ANY, $flags); + } +} +// }}} + // {{{ class UFBF_JobCompany class UFBF_JobCompany extends UFBF_Text { @@ -1020,6 +1106,11 @@ class UFBF_Networking extends UFBF_Text } } + public function isEmpty() + { + return parent::isEmpty() || $this->nwtype == 0; + } + public function buildUFC(UserFilterBuilder &$ufb) { return new UFC_Networking($this->nwtype, $this->val);