Update UFC_SchoolId arguments
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 28 Dec 2010 15:19:18 +0000 (16:19 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 29 Dec 2010 17:53:18 +0000 (18:53 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/userfilter.php

index 2c12918..03a88a0 100644 (file)
@@ -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);
     }
 }
 // }}}