diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-17 10:14:08 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-17 10:14:08 -0800 |
commit | 5a6cbb248f8cdcb171ea5540e6a6c2eb10506a82 (patch) | |
tree | c72830bef3388b1ceb19cc6ef688177122961435 /classes/Profile.php | |
parent | 46e9aa13aa87955b441bc63b7cf2f58622b131b0 (diff) | |
parent | 3cb6b1670bd7e3860fdca217e4075f51378fe5e0 (diff) |
Merge branch 'testing' into 0.9.x
Diffstat (limited to 'classes/Profile.php')
-rw-r--r-- | classes/Profile.php | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/classes/Profile.php b/classes/Profile.php index ab05bb854..494c697e4 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -769,7 +769,7 @@ class Profile extends Memcached_DataObject $xs->elementStart('author'); $xs->element('name', null, $this->nickname); - $xs->element('uri', null, $this->profileurl); + $xs->element('uri', null, $this->getUri()); $xs->elementEnd('author'); return $xs->getString(); @@ -810,10 +810,7 @@ class Profile extends Memcached_DataObject $xs->element( 'id', null, - common_local_url( - 'userbyid', - array('id' => $this->id) - ) + $this->getUri() ); $xs->element('title', null, $this->getBestName()); @@ -822,6 +819,7 @@ class Profile extends Memcached_DataObject $xs->element( 'link', array( 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype, + 'rel' => 'avatar', 'href' => empty($avatar) ? Avatar::defaultImage(AVATAR_PROFILE_SIZE) : $avatar->displayUrl() @@ -834,9 +832,40 @@ class Profile extends Memcached_DataObject return $xs->getString(); } - function getAcctUri() + /** + * Returns the best URI for a profile. Plugins may override. + * + * @return string $uri + */ + function getUri() { - return $this->nickname . '@' . common_config('site', 'server'); + $uri = null; + + // check for a local user first + $user = User::staticGet('id', $this->id); + + if (!empty($user)) { + $uri = common_local_url( + 'userbyid', + array('id' => $user->id) + ); + } else { + + // give plugins a chance to set the URI + if (Event::handle('StartGetProfileUri', array($this, &$uri))) { + + // return OMB profile if any + $remote = Remote_profile::staticGet('id', $this->id); + + if (!empty($remote)) { + $uri = $remote->uri; + } + + Event::handle('EndGetProfileUri', array($this, &$uri)); + } + } + + return $uri; } } |