3 * StatusNet, the distributed open-source microblogging tool
5 * Show a single message
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2008-2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
29 if (!defined('STATUSNET') && !defined('LACONICA')) {
33 require_once INSTALLDIR.'/lib/mailbox.php';
36 * Show a single message
38 * // XXX: It is totally weird how this works!
42 * @author Evan Prodromou <evan@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
46 class ShowmessageAction extends MailboxAction
49 * Message object to show
60 * Load attributes based on database arguments
62 * Loads all the DB stuff
64 * @param array $args $_REQUEST array
66 * @return success flag
68 function prepare($args)
70 parent::prepare($args);
74 $id = $this->trimmed('message');
75 $this->message = Message::staticGet('id', $id);
77 if (!$this->message) {
78 // TRANS: Client error displayed requesting a single message that does not exist.
79 $this->clientError(_('No such message.'), 404);
83 $this->user = common_current_user();
88 function handle($args)
90 Action::handle($args);
92 if ($this->user && ($this->user->id == $this->message->from_profile ||
93 $this->user->id == $this->message->to_profile)) {
96 // TRANS: Client error displayed requesting a single direct message the requesting user was not a party in.
97 $this->clientError(_('Only the sender and recipient ' .
98 'may read this message.'), 403);
105 if ($this->user->id == $this->message->from_profile) {
106 $to = $this->message->getTo();
107 // @todo FIXME: Might be nice if the timestamp could be localised.
108 // TRANS: Page title for single direct message display when viewing user is the sender.
109 // TRANS: %1$s is the addressed user's nickname, $2$s is a timestamp.
110 return sprintf(_('Message to %1$s on %2$s'),
112 common_exact_date($this->message->created));
113 } else if ($this->user->id == $this->message->to_profile) {
114 $from = $this->message->getFrom();
115 // @todo FIXME: Might be nice if the timestamp could be localised.
116 // TRANS: Page title for single message display.
117 // TRANS: %1$s is the sending user's nickname, $2$s is a timestamp.
118 return sprintf(_('Message from %1$s on %2$s'),
120 common_exact_date($this->message->created));
124 function getMessages()
126 $message = new Message();
127 $message->id = $this->message->id;
132 function getMessageProfile()
134 if ($this->user->id == $this->message->from_profile) {
135 return $this->message->getTo();
136 } else if ($this->user->id == $this->message->to_profile) {
137 return $this->message->getFrom();
139 // This shouldn't happen
145 * Don't show local navigation
149 function showLocalNavBlock()
154 * Don't show page notice
158 function showPageNoticeBlock()
172 * Don't show any instructions
176 function getInstructions()
181 function isReadOnly($args)