X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapitimelinementions.php;h=6465cdf85e58ec6e525a866b233a69567679a56d;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=2b5053a84f5df0822bafec5454e819abf6d2ccb6;hpb=d544c78276e6b822e94e7714a98f73b941189185;p=quix0rs-gnu-social.git diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index 2b5053a84f..6465cdf85e 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -38,8 +38,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apibareauth.php'; - /** * Returns the most recent (default 20) mentions (status containing @nickname) * @@ -66,16 +64,15 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction * * @return boolean success flag */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->user = $this->getTargetUser($this->arg('id')); + $this->target = $this->getTargetProfile($this->arg('id')); - if (empty($this->user)) { + if (!($this->target instanceof Profile)) { // TRANS: Client error displayed when requesting most recent mentions for a non-existing user. - $this->clientError(_('No such user.'), 404, $this->format); - return; + $this->clientError(_('No such user.'), 404); } $this->notices = $this->getNotices(); @@ -88,13 +85,11 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction * * Just show the notices * - * @param array $args $_REQUEST data (unused) - * * @return void */ - function handle($args) + protected function handle() { - parent::handle($args); + parent::handle(); $this->showTimeline(); } @@ -105,33 +100,28 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction */ function showTimeline() { - $profile = $this->user->getProfile(); - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - $sitename = common_config('site', 'name'); $title = sprintf( // TRANS: Title for timeline of most recent mentions of a user. // TRANS: %1$s is the StatusNet sitename, %2$s is a user nickname. _('%1$s / Updates mentioning %2$s'), - $sitename, $this->user->nickname + $sitename, $this->target->nickname ); $taguribase = TagURI::base(); - $id = "tag:$taguribase:Mentions:" . $this->user->id; - $link = common_local_url( - 'replies', - array('nickname' => $this->user->nickname) - ); + $id = "tag:$taguribase:Mentions:" . $this->target->id; + $logo = $this->target->avatarUrl(AVATAR_PROFILE_SIZE); + $link = common_local_url('replies', + array('nickname' => $this->target->nickname)); $self = $this->getSelfUri(); $subtitle = sprintf( // TRANS: Subtitle for timeline of most recent mentions of a user. // TRANS: %1$s is the StatusNet sitename, %2$s is a user nickname, // TRANS: %3$s is a user's full name. - _('%1$s updates that reply to updates from %2$s / %3$s.'), - $sitename, $this->user->nickname, $profile->getBestName() + _('%1$s updates that reply to updates from %3$s / %2$s.'), + $sitename, $this->target->nickname, $this->target->getBestName() ); - $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); switch($this->format) { case 'xml': @@ -170,7 +160,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $this->showJsonTimeline($this->notices); break; case 'as': - header('Content-Type: application/json; charset=utf-8'); + header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE); $doc = new ActivityStreamJSONDocument($this->auth_user); $doc->setTitle($title); $doc->addLink($link, 'alternate', 'text/html'); @@ -193,13 +183,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction { $notices = array(); - if (empty($this->auth_user)) { - $profile = null; - } else { - $profile = $this->auth_user->getProfile(); - } - - $stream = new ReplyNoticeStream($this->user->id, $profile); + $stream = new ReplyNoticeStream($this->target->id, $this->scoped); $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, @@ -220,7 +204,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction * * @return boolean true */ - function isReadOnly($args) + function isReadOnly(array $args=array()) { return true; } @@ -258,7 +242,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction array($this->arg('action'), common_user_cache_hash($this->auth_user), common_language(), - $this->user->id, + $this->target->id, strtotime($this->notices[0]->created), strtotime($this->notices[$last]->created)) )