#!/usr/bin/php5 -q mailstorage->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']); } /* Emits a warning for GApps accounts without local user_id. */ $res = XDB::iterator( "SELECT g.g_account_name 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 NULL"); while ($account = $res->next()) { if (!preg_match("/^admin-/", $account['g_account_name'])) { printf("Warning: GApps account '%s' has no local user_id.\n", $account['g_account_name']); } } /* Retrieves successful job queues for post-queue processing. */ $res = XDB::iterator( "SELECT q_id, q_recipient_id, j_type, j_parameters FROM gapps_queue WHERE p_status = 'success' AND q_recipient_id IS NOT NULL"); while ($job = $res->next()) { if ($job['j_type'] == 'u_create') { post_queue_u_create($job); } else if ($job['j_type'] == 'u_update') { post_queue_u_update($job); } } /* Removes successful jobs, and old failed jobs. */ XDB::execute( "DELETE FROM gapps_queue WHERE p_status = 'success' OR (p_status = 'hardfail' AND p_end_date < DATE_SUB(NOW(), INTERVAL 15 DAY))"); // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>