summaryrefslogtreecommitdiff
path: root/classes/Profile.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2009-10-04 16:16:52 -0700
committerBrion Vibber <brion@pobox.com>2009-10-04 16:16:52 -0700
commit4462a1c63600fa83d2692ac2de8067b12b1eeac9 (patch)
treea946b98184eb32b5be4bf64e67357c06e8d0f65d /classes/Profile.php
parent9235c1437e542d2b565d2d2d36fe2b7561e4d5f7 (diff)
parent2f065d687dc76bfbac3e1b7b3dcccf544f4b4987 (diff)
Merge branch '0.9.x' of git://gitorious.org/statusnet/mainline into 0.9.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 7f0d12758..4a069ee84 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -476,4 +476,79 @@ class Profile extends Memcached_DataObject
$biolimit = self::maxBio();
return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
}
+
+ 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();
+ }
}