Fetch groups a user belongs to
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 14 Feb 2010 12:07:22 +0000 (13:07 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 14 Feb 2010 22:39:37 +0000 (23:39 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/user.php

index f2cd4b5..d6555af 100644 (file)
@@ -471,6 +471,19 @@ class User extends PlUser
         return isset($this->contacts[$user->id()]);
     }
 
+    // Groupes X
+    private $groups = null;
+    public function groups()
+    {
+        if (is_null($this->groups)) {
+            $this->groups = XDB::fetchAllAssoc('asso_id', 'SELECT  asso_id, perms, comm
+                                                             FROM  #groupex#.membres
+                                                            WHERE  uid = {?}',
+                                                $this->id());
+        }
+        return $this->groups;
+    }
+
     // Return permission flags for a given permission level.
     public static function makePerms($perms, $is_admin)
     {