X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fufbuilder.inc.php;h=73997e9aef9b9f15812df3cd34c932b697c7956d;hb=e5b254d5b406a2ed6c15e27aa3d05e6f729178ca;hp=40c5a7465985392f22f016fc7c35147ae715861e;hpb=9d590571b644fb7851c0c98f57051da86549b20b;p=platal.git diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 40c5a74..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); @@ -563,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 { @@ -655,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 { @@ -792,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 { @@ -1010,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);