return ($isOk && ($maxlen > 2 || $maxlen == strlen($_lastname)));
}
+ /**
+ * Clears a profile.
+ * *always deletes in: profile_addresses, profile_binets, profile_job,
+ * profile_langskills, profile_mentor, profile_networking,
+ * profile_phones, profile_skills, watch_profile
+ * *always keeps in: profile_corps, profile_display, profile_education,
+ * profile_medals, profile_name, profile_photos, search_name
+ * *modifies: profiles
+ */
+ public function clear()
+ {
+ XDB::execute('DELETE FROM profile_job, profile_langskills, profile_mentor,
+ profile_networking, profile_skills, watch_profile
+ WHERE pid = {?}',
+ $this->id());
+ XDB::execute('DELETE FROM profile_addresses, profile_binets,
+ profile_phones
+ WHERE pid = {?}',
+ $this->id());
+ XDB::execute("UPDATE profiles
+ SET cv = NULL, freetext = NULL, freetext_pub = 'private',
+ medals_pub = 'private', alias_pub = 'private',
+ email_directory = NULL
+ WHERE pid = {?}",
+ $this->id());
+ }
+
private static function fetchProfileData(array $pids, $respect_order = true)
{
if (count($pids) == 0) {
return $this->groups;
}
+ /**
+ * Clears a user.
+ * *always deletes in: account_lost_passwords, register_marketing,
+ * register_pending, register_subs, watch_nonins, watch, watch_promo
+ * *always keeps in: account_types, accounts, aliases, axletter_ins, carvas,
+ * group_members, homonyms, newsletter_ins, register_mstats,
+ * *deletes if $clearAll: account_auth_openid, announce_read, contacts,
+ * email_options, email_send_save, emails, forum_innd, forum_profiles,
+ * forum_subs, gapps_accounts, gapps_nicknames, group_announces_read,
+ * group_member_sub_requests, reminder, requests, requests_hidden,
+ * virtual, virtual_redirect, 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)
+ {
+ XDB::execute('DELETE FROM account_lost_passwords, register_marketing,
+ register_pending, register_subs, watch_nonins,
+ watch, watch_promo
+ WHERE uid = {?}',
+ $this->id());
+
+ if ($clearAll) {
+ XDB::execute('DELETE FROM account_auth_openid, announce_read, contacts,
+ email_options, email_send_save, emails,
+ forum_innd, forum_profiles, forum_subs,
+ gapps_accounts, gapps_nicknames, group_announces_read,
+ group_member_sub_requests, reminder, requests,
+ requests_hidden
+ WHERE uid = {?}',
+ $this->id());
+ XDB::execute("UPDATE accounts
+ SET registration_date = 0, state = 'pending', password = NULL,
+ weak_password = NULL, token = NULL, is_admin = 0
+ WHERE uid = {?}",
+ $this->id());
+
+ XDB::execute('DELETE v.*
+ FROM virtual AS v
+ INNER JOIN virtual_redirect AS r ON (v.vid = r.vid)
+ WHERE redirect = {?} OR redirect = {?}',
+ $this->forlifeEmail(), $this->m4xForlifeEmail());
+ XDB::execute('DELETE FROM virtual_redirect
+ WHERE redirect = {?} OR redirect = {?}',
+ $this->forlifeEmail(), $this->m4xForlifeEmail());
+
+ if ($globals->mailstorage->googleapps_domain) {
+ require_once 'googleapps.inc.php';
+
+ if (GoogleAppsAccount::account_status($uid)) {
+ $account = new GoogleAppsAccount($user);
+ $account->suspend();
+ }
+ }
+ }
+
+ $mmlist = new MMList($this);
+ $mmlist->kill($alias, $clearAll);
+ }
+
// Return permission flags for a given permission level.
public static function makePerms($perms, $is_admin)
{
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2010 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 *
- ***************************************************************************/
-
-// {{{ function user_clear_all_subs()
-/** kills the inscription of a user.
- * we still keep his birthdate, adresses, and personnal stuff
- * kills the entreprises, mentor, emails and lists subscription stuff
- */
-function user_clear_all_subs($user_id, $really_del=true)
-{
- // keep datas in : aliases, adresses, tels, profile_education, profile_binets, contacts, groupesx_ins, homonymes, identification_ax, photo
- // delete in : profile_skills, emails, entreprises, profile_langskills, mentor,
- // mentor_pays, mentor_secteurs, newsletter_ins, perte_pass, requests, user_changes, virtual_redirect, watch_sub
- // + delete maillists
-
- global $globals;
- $uid = intval($user_id);
- $user = User::getSilent($uid);
- list($alias) = explode('@', $user->forlifeEmail());
-
- // TODO: clear profile.
- $tables_to_clear = array('uid' => array('profile_skills', 'profile_job', 'profile_langskills', 'profile_mentor_country',
- 'profile_mentor_sector', 'profile_mentor', 'perte_pass', 'watch_sub'),
- 'user_id' => array('requests', 'user_changes'));
-
- if ($really_del) {
- array_push($tables_to_clear['uid'], 'emails', 'group_members', 'contacts', 'adresses', 'profile_phones',
- 'photo', 'perte_pass', 'profile_langskills', 'forum_subs', 'forum_profiles');
- array_push($tables_to_clear['user_id'], 'newsletter_ins', 'profile_binets');
- $tables_to_clear['id'] = array('aliases');
- $tables_to_clear['contact'] = array('contacts');
- XDB::execute("UPDATE accounts
- SET registration_date = 0, state = 'pending', password = NULL, weak_password = NULL, token = NULL, is_admin = 0
- WHERE uid = {?}", $uid);
- XDB::execute("DELETE virtual.* FROM virtual INNER JOIN virtual_redirect AS r USING(vid) WHERE redirect = {?}",
- $alias.'@'.$globals->mail->domain);
- XDB::execute("DELETE virtual.* FROM virtual INNER JOIN virtual_redirect AS r USING(vid) WHERE redirect = {?}",
- $alias.'@'.$globals->mail->domain2);
- } else {
- XDB::execute("UPDATE accounts
- SET password = NULL, weak_password = NULL, token = NULL
- WHERE uid = {?}", $uid);
- }
-
- XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain);
- XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain2);
-
- /* TODO: handle both account and profile
- foreach ($tables_to_clear as $key=>&$tables) {
- foreach ($tables as $table) {
- XDB::execute("DELETE FROM $table WHERE $key={?}", $uid);
- }
- }*/
-
- $mmlist = new MMList($user);
- $mmlist->kill($alias, $really_del);
-
- // Deactivates, when available, the Google Apps account of the user.
- if ($globals->mailstorage->googleapps_domain) {
- require_once 'googleapps.inc.php';
- if (GoogleAppsAccount::account_status($uid)) {
- $account = new GoogleAppsAccount($user);
- $account->suspend();
- }
- }
-}
-
-// }}}
-
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
WHERE hrpid = {?}', $val, $pid);
$page->trigSuccess('Ajout du décès de ' . $name . ' le ' . $val . '.');
if($death == '0000-00-00' || empty($death)) {
- // TODO: FIX THIS DEPRECATED CALL
- require_once('user.func.inc.php');
- user_clear_all_subs($uid, false); // by default, dead ppl do not loose their email
+ $profile = Profile::get($pid);
+ $profile->clear();
+ $profile->owner()->clear(false);
}
}
}