summaryrefslogtreecommitdiff
path: root/classes/Profile.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2009-10-13 16:45:26 +0000
committerBrion Vibber <brion@pobox.com>2009-10-13 16:45:26 +0000
commit834ac7aa1172518c112bbf90561ead34499e20b8 (patch)
tree474dc49eed8ff3542e6d2c8154e14fa4b8432ada /classes/Profile.php
parent18df82ba2302d5b72bc42f4d3296d6fff7d16341 (diff)
parent006cfc528edab32548d1265df5dada09a1536aed (diff)
Merge branch '0.8.x' of git@gitorious.org:~brion/statusnet/brion-fixes into 0.8.x
Diffstat (limited to 'classes/Profile.php')
-rw-r--r--classes/Profile.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index 6ad0e7a3a..8385ebf88 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;
+ $tag->delete();
+ }
+
+ function _deleteBlocks()
+ {
+ $block = new Profile_block();
+ $block->blocked = $this->id;
+ $block->delete();
+
+ $block = new Group_block();
+ $block->blocked = $this->id;
+ $block->delete();
+ }
}