/** * Clears a user. * *always deletes in: account_lost_passwords, register_marketing, * register_pending, register_subs, watch_nonins, watch, watch_promo, watch_group, * *always keeps in: account_types, accounts, email_virtual, carvas, * group_members, homonyms_list, newsletter_ins, register_mstats, email_source_account * *deletes if $clearAll: account_auth_openid, announce_read, contacts, * email_redirect_account, email_redirect_account, email_send_save, forum_innd, forum_profiles, * forum_subs, gapps_accounts, gapps_nicknames, group_announces_read, * group_member_sub_requests, reminder, requests, requests_hidden, * email_virtual, ML * *modifies if $clearAll: accounts * * Use cases: * *$clearAll == false: when a user dies, her family still needs to keep in * touch with the community. * *$clearAll == true: in every other case we want the account to be fully * deleted so that it can not be used anymore. */ public function clear($clearAll = true) { $tables = array('account_lost_passwords', 'register_marketing', 'register_pending', 'register_subs', 'watch_nonins', 'watch', 'watch_promo', 'watch_group'); foreach ($tables as $t) { XDB::execute('DELETE FROM ' . $t . ' WHERE uid = {?}', $this->id()); } if ($clearAll) { global $globals; $groupIds = XDB::iterator('SELECT asso_id FROM group_members WHERE uid = {?}', $this->id()); while ($groupId = $groupIds->next()) { $group = Group::get($groupId); if (!empty($group) && $group->notif_unsub) { $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl'); $admins = $group->iterAdmins(); while ($admin = $admins->next()) { $mailer->addTo($admin); } $mailer->assign('group', $group->shortname); $mailer->assign('user', $this); $mailer->assign('selfdone', false); $mailer->send(); } } $tables = array('account_auth_openid', 'announce_read', 'contacts', 'email_send_save', 'forum_innd', 'forum_profiles', 'forum_subs', 'group_announces_read', 'group_members', 'group_member_sub_requests', 'reminder', 'requests', 'requests_hidden'); foreach ($tables as $t) { XDB::execute('DELETE FROM ' . $t . ' WHERE uid = {?}', $this->id()); } XDB::execute('DELETE FROM email_redirect_account WHERE uid = {?} AND type != \'homonym\'', $this->id()); XDB::execute('DELETE FROM email_virtual WHERE redirect = {?}', $this->forlifeEmail()); foreach (array('gapps_accounts', 'gapps_nicknames') as $t) { XDB::execute('DELETE FROM ' . $t . ' WHERE l_userid = {?}', $this->id()); } XDB::execute("UPDATE accounts\n SET registration_date = 0, state = 'pending', password = NULL,\n weak_password = NULL, token = NULL, is_admin = 0\n WHERE uid = {?}", $this->id()); if ($globals->mailstorage->googleapps_domain) { require_once 'googleapps.inc.php'; if (GoogleAppsAccount::account_status($this->id())) { $account = new GoogleAppsAccount($this); $account->suspend(); } } } $mmlist = new MMList(S::user()); $mmlist->kill($this->forlife, $this->promo(), $clearAll); }
function handler_admin_user($page, $user = null) { require_once 'emails.inc.php'; require_once 'googleapps.inc.php'; $page->changeTpl('googleapps/admin.user.tpl'); $page->setTitle('Administration Google Apps'); $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid'))); if (!$user && Post::has('login')) { $user = Post::v('login'); } $user = User::get($user); if ($user) { $account = new GoogleAppsAccount($user); // Apply requested actions. if (Post::has('suspend') && $account->active() && !$account->pending_update_suspension) { S::assert_xsrf_token(); $account->suspend(); $page->trigSuccess('Le compte est en cours de suspension.'); } else { if (Post::has('unsuspend') && $account->suspended() && !$account->pending_update_suspension) { S::assert_xsrf_token(); $account->do_unsuspend(); $page->trigSuccess('Le compte est en cours de réactivation.'); } else { if (Post::has('forcesync') && $account->active() && $account->sync_password) { $account->set_password($user->password()); $page->trigSuccess('Le mot de passe est en cours de synchronisation.'); } else { if (Post::has('sync') && $account->active()) { $account->set_password($user->password()); $account->set_password_sync(true); } else { if (Post::has('nosync') && $account->active()) { $account->set_password_sync(false); } } } } } // Displays basic account information. $page->assign('account', $account); $page->assign('admin_account', GoogleAppsAccount::is_administrator($user->id())); $page->assign('googleapps_storage', Email::is_active_storage($user, 'googleapps')); $page->assign('user', $user->id()); // Retrieves user's pending requests. $res = XDB::iterator("SELECT q_id, q_recipient_id, p_status, j_type, UNIX_TIMESTAMP(p_entry_date) AS p_entry_date\n FROM gapps_queue\n WHERE q_recipient_id = {?}\n ORDER BY p_entry_date DESC", $user->id()); $page->assign('requests', $res); } }