]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
Merge commit 'origin/testing' into 0.9.x
[quix0rs-gnu-social.git] / classes / User_group.php
index e9288747467472491459be7b6c72868557040107..7be55163a30186c0199f1ffc36dc82692b370089 100644 (file)
@@ -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)) {
@@ -441,6 +455,11 @@ class User_group extends Memcached_DataObject
         $group = new User_group();
 
         $group->query('BEGIN');
+        
+        if (empty($uri)) {
+            // fill in later...
+            $uri = null;
+        }
 
         $group->nickname    = $nickname;
         $group->fullname    = $fullname;