diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-06-14 23:43:47 -0700 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-06-14 23:43:47 -0700 |
commit | 1b6b00a6d05ad646a9137a872af8d8fdeeaf260f (patch) | |
tree | d298ff338dcfb09a42bdd6ee5e133f669e1ce40e /classes | |
parent | ecbd7718d57fc427d2aeac885d8be0321b3cf1fe (diff) |
Link and distribute notices tagged for a group alias
Correctly link and distribute notices tagged for a group alias. Added
a helper function, getForNickname(), to User_group, to make it easier
to get a group by its nickname or aliases.
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Notice.php | 6 | ||||
-rw-r--r-- | classes/User_group.php | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/classes/Notice.php b/classes/Notice.php index 78786b27d..68602b1f7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -752,16 +752,16 @@ class Notice extends Memcached_DataObject foreach (array_unique($match[1]) as $nickname) { /* XXX: remote groups. */ - $group = User_group::staticGet('nickname', $nickname); + $group = User_group::getForNickname($nickname); - if (!$group) { + if (empty($group)) { continue; } // we automatically add a tag for every group name, too $tag = Notice_tag::pkeyGet(array('tag' => common_canonical_tag($nickname), - 'notice_id' => $this->id)); + 'notice_id' => $this->id)); if (is_null($tag)) { $this->saveTag($nickname); diff --git a/classes/User_group.php b/classes/User_group.php index 0fcfee8c6..1a24124bb 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -225,4 +225,18 @@ class User_group extends Memcached_DataObject return true; } + + static function getForNickname($nickname) + { + $nickname = common_canonical_nickname($nickname); + $group = User_group::staticGet('nickname', $nickname); + if (!empty($group)) { + return $group; + } + $alias = Group_alias::staticGet('alias', $nickname); + if (!empty($alias)) { + return User_group::staticGet('id', $alias->group_id); + } + return null; + } } |