From 7bec455a2120607a0aacb8be03cd60372cc5d0c1 Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Wed, 1 Sep 2010 16:15:22 -0400
Subject: Static method to get a profile based on an URI

---
 classes/Profile.php | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'classes/Profile.php')

diff --git a/classes/Profile.php b/classes/Profile.php
index d7617f0b7..87cfab0e0 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -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));
+        }
+
+    }
 }
-- 
cgit v1.2.3-54-g00ecf


From 974ac48771915406527b4f2e5670c7e7cb5aa314 Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Wed, 1 Sep 2010 16:55:16 -0400
Subject: bug in Profile::fromURI() wasn't returning profile

---
 classes/Profile.php | 1 +
 1 file changed, 1 insertion(+)

(limited to 'classes/Profile.php')

diff --git a/classes/Profile.php b/classes/Profile.php
index 87cfab0e0..8f8679550 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -979,5 +979,6 @@ class Profile extends Memcached_DataObject
             Event::handle('EndGetProfileFromURI', array($uri, $profile));
         }
 
+        return $profile;
     }
 }
-- 
cgit v1.2.3-54-g00ecf