X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fgoogleapps.inc.php;h=28d94599e735646d155c2ec42f59922598f31d1e;hb=50bf984bf184367a83307676441c9bf14555efc8;hp=e6d69433e7594dbad53d13b03c1086a848f14807;hpb=f5c4bf30937c75b077ce4941a7c66019cc781a67;p=platal.git diff --git a/include/googleapps.inc.php b/include/googleapps.inc.php index e6d6943..28d9459 100644 --- a/include/googleapps.inc.php +++ b/include/googleapps.inc.php @@ -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. @@ -116,6 +116,7 @@ class GoogleAppsAccount public $activate_mail_redirection; // Account status, obtained from Google Apps provisioning & reporting APIs. + public $g_account_id; public $g_status; public $g_suspension; public $r_disk_usage; @@ -148,10 +149,13 @@ 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, - g_account_name, g_status, g_suspension, r_disk_usage, + g_account_name, g_account_id, g_status, g_suspension, r_disk_usage, UNIX_TIMESTAMP(r_creation) as r_creation, UNIX_TIMESTAMP(r_last_login) as r_last_login, UNIX_TIMESTAMP(r_last_webmail) as r_last_webmail @@ -161,6 +165,7 @@ class GoogleAppsAccount if ($account = $res->fetchOneAssoc()) { $this->sync_password = $account['l_sync_password']; $this->activate_mail_redirection = $account['l_activate_mail_redirection']; + $this->g_account_id = $account['g_account_id']; $this->g_status = $account['g_status']; $this->g_suspension = $account['g_suspension']; $this->r_disk_usage = $account['r_disk_usage']; @@ -242,7 +247,7 @@ class GoogleAppsAccount // Creates a queue job of the @p type, for the user represented by this // GoogleAppsAccount object, using @p parameters. @p parameters is supposed // to be a one-dimension array of key-value mappings. - // The created job as a 'normal' priority, and is scheduled for immediate + // The created job as a 'immediate' priority, and is scheduled for immediate // execution. private function create_queue_job($type, $parameters) { $parameters["username"] = $this->g_account_name; @@ -250,7 +255,7 @@ class GoogleAppsAccount "INSERT INTO gapps_queue SET q_owner_id = {?}, q_recipient_id = {?}, p_entry_date = NOW(), p_notbefore_date = NOW(), - p_priority = 'normal', + p_priority = 'immediate', j_type = {?}, j_parameters = {?}", S::v('uid'), $this->uid, @@ -287,6 +292,7 @@ class GoogleAppsAccount if (!$this->pending_update_password) { $this->create_queue_job('u_update', array('password' => $password)); + $this->pending_update_password = true; } } @@ -316,6 +322,11 @@ class GoogleAppsAccount if (!$this->pending_update_suspension) { $this->create_queue_job('u_update', array('suspended' => true)); $this->pending_update_suspension = true; + XDB::execute( + "UPDATE gapps_accounts + SET g_status = 'disabled' + WHERE g_account_name = {?} AND g_status = 'active'", + $this->g_account_name); } } @@ -436,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); } }