summaryrefslogtreecommitdiff
path: root/classes/Profile.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-16 20:13:39 -0800
committerZach Copley <zach@status.net>2010-02-16 20:13:39 -0800
commit2cb243808c2c1540f2690bff5a2d9932fa428923 (patch)
tree297da030cf7ba347f2cb72308cef4c9f39c36710 /classes/Profile.php
parentb2a502b33616cdcbf23a8bccd32f75d17c95a713 (diff)
More sensical profile::getUri()
Diffstat (limited to 'classes/Profile.php')
-rw-r--r--classes/Profile.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index 5a86619fd..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();
@@ -832,21 +832,40 @@ class Profile extends Memcached_DataObject
return $xs->getString();
}
+ /**
+ * Returns the best URI for a profile. Plugins may override.
+ *
+ * @return string $uri
+ */
function getUri()
{
- if (Event::handle('GetProfileUri', array($this))) {
+ $uri = null;
- $remote = Remote_profile::staticGet('id', $this->id);
+ // check for a local user first
+ $user = User::staticGet('id', $this->id);
- if (!empty($remote)) {
- return $remote->uri;
- } else {
- return common_local_url(
- 'userbyid',
- array('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;
}
}