From 7bec455a2120607a0aacb8be03cd60372cc5d0c1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 1 Sep 2010 16:15:22 -0400 Subject: [PATCH] Static method to get a profile based on an URI --- classes/Profile.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/classes/Profile.php b/classes/Profile.php index d7617f0b74..87cfab0e01 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)); + } + + } } -- 2.39.5