]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Static method to get a profile based on an URI
authorEvan Prodromou <evan@status.net>
Wed, 1 Sep 2010 20:15:22 +0000 (16:15 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 1 Sep 2010 20:15:22 +0000 (16:15 -0400)
classes/Profile.php

index d7617f0b74c0a27afbbd67ee20bb1ef7c03d1bf4..87cfab0e011117174558a85a62fbfc195c224537 100644 (file)
@@ -960,4 +960,24 @@ class Profile extends Memcached_DataObject
 
         return $feed;
     }
+
+    static function fromURI($uri)
+    {
+        $profile = null;
+
+        if (Event::handle('StartGetProfileFromURI', array($uri, &$profile))) {
+            // Get a local user or remote (OMB 0.1) profile
+            $user = User::staticGet('uri', $uri);
+            if (!empty($user)) {
+                $profile = $user->getProfile();
+            } else {
+                $remote_profile = Remote_profile::staticGet('uri', $uri);
+                if (!empty($remote_profile)) {
+                    $profile = Profile::staticGet('id', $remote_profile->profile_id);
+                }
+            }
+            Event::handle('EndGetProfileFromURI', array($uri, $profile));
+        }
+
+    }
 }