From c1c7feedbd11cc291a0fb68ea8c4d322eb8bf538 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 31 Mar 2010 15:02:19 -0400 Subject: do complete unsubscribe process when deleting a user --- classes/Profile.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Profile.php b/classes/Profile.php index eded1ff71..5de35c191 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -577,11 +577,41 @@ class Profile extends Memcached_DataObject { $sub = new Subscription(); $sub->subscriber = $this->id; - $sub->delete(); + + $sub->find(); + + while ($sub->fetch()) { + $other = Profile::staticGet('id', $sub->subscribed); + if (empty($other)) { + continue; + } + if ($other->id == $this->id) { + continue; + } + Subscription::cancel($this, $other); + } $subd = new Subscription(); $subd->subscribed = $this->id; - $subd->delete(); + $subd->find(); + + while ($subd->fetch()) { + $other = Profile::staticGet('id', $subd->subscriber); + if (empty($other)) { + continue; + } + if ($other->id == $this->id) { + continue; + } + Subscription::cancel($other, $this); + } + + $self = new Subscription(); + + $self->subscriber = $this->id; + $self->subscribed = $this->id; + + $self->delete(); } function _deleteMessages() -- cgit v1.2.3-54-g00ecf From d3f995846b2a849bc53eb965eb2607d8d1d6dd34 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 31 Mar 2010 15:20:16 -0400 Subject: use Subscription::cancel() to cancel all subscriptions on block --- classes/User.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'classes') diff --git a/classes/User.php b/classes/User.php index 659ec9467..2c256301c 100644 --- a/classes/User.php +++ b/classes/User.php @@ -525,8 +525,8 @@ class User extends Memcached_DataObject common_log(LOG_WARNING, sprintf( "Profile ID %d (%s) tried to block his or herself.", - $profile->id, - $profile->nickname + $this->id, + $this->nickname ) ); return false; @@ -548,13 +548,7 @@ class User extends Memcached_DataObject return false; } - // Cancel their subscription, if it exists - - $otherUser = User::staticGet('id', $other->id); - - if (!empty($otherUser)) { - subs_unsubscribe_to($otherUser, $this->getProfile()); - } + Subscription::cancel($other, $this->getProfile()); $block->query('COMMIT'); -- cgit v1.2.3-54-g00ecf