Add UFC_Hrpid.
[platal.git] / include / user.func.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
9f5bd98e 3 * Copyright (C) 2003-2010 Polytechnique.org *
0337d704 4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22// {{{ function user_clear_all_subs()
23/** kills the inscription of a user.
24 * we still keep his birthdate, adresses, and personnal stuff
25 * kills the entreprises, mentor, emails and lists subscription stuff
26 */
27function user_clear_all_subs($user_id, $really_del=true)
28{
5c8a71f2
FB
29 // keep datas in : aliases, adresses, tels, profile_education, profile_binets, contacts, groupesx_ins, homonymes, identification_ax, photo
30 // delete in : profile_skills, emails, entreprises, profile_langskills, mentor,
0337d704 31 // mentor_pays, mentor_secteurs, newsletter_ins, perte_pass, requests, user_changes, virtual_redirect, watch_sub
32 // + delete maillists
33
34 global $globals;
d56cb887
VZ
35 $uid = intval($user_id);
36 $user = User::getSilent($uid);
37 list($alias) = explode('@', $user->forlifeEmail());
0337d704 38
0c1e3a66 39 // TODO: clear profile.
5c8a71f2 40 $tables_to_clear = array('uid' => array('profile_skills', 'profile_job', 'profile_langskills', 'profile_mentor_country',
5fecdf6d 41 'profile_mentor_sector', 'profile_mentor', 'perte_pass', 'watch_sub'),
425f432d 42 'user_id' => array('requests', 'user_changes'));
43
0337d704 44 if ($really_del) {
eb41eda9 45 array_push($tables_to_clear['uid'], 'emails', 'group_members', 'contacts', 'adresses', 'profile_phones',
5c8a71f2
FB
46 'photo', 'perte_pass', 'profile_langskills', 'forum_subs', 'forum_profiles');
47 array_push($tables_to_clear['user_id'], 'newsletter_ins', 'profile_binets');
787bb3d7 48 $tables_to_clear['id'] = array('aliases');
425f432d 49 $tables_to_clear['contact'] = array('contacts');
0c1e3a66
FB
50 XDB::execute("UPDATE accounts
51 SET registration_date = 0, state = 'pending', password = NULL, weak_password = NULL, token = NULL, is_admin = 0
52 WHERE uid = {?}", $uid);
425f432d 53 XDB::execute("DELETE virtual.* FROM virtual INNER JOIN virtual_redirect AS r USING(vid) WHERE redirect = {?}",
54 $alias.'@'.$globals->mail->domain);
55 XDB::execute("DELETE virtual.* FROM virtual INNER JOIN virtual_redirect AS r USING(vid) WHERE redirect = {?}",
56 $alias.'@'.$globals->mail->domain2);
57 } else {
0c1e3a66
FB
58 XDB::execute("UPDATE accounts
59 SET password = NULL, weak_password = NULL, token = NULL
60 WHERE uid = {?}", $uid);
0337d704 61 }
62
08cce2ff 63 XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain);
64 XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain2);
65
0c1e3a66 66 /* TODO: handle both account and profile
425f432d 67 foreach ($tables_to_clear as $key=>&$tables) {
68 foreach ($tables as $table) {
69 XDB::execute("DELETE FROM $table WHERE $key={?}", $uid);
70 }
0c1e3a66 71 }*/
9bb8bf21 72
0c1e3a66 73 $mmlist = new MMList($user);
9bb8bf21 74 $mmlist->kill($alias, $really_del);
84270653
VZ
75
76 // Deactivates, when available, the Google Apps account of the user.
77 if ($globals->mailstorage->googleapps_domain) {
78 require_once 'googleapps.inc.php';
14870e88 79 if (GoogleAppsAccount::account_status($uid)) {
d56cb887 80 $account = new GoogleAppsAccount($user);
14870e88
VZ
81 $account->suspend();
82 }
84270653 83 }
0337d704 84}
85
86// }}}
433336f3 87
88
a7de4ef7 89// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 90?>