X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile.php;h=6b396c8c340b64115b7c4377b3d148c1921eba23;hb=1a86bf9c65d2579d9245c6edcc968fed3d674f39;hp=1076fb2cb3e09f8b95b1915b36f1b6bb5ffbcef6;hpb=663e4e02a1b3b1c104c2c3db19e524a486c3d981;p=quix0rs-gnu-social.git diff --git a/classes/Profile.php b/classes/Profile.php index 1076fb2cb3..6b396c8c34 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -716,6 +716,7 @@ class Profile extends Memcached_DataObject switch ($right) { case Right::DELETEOTHERSNOTICE: + case Right::MAKEGROUPADMIN: case Right::SANDBOXUSER: case Right::SILENCEUSER: case Right::DELETEUSER: @@ -753,4 +754,130 @@ class Profile extends Memcached_DataObject return !empty($notice); } + + /** + * Returns an XML string fragment with limited profile information + * as an Atom element. + * + * Assumes that Atom has been previously set up as the base namespace. + * + * @return string + */ + function asAtomAuthor() + { + $xs = new XMLStringer(true); + + $xs->elementStart('author'); + $xs->element('name', null, $this->nickname); + $xs->element('uri', null, $this->getUri()); + $xs->elementEnd('author'); + + return $xs->getString(); + } + + /** + * Returns an XML string fragment with profile information as an + * Activity Streams element. + * + * Assumes that 'activity' namespace has been previously defined. + * + * @return string + */ + function asActivityActor() + { + return $this->asActivityNoun('actor'); + } + + /** + * 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. + * + * @param string $element one of 'actor', 'subject', 'object', 'target' + * @return string + */ + function asActivityNoun($element) + { + $xs = new XMLStringer(true); + + $xs->elementStart('activity:' . $element); + $xs->element( + 'activity:object-type', + null, + 'http://activitystrea.ms/schema/1.0/person' + ); + $xs->element( + 'id', + null, + $this->getUri() + ); + $xs->element('title', null, $this->getBestName()); + + $avatar = $this->getAvatar(AVATAR_PROFILE_SIZE); + + $xs->element( + 'link', array( + 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype, + 'rel' => 'avatar', + 'href' => empty($avatar) + ? Avatar::defaultImage(AVATAR_PROFILE_SIZE) + : $avatar->displayUrl() + ), + '' + ); + + $xs->elementEnd('activity:' . $element); + + return $xs->getString(); + } + + /** + * Returns the best URI for a profile. Plugins may override. + * + * @return string $uri + */ + function getUri() + { + $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; + } + + function hasBlocked($other) + { + $block = Profile_block::get($this->id, $other->id); + + if (empty($block)) { + $result = false; + } else { + $result = true; + } + + return $result; + } }