summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2010-03-11 20:40:25 -0500
committerCraig Andrews <candrews@integralblue.com>2010-03-11 20:40:25 -0500
commita715271f847fed7d7c725c5b752ea7a00800520a (patch)
tree1ad234842499d59834d0dffcb45e2ea086e1602e /lib
parentd6e0640251b91928fc65324438000d91f12cecf0 (diff)
reuse Subscription::cancel instead of reimplementing it.
I didn't know this method existed before... pretty neat.
Diffstat (limited to 'lib')
-rw-r--r--lib/command.php2
-rw-r--r--lib/subs.php43
2 files changed, 1 insertions, 44 deletions
diff --git a/lib/command.php b/lib/command.php
index 0b3b3c95a..3809c98cc 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -729,7 +729,7 @@ class LoseCommand extends Command
return;
}
- $result=subs_unsubscribe_from($this->user, $this->other);
+ $result = Subscription::cancel($this->other, $this->user);
if ($result) {
$channel->output($this->user, sprintf(_('Unsubscribed %s'), $this->other));
diff --git a/lib/subs.php b/lib/subs.php
index e2ce0667e..165bbaa8f 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -43,46 +43,3 @@ function subs_unsubscribe_to($user, $other)
return $e->getMessage();
}
}
-
-function subs_unsubscribe_from($user, $other){
- $local = User::staticGet("nickname",$other);
- if($local){
- return subs_unsubscribe_to($local,$user);
- } else {
- try {
- $remote = Profile::staticGet("nickname",$other);
- if(is_string($remote)){
- return $remote;
- }
- if (Event::handle('StartUnsubscribe', array($remote,$user))) {
-
- $sub = DB_DataObject::factory('subscription');
-
- $sub->subscriber = $remote->id;
- $sub->subscribed = $user->id;
-
- $sub->find(true);
-
- // note we checked for existence above
-
- if (!$sub->delete())
- return _('Couldn\'t delete subscription.');
-
- $cache = common_memcache();
-
- if ($cache) {
- $cache->delete(common_cache_key('user:notices_with_friends:' . $remote->id));
- }
-
-
- $user->blowSubscribersCount();
- $remote->blowSubscribersCount();
-
- Event::handle('EndUnsubscribe', array($remote, $user));
- }
- } catch (Exception $e) {
- return $e->getMessage();
- }
- }
-}
-