diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-24 15:48:27 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-24 15:48:27 -0800 |
commit | 3194a86caa02f5796f468a7d2ebc8e54139fb1cb (patch) | |
tree | 7e1047fd9ccc7da5cd078ddc7ca13147069881d6 /lib/subs.php | |
parent | 59be4b8cae992476628b23c2976d335e4f704c89 (diff) | |
parent | f0d1d07b94fbd2fe0ecd1c2f18d831a177d11c5c (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib/subs.php')
-rw-r--r-- | lib/subs.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/subs.php b/lib/subs.php index 1c240c475..e2ce0667e 100644 --- a/lib/subs.php +++ b/lib/subs.php @@ -42,4 +42,47 @@ function subs_unsubscribe_to($user, $other) } catch (Exception $e) { return $e->getMessage(); } -}
\ No newline at end of file +} + +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(); + } + } +} + |