Adds support for GoogleApps-only redirections in newsletters.
[platal.git] / include / googleapps.inc.php
index dadbf03..1e9ee3c 100644 (file)
@@ -36,8 +36,8 @@ function post_queue_u_create($job) {
     $account = new GoogleAppsAccount($userid, $forlife);
     if ($account->activate_mail_redirection) {
         require_once('emails.inc.php');
-        $storage = new MailStorageGoogleApps($userid);
-        $storage->enable();
+        $storage = new EmailStorage($userid, 'googleapps');
+        $storage->activate();
     }
 
     // Sends the 'account created' email to the user, with basic documentation.
@@ -78,8 +78,8 @@ function post_queue_u_update($job) {
         if ($account->active()) {
             // Re-adds the email redirection (if the user did request it).
             if ($account->activate_mail_redirection) {
-                $storage = new MailStorageGoogleApps($userid);
-                $storage->enable();
+                $storage = new EmailStorage($userid, 'googleapps');
+                $storage->activate();
             }
 
             // Sends an email to the account owner.
@@ -149,6 +149,9 @@ class GoogleAppsAccount
         $this->uid = $uid;
         $this->g_account_name = $account_name;
         $this->g_status = NULL;
+        if (!$this->g_account_name) {
+            return;
+        }
 
         $res = XDB::query(
             "SELECT  l_sync_password, l_activate_mail_redirection,
@@ -444,7 +447,7 @@ class GoogleAppsAccount
             "SELECT  g_admin
                FROM  gapps_accounts
               WHERE  l_userid = {?} AND g_status = 'active'", $uid);
-        return ($res->numRows() > 0 ? (bool)$res->fetchOneRow() : false);
+        return ($res->numRows() > 0 ? (bool)$res->fetchOneCell() : false);
     }
 }