From 51dda412113d168476fabd15f346678bd2d301b6 Mon Sep 17 00:00:00 2001 From: millette Date: Wed, 3 Dec 2008 11:49:42 -0500 Subject: [PATCH] delete user and all traces from the db. darcs-hash:20081203164942-099f7-ea511948139c9c18b1c8b7de018aa4f0ee5ff624.gz --- actions/profilesettings.php | 99 ++++++++++++++++++++++++++++++++----- classes/Notice.php | 2 +- 2 files changed, 87 insertions(+), 14 deletions(-) diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 81e589c6e0..f0083b219d 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -509,22 +509,95 @@ class ProfilesettingsAction extends SettingsAction { } function delete_account() { - $user = common_current_user(); assert(!is_null($user)); # should already be checked - // delete avatar (profile_id and filename) - // delete fave (user_id) - // delete message (from_profile, to_profile) - // delete notice (profile_id) (also delete from notice_source and notice_tag) - // delete notice_inbox (user_id) - // delete subscription (subscriber, subscribed) - // delete user (id) - // delete user_openid (user_id) - // delete profile (id) - // delete tags tables (to verify) - // delete all the users notices + // deleted later through the profile + /* + $avatar = new Avatar; + $avatar->profile_id = $user->id; + $n_avatars_deleted = $avatar->delete(); + */ - $this->show_form(_('Your account has been deleted.'), true); + $fave = new Fave; + $fave->user_id = $user->id; + $n_faves_deleted = $fave->delete(); + + $confirmation = new Confirm_address; + $confirmation->user_id = $user->id; + $n_confirmations_deleted = $confirmation->delete(); + + // TODO foreign stuff... + + $invitation = new Invitation; + $invitation->user_id = $user->id; + $n_invitations_deleted = $invitation->delete(); + + $message_from = new Message; + $message_from->from_profile = $user->id; + $n_messages_from_deleted = $message_from->delete(); + + $message_to = new Message; + $message_to->to_profile = $user->id; + $n_messages_to_deleted = $message_to->delete(); + + $notice = new Notice; + $notice->profile_id = $user->id; + $n_notices_deleted = $notice->delete(); + + $notice_inbox = new Notice_inbox; + $notice_inbox->user_id = $user->id; + $n_notices_inbox_deleted = $notice_inbox->delete(); + + $profile_tagger = new Profile_tag; + $profile_tagger->tagger = $user->id; + $n_profiles_tagger_deleted = $profile_tagger->delete(); + + $profile_tagged = new Profile_tag; + $profile_tagged->tagged = $user->id; + $n_profiles_tagged_deleted = $profile_tagged->delete(); + + $remember_me = new Remember_me; + $remember_me->user_id = $user->id; + $n_remember_mes_deleted = $remember_me->delete(); + + $reply_from = new Reply; + $reply_from->profile_id = $user->id; + $n_replies_from_deleted = $reply_from->delete(); + + // not sure if this should be deleted... + //TODO: test + if (1) { + $reply_to = new Reply; + $reply_to->replied_id = $user->id; + $reply_to->find(); + while ($reply_to->fetch()) { + $str = print_r($reply_to, true); + } +// $n_replies_to_deleted = $reply_to->delete(); + } + + $subscriber = new Subscription; + $subscriber->subscriber = $user->id; + $n_subscribers_deleted = $subscriber->delete(); + + $subscribed = new Subscription; + $subscribed->subscribed = $user->id; + $n_subscribeds_deleted = $subscribed->delete(); + + $user_openid = new User_openid; + $user_openid->user_id = $user->id; + $n_user_openids_deleted = $user_openid->delete(); + + // last steps + if (0) { + $profile = new Profile; + $profile->id = $user->id; + $profile->delete_avatars(); + $n_profiles_deleted = $profile->delete(); + $n_users_deleted = $user->delete(); + } + + $this->show_form(_("Your account has been deleted. ($str)"), true); } } diff --git a/classes/Notice.php b/classes/Notice.php index 83862ae959..8de34f39c9 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -61,7 +61,7 @@ class Notice extends Memcached_DataObject $this->blowCaches(true); $this->blowFavesCache(true); $this->blowInboxes(); - parent::delete(); + return parent::delete(); } function saveTags() {