123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class ShowmessageAction extends Action
- {
-
- var $message = null;
-
- var $user = null;
-
- function prepare(array $args = array())
- {
- parent::prepare($args);
- $this->page = 1;
- $id = $this->trimmed('message');
- $this->message = Message::getKV('id', $id);
- if (!$this->message) {
-
- $this->clientError(_('No such message.'), 404);
- }
- $this->user = common_current_user();
- if (empty($this->user) ||
- ($this->user->id != $this->message->from_profile &&
- $this->user->id != $this->message->to_profile)) {
-
- throw new ClientException(_('Only the sender and recipient ' .
- 'may read this message.'), 403);
- }
- return true;
- }
- function handle()
- {
- $this->showPage();
- }
- function title()
- {
- if ($this->user->id == $this->message->from_profile) {
- $to = $this->message->getTo();
-
-
-
- return sprintf(_('Message to %1$s on %2$s'),
- $to->nickname,
- common_exact_date($this->message->created));
- } else if ($this->user->id == $this->message->to_profile) {
- $from = $this->message->getFrom();
-
-
-
- return sprintf(_('Message from %1$s on %2$s'),
- $from->nickname,
- common_exact_date($this->message->created));
- }
- }
- function showContent()
- {
- $this->elementStart('ul', 'notices messages');
- $ml = new ShowMessageListItem($this, $this->message, $this->user);
- $ml->show();
- $this->elementEnd('ul');
- }
- function isReadOnly($args)
- {
- return true;
- }
-
- function showAside() {
- }
- }
- class ShowMessageListItem extends MessageListItem
- {
- var $user;
- function __construct($out, $message, $user)
- {
- parent::__construct($out, $message);
- $this->user = $user;
- }
- function getMessageProfile()
- {
- if ($this->user->id == $this->message->from_profile) {
- return $this->message->getTo();
- } else if ($this->user->id == $this->message->to_profile) {
- return $this->message->getFrom();
- } else {
-
- return null;
- }
- }
- }
|