From 51ac34e80c5a99008b1a945b2c00b6dbfdde1529 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 26 Jul 2009 13:06:38 -0600 Subject: first version of deleting users --- classes/Profile.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'classes/Profile.php') diff --git a/classes/Profile.php b/classes/Profile.php index f926b2cef..0ee6fa657 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -461,4 +461,79 @@ class Profile extends Memcached_DataObject $c->delete(common_cache_key('profile:notice_count:'.$this->id)); } } + + function delete() + { + $this->_deleteNotices(); + $this->_deleteSubscriptions(); + $this->_deleteMessages(); + $this->_deleteTags(); + $this->_deleteBlocks(); + + $related = array('Avatar', + 'Reply', + 'Group_member', + ); + + foreach ($related as $cls) { + $inst = new $cls(); + $inst->profile_id = $this->id; + $inst->delete(); + } + + parent::delete(); + } + + function _deleteNotices() + { + $notice = new Notice(); + $notice->profile_id = $this->id; + + if ($notice->find()) { + while ($notice->fetch()) { + $other = clone($notice); + $other->delete(); + } + } + } + + function _deleteSubscriptions() + { + $sub = new Subscription(); + $sub->subscriber = $this->id; + $sub->delete(); + + $subd = new Subscription(); + $subd->subscribed = $this->id; + $subd->delete(); + } + + function _deleteMessages() + { + $msg = new Message(); + $msg->from_profile = $this->id; + $msg->delete(); + + $msg = new Message(); + $msg->to_profile = $this->id; + $msg->delete(); + } + + function _deleteTags() + { + $tag = new Profile_tag(); + $tag->tagged = $this->id; + $msg->delete(); + } + + function _deleteBlocks() + { + $block = new Profile_block(); + $block->blocked = $this->id; + $block->delete(); + + $block = new Group_block(); + $block->blocked = $this->id; + $block->delete(); + } } -- cgit v1.2.3-54-g00ecf