* @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
*
* @return boolean success flag
*/
- function prepare($args)
+ 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);
}
$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();
$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)) {
* @link http://status.net/
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Creates a new direct message from the authenticating user to
{
parent::prepare($args);
- if (empty($this->user)) {
+ if (!$this->scoped instanceof Profile) {
// TRANS: Client error when user not found for an API direct message action.
$this->clientError(_('No such user.'), 404);
}
if (!$this->other instanceof Profile) {
// TRANS: Client error displayed if a recipient user could not be found (403).
$this->clientError(_('Recipient user not found.'), 403);
- } else if (!$this->user->mutuallySubscribed($this->other)) {
+ } else if (!$this->scoped->mutuallySubscribed($this->other)) {
// TRANS: Client error displayed trying to direct message another user who's not a friend (403).
$this->clientError(_('Cannot send direct messages to users who aren\'t your friend.'), 403);
- } else if ($this->user->id == $this->other->id) {
+ } else if ($this->scoped->getID() === $this->other->getID()) {
// Note: sending msgs to yourself is allowed by Twitter
}
$message = Message::saveNew(
- $this->user->id,
- $this->other->id,
+ $this->scoped->getID(),
+ $this->other->getID(),
html_entity_decode($this->content, ENT_NOQUOTES, 'UTF-8'),
$this->source
);