From 4a0746a82545651c559ea3e593c810ce6fdef6a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Tue, 28 Dec 2010 16:19:18 +0100 Subject: [PATCH] Update UFC_SchoolId arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- classes/userfilter.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/classes/userfilter.php b/classes/userfilter.php index 2c12918..03a88a0 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -228,7 +228,7 @@ 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 + * @param value Array of school ids */ class UFC_SchoolId implements UserFilterCondition { @@ -246,23 +246,30 @@ class UFC_SchoolId implements UserFilterCondition } } - public function __construct($type, $id) + /** Construct a UFC_SchoolId + * The first argument is the type, all following arguments can be either ids + * or arrays of ids to use: + * $ufc = new UFC_SchoolId(UFC_SchoolId::AX, $id1, $id2, array($id3, $id4)); + */ + public function __construct($type) { $this->type = $type; - $this->id = $id; + $ids = func_get_args(); + array_shift($ids); + $this->ids = pl_flatten($ids); self::assertType($type); } public function buildCondition(PlFilter &$uf) { $uf->requireProfiles(); - $id = $this->id; + $ids = $this->ids; $type = $this->type; if ($type == self::School) { $type = self::Xorg; - $id = Profile::getXorgId($id); + $ids = array_map(array('Profile', 'getXorgId'), $ids); } - return XDB::format('p.' . $type . '_id = {?}', $id); + return XDB::format('p.' . $type . '_id IN {?}', $ids); } } // }}} -- 2.1.4