From 3bb42d117027ebf610481ca3b0733854e0127e56 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 19:00:02 +0000 Subject: Use poster's subscribed groups to disambiguate group linking when a remote group and a local group exist with the same name. (If you're a member of two groups with the same name though, there's not a defined winner.) --- classes/User_group.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'classes/User_group.php') diff --git a/classes/User_group.php b/classes/User_group.php index 64fe024b3..1a5ddf253 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -279,12 +279,26 @@ class User_group extends Memcached_DataObject return true; } - static function getForNickname($nickname) + static function getForNickname($nickname, $profile=null) { $nickname = common_canonical_nickname($nickname); - $group = User_group::staticGet('nickname', $nickname); + + // Are there any matching remote groups this profile's in? + if ($profile) { + $group = $profile->getGroups(); + while ($group->fetch()) { + if ($group->nickname == $nickname) { + // @fixme is this the best way? + return clone($group); + } + } + } + + // If not, check local groups. + + $group = Local_group::staticGet('nickname', $nickname); if (!empty($group)) { - return $group; + return User_group::staticGet('id', $group->group_id); } $alias = Group_alias::staticGet('alias', $nickname); if (!empty($alias)) { -- cgit v1.2.3-54-g00ecf