From: Florent Bruneau Date: Sat, 27 Feb 2010 20:49:22 +0000 (+0100) Subject: Add UFC_SchoolId. X-Git-Tag: xorg/1.0.0~332^2~167 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=9e8bacfbba170764624f6d3c050c710e398e1dae;p=platal.git Add UFC_SchoolId. $cond = new UFC_SchoolId($type, $id); $type is one of UFC_SchoolId::Xorg, AX, School Signed-off-by: Florent Bruneau --- diff --git a/classes/userfilter.php b/classes/userfilter.php index 5a6e645..3e89426 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -153,6 +153,48 @@ class UFC_Promo implements UserFilterCondition } // }}} +// {{{ class UFC_SchoolId +/** Filters users based on their shoold identifier + * @param type Parameter type (Xorg, AX, School) + * @param value School id value + */ +class UFC_SchooldId implements UserFilterCondition +{ + const AX = 'ax'; + const Xorg = 'xorg'; + const School = 'school'; + + private $type; + private $id; + + static public function assertType($type) + { + if ($type != self::AX && $type != self::Xorg && $type != self::School) { + Platal::page()->killError("Type de matricule invalide: $type"); + } + } + + public function __construct($type, $id) + { + $this->type = $type; + $this->id = $id; + self::assertType($type); + } + + public function buildCondition(PlFilter &$uf) + { + $uf->requireProfiles(); + $id = $this->id; + $type = $this->type; + if ($type == self::School) { + $type = self::Xorg; + $id = Profile::getXorgId($id); + } + return XDB::format('p.' . $type . '_id = {?}', $id); + } +} +// }}} + // {{{ class UFC_EducationSchool /** Filters users by formation * @param $val The formation to search (either ID or array of IDs)