From 0d0e51292d97e0b3a07cf1d12031df0b8f69823f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 15:32:57 -0800 Subject: some User -> Profile cleanup to help in adapting the profile page action to show stuff for remote users. Subscriptions, groups, roles, etc are all on profiles now so go ahead and use em. --- classes/Profile.php | 23 +++++++++++++++++++++++ classes/User.php | 7 ++++--- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'classes') diff --git a/classes/Profile.php b/classes/Profile.php index 37d2c571f..b11cffc77 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -473,6 +473,29 @@ class Profile extends Memcached_DataObject return $cnt; } + /** + * Is this profile subscribed to another profile? + * + * @param Profile $other + * @return boolean + */ + function isSubscribed($other) + { + return Subscription::exists($this, $other); + } + + /** + * Are these two profiles subscribed to each other? + * + * @param Profile $other + * @return boolean + */ + function mutuallySubscribed($other) + { + return $this->isSubscribed($other) && + $other->isSubscribed($this); + } + function hasFave($notice) { $cache = common_memcache(); diff --git a/classes/User.php b/classes/User.php index 7345dc7f9..964bc3e7f 100644 --- a/classes/User.php +++ b/classes/User.php @@ -84,7 +84,8 @@ class User extends Memcached_DataObject function isSubscribed($other) { - return Subscription::exists($this->getProfile(), $other); + $profile = $this->getProfile(); + return $profile->isSubscribed($other); } // 'update' won't write key columns, so we have to do it ourselves. @@ -418,8 +419,8 @@ class User extends Memcached_DataObject function mutuallySubscribed($other) { - return $this->isSubscribed($other) && - $other->isSubscribed($this); + $profile = $this->getProfile(); + return $profile->mutuallySubscribed($other); } function mutuallySubscribedUsers() -- cgit v1.2.3-54-g00ecf