Adds basic Google Apps support.
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Fri, 25 Jan 2008 16:00:31 +0000 (17:00 +0100)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Mon, 10 Mar 2008 08:59:13 +0000 (09:59 +0100)
* Adds minimal configuration directives in platal.ini.
* Adds the SQL tables for the Plat/al - GAppsDaemon interactions.
* Adds the Google Apps sql table cleanup cron.

Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
bin/cron/google_apps.php [new file with mode: 0755]
configs/platal.cron.in
upgrade/0.9.16/06_google_apps.sql [new file with mode: 0644]

diff --git a/bin/cron/google_apps.php b/bin/cron/google_apps.php
new file mode 100755 (executable)
index 0000000..76cfcc5
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/php5 -q
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+/* Updates the gapps_accounts table with Plat/al information. */
+
+require('./connect.db.inc.php');
+if (!$globals->googleapps->domain) {
+  exit;
+}
+
+/* Updates the l_userid parameter for newer user accounts. */
+$res = XDB::iterator("SELECT  g.g_account_name, a.id
+                        FROM  gapps_accounts AS g
+                   LEFT JOIN  aliases as a ON (a.alias = g.g_account_name AND a.type = 'a_vie')
+                       WHERE  (g.l_userid IS NULL OR g.l_userid <= 0) AND
+                              a.id IS NOT NULL");
+while ($account = $res->next()) {
+  XDB::execute("UPDATE  gapps_accounts
+                   SET  l_userid = {?}
+                 WHERE  g_account_name = {?}",
+               $account['id'], $account['g_account_name']);
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 05de023..4c57ba8 100644 (file)
@@ -30,4 +30,7 @@ WD=/home/web/prod/platal/bin/cron
 # ml moderation
 * * * * *       web     cd $WD; ./cron_ml_moderate.php > /dev/null
 
+# synchronisation google apps - plat/al
+0 3 * * *      web     cd $WD; ./google_apps.php
+
 # vim:set noet syntax=crontab ts=8 sw=8 sts=8 enc=utf-8:
diff --git a/upgrade/0.9.16/06_google_apps.sql b/upgrade/0.9.16/06_google_apps.sql
new file mode 100644 (file)
index 0000000..1ad53f3
--- /dev/null
@@ -0,0 +1,86 @@
+-- This SQL table comes from the 'gapps-daemon' project.
+
+-- Table `gapps_reporting`.
+-- The table contains daily statistics of the Google Apps domain. They are
+-- obtained with the Summary and Actvity reports of the Google Apps Reorting
+-- API.
+CREATE TABLE IF NOT EXISTS `gapps_reporting` (
+  date DATE NOT NULL,
+  num_accounts INTEGER  UNSIGNED DEFAULT NULL,
+  count_1_day_actives INTEGER UNSIGNED DEFAULT NULL,
+  count_7_day_actives INTEGER UNSIGNED DEFAULT NULL,
+  count_14_day_actives INTEGER UNSIGNED DEFAULT NULL,
+  count_30_day_actives INTEGER UNSIGNED DEFAULT NULL,
+  count_30_day_idle INTEGER UNSIGNED DEFAULT NULL,
+  count_60_day_idle INTEGER UNSIGNED DEFAULT NULL,
+  count_90_day_idle INTEGER UNSIGNED DEFAULT NULL,
+  usage_in_bytes BIGINT UNSIGNED DEFAULT NULL,
+  quota_in_mb INTEGER  UNSIGNED DEFAULT NULL,
+  PRIMARY KEY(date)
+) CHARSET=utf8;
+
+-- Table `gapps_accounts`.
+-- Holds the Google Apps account list, ie. a list of all registered accounts on
+-- the Google Apps domain.
+CREATE TABLE IF NOT EXISTS `gapps_accounts` (
+  -- Application-specific fields.
+  l_userid SMALLINT UNSIGNED DEFAULT NULL,
+  l_sync_password BOOL DEFAULT TRUE,
+  l_activate_mail_redirection BOOL DEFAULT TRUE,
+
+  -- Shared fields.
+  g_account_id CHAR(16) DEFAULT NULL,
+  g_account_name VARCHAR(256) NOT NULL,
+  g_first_name VARCHAR(40) NOT NULL,
+  g_last_name VARCHAR(40) NOT NULL,
+  g_status ENUM('unprovisioned', 'disabled', 'active') DEFAULT 'unprovisioned',
+  g_admin BOOL DEFAULT NULL,
+  g_suspension VARCHAR(256) DEFAULT NULL,
+
+  -- Google-owned fields.
+  r_disk_usage BIGINT DEFAULT NULL,
+  r_creation DATE DEFAULT NULL,
+  r_last_login DATE DEFAULT NULL,
+  r_last_webmail DATE DEFAULT NULL,
+
+  -- Indexes.
+  PRIMARY KEY(g_account_name),
+  INDEX l_userid(l_userid)
+) CHARSET=utf8;
+
+-- Table `gapps_queue`.
+-- Holds queued API requests that are to be processed by the gappsd. It also
+-- includes processed but not yet acknowledged requests.
+CREATE TABLE IF NOT EXISTS `gapps_queue` (
+  -- Queue identification fields.
+  q_id INT NOT NULL AUTO_INCREMENT,
+  q_owner_id SMALLINT DEFAULT NULL,
+  q_recipient_id SMALLINT DEFAULT NULL,
+
+  -- Queue management information.
+  p_entry_date DATETIME NOT NULL,
+  p_notbefore_date DATETIME NOT NULL,
+  p_start_date DATETIME DEFAULT NULL,
+  p_end_date DATETIME DEFAULT NULL,
+  p_status ENUM('idle', 'active', 'success', 'hardfail', 'softfail') DEFAULT 'idle' NOT NULL,
+  p_priority ENUM('immediate', 'normal', 'offline') DEFAULT 'offline' NOT NULL,
+  p_admin_request BOOLEAN DEFAULT false NOT NULL,
+
+  -- Job content fields.
+  j_type ENUM('r_activity', 'r_accounts', 'u_create', 'u_delete', 'u_update', 'u_sync') NOT NULL,
+  j_parameters TEXT DEFAULT NULL,
+
+  -- Job execution result fields.
+  r_softfail_date DATETIME DEFAULT NULL,
+  r_softfail_count SMALLINT DEFAULT 0 NOT NULL,
+  r_result VARCHAR(256) DEFAULT NULL,
+
+  -- Indexes.
+  PRIMARY KEY(q_id),
+  INDEX q_owner_id(q_owner_id),
+  INDEX q_recipient_id(q_recipient_id),
+  INDEX p_status(p_status),
+  INDEX p_priority(p_priority)
+) CHARSET=utf8;
+
+-- vim:set syntax=mysql: