+// {{{ 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);
+ }
+}
+// }}}
+