X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FDirectMessage%2Factions%2Fapidirectmessage.php;fp=plugins%2FDirectMessage%2Factions%2Fapidirectmessage.php;h=20cb0c28906551ffa9da8cd185f0b0a0a11dbb5b;hb=4160a3fb730113f3d712bd777884c4b0482f6df1;hp=294f600deff3467c751e0cbdda5cf9370af9b5e6;hpb=abd90bbdf562614755802885dfb5673645df8575;p=quix0rs-gnu-social.git diff --git a/plugins/DirectMessage/actions/apidirectmessage.php b/plugins/DirectMessage/actions/apidirectmessage.php index 294f600def..20cb0c2890 100644 --- a/plugins/DirectMessage/actions/apidirectmessage.php +++ b/plugins/DirectMessage/actions/apidirectmessage.php @@ -30,9 +30,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Show a list of direct messages from or to the authenticating user @@ -62,13 +60,11 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return boolean success flag */ - function prepare(array $args=array()) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->user = $this->auth_user; - - if (empty($this->user)) { + if (!$this->scoped instanceof Profile) { // TRANS: Client error given when a user was not found (404). $this->clientError(_('No such user.'), 404); } @@ -83,30 +79,30 @@ class ApiDirectMessageAction extends ApiAuthAction $this->title = sprintf( // TRANS: Title. %s is a user nickname. _("Direct messages from %s"), - $this->user->nickname + $this->scoped->getNickname() ); $this->subtitle = sprintf( // TRANS: Subtitle. %s is a user nickname. _("All the direct messages sent from %s"), - $this->user->nickname + $this->scoped->getNickname() ); - $this->link = $server . $this->user->nickname . '/outbox'; + $this->link = $server . $this->scoped->getNickname() . '/outbox'; $this->selfuri_base = common_root_url() . 'api/direct_messages/sent'; - $this->id = "tag:$taguribase:SentDirectMessages:" . $this->user->id; + $this->id = "tag:$taguribase:SentDirectMessages:" . $this->scoped->getID(); } else { $this->title = sprintf( // TRANS: Title. %s is a user nickname. _("Direct messages to %s"), - $this->user->nickname + $this->scoped->getNickname() ); $this->subtitle = sprintf( // TRANS: Subtitle. %s is a user nickname. _("All the direct messages sent to %s"), - $this->user->nickname + $this->scoped->getNickname() ); - $this->link = $server . $this->user->nickname . '/inbox'; + $this->link = $server . $this->scoped->getNickname() . '/inbox'; $this->selfuri_base = common_root_url() . 'api/direct_messages'; - $this->id = "tag:$taguribase:DirectMessages:" . $this->user->id; + $this->id = "tag:$taguribase:DirectMessages:" . $this->scoped->getID(); } $this->messages = $this->getMessages(); @@ -114,18 +110,9 @@ class ApiDirectMessageAction extends ApiAuthAction return true; } - /** - * Handle the request - * - * Show the messages - * - * @param array $args $_REQUEST data (unused) - * - * @return void - */ - function handle(array $args=array()) + protected function handle() { - parent::handle($args); + parent::handle(); $this->showMessages(); } @@ -166,9 +153,9 @@ class ApiDirectMessageAction extends ApiAuthAction $message = new Message(); if ($this->arg('sent')) { - $message->from_profile = $this->user->id; + $message->from_profile = $this->scoped->getID(); } else { - $message->to_profile = $this->user->id; + $message->to_profile = $this->scoped->getID(); } if (!empty($this->max_id)) {