diff options
author | Craig Andrews <candrews@integralblue.com> | 2010-02-24 20:52:45 -0500 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2010-02-24 20:52:45 -0500 |
commit | c187bf55974347f7ddb4f28714af57861dce8f08 (patch) | |
tree | 4398b456d88ce79977959b25ba1a0f6fe0c1d77f /classes/Profile.php | |
parent | 20d6a7caed6636c28cc7b95c584549691dff4388 (diff) | |
parent | 8914b69d5055c1bc7d0604ee338ffdaf6b0a8606 (diff) |
Merge branch '0.9.x' into 1.0.x
Conflicts:
EVENTS.txt
db/statusnet.sql
lib/queuemanager.php
Diffstat (limited to 'classes/Profile.php')
-rw-r--r-- | classes/Profile.php | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/classes/Profile.php b/classes/Profile.php index ab05bb854..78223b34a 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(); @@ -792,51 +792,59 @@ class Profile extends Memcached_DataObject * Returns an XML string fragment with profile information as an * Activity Streams noun object with the given element type. * - * Assumes that 'activity' namespace has been previously defined. + * Assumes that 'activity', 'georss', and 'poco' namespace has been + * previously defined. * * @param string $element one of 'actor', 'subject', 'object', 'target' + * * @return string */ function asActivityNoun($element) { - $xs = new XMLStringer(true); + $noun = ActivityObject::fromProfile($this); + return $noun->asString('activity:' . $element); + } - $xs->elementStart('activity:' . $element); - $xs->element( - 'activity:object-type', - null, - 'http://activitystrea.ms/schema/1.0/person' - ); - $xs->element( - 'id', - null, - common_local_url( - 'userbyid', - array('id' => $this->id) - ) - ); - $xs->element('title', null, $this->getBestName()); - - $avatar = $this->getAvatar(AVATAR_PROFILE_SIZE); - - $xs->element( - 'link', array( - 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype, - 'href' => empty($avatar) - ? Avatar::defaultImage(AVATAR_PROFILE_SIZE) - : $avatar->displayUrl() - ), - '' - ); - - $xs->elementEnd('activity:' . $element); + /** + * Returns the best URI for a profile. Plugins may override. + * + * @return string $uri + */ + function getUri() + { + $uri = null; - return $xs->getString(); + // give plugins a chance to set the URI + if (Event::handle('StartGetProfileUri', array($this, &$uri))) { + + // check for a local user first + $user = User::staticGet('id', $this->id); + + if (!empty($user)) { + $uri = $user->uri; + } else { + // 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; } - function getAcctUri() + function hasBlocked($other) { - return $this->nickname . '@' . common_config('site', 'server'); - } + $block = Profile_block::get($this->id, $other->id); + if (empty($block)) { + $result = false; + } else { + $result = true; + } + + return $result; + } } |