Merge remote branch 'origin/platal-0.10.2'
[platal.git] / include / googleapps.inc.php
index fb9d52c..7449a3a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -101,7 +101,7 @@ function post_queue_u_update($job) {
 // TODO(vincent.zanotti): add the url of gappsd, when available.
 class GoogleAppsAccount
 {
-    // User identification: user id, and forlife.
+    // User identification: user id, and hruid.
     private $user;
     public $g_account_name;
 
@@ -119,6 +119,9 @@ class GoogleAppsAccount
     public $r_last_webmail;
     public $reporting_date;
 
+    // Nicknames (aliases) registered for that user, lazily loaded.
+    public $nicknames;
+
     // Pending requests in the gappsd job queue (cf. top note).
     public $pending_create;
     public $pending_delete;
@@ -272,6 +275,21 @@ class GoogleAppsAccount
         return $this->g_status == 'disabled';
     }
 
+    // Loads and returns the list of nicknames for the user.
+    public function nicknames()
+    {
+        if ($this->nicknames == null) {
+            $res = XDB::query(
+                "SELECT  g_nickname
+                   FROM  gapps_nicknames
+                  WHERE  g_account_name = {?}
+               ORDER BY  g_nickname",
+                $this->g_account_name);
+            $this->nicknames = $res->fetchColumn();
+        }
+        return $this->nicknames;
+    }
+
 
     // Changes the GoogleApps password.
     public function set_password($password) {