]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Link and distribute notices tagged for a group alias
authorEvan Prodromou <evan@controlyourself.ca>
Mon, 15 Jun 2009 06:43:47 +0000 (23:43 -0700)
committerEvan Prodromou <evan@controlyourself.ca>
Mon, 15 Jun 2009 06:43:47 +0000 (23:43 -0700)
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.

classes/Notice.php
classes/User_group.php
lib/util.php

index 78786b27de87b49be365c9f654e1272eaea4d1a6..68602b1f7cbd8e3ac4568043250fac34731bfc4b 100644 (file)
@@ -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);
index 0fcfee8c62e7739bb234a663f793a52ab5dd55a5..1a24124bb176413e70bfe2b31702d39ddfbdcf14 100644 (file)
@@ -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;
+    }
 }
index b3a94a5a011ffe1d947d907a5ceb4e690f0548d1..49c6ae108e4214d7fb873c0686fcd5099daebbe0 100644 (file)
@@ -591,7 +591,7 @@ function common_at_link($sender_id, $nickname)
 function common_group_link($sender_id, $nickname)
 {
     $sender = Profile::staticGet($sender_id);
-    $group = User_group::staticGet('nickname', common_canonical_nickname($nickname));
+    $group = User_group::getForNickname($nickname);
     if ($group && $sender->isMember($group)) {
         $attrs = array('href' => $group->permalink(),
                        'class' => 'url');