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/
47 class ShowmessageAction extends MailboxAction
50 * Message object to show
62 * Load attributes based on database arguments
64 * Loads all the DB stuff
66 * @param array $args $_REQUEST array
68 * @return success flag
71 function prepare($args)
73 parent::prepare($args);
77 $id = $this->trimmed('message');
78 $this->message = Message::staticGet('id', $id);
80 if (!$this->message) {
81 $this->clientError(_('No such message.'), 404);
85 $this->user = common_current_user();
90 function handle($args)
92 Action::handle($args);
94 if ($this->user && ($this->user->id == $this->message->from_profile ||
95 $this->user->id == $this->message->to_profile)) {
98 $this->clientError(_('Only the sender and recipient ' .
99 'may read this message.'), 403);
106 if ($this->user->id == $this->message->from_profile) {
107 $to = $this->message->getTo();
108 return sprintf(_("Message to %1\$s on %2\$s"),
110 common_exact_date($this->message->created));
111 } else if ($this->user->id == $this->message->to_profile) {
112 $from = $this->message->getFrom();
113 return sprintf(_("Message from %1\$s on %2\$s"),
115 common_exact_date($this->message->created));
119 function getMessages()
121 $message = new Message();
122 $message->id = $this->message->id;
127 function getMessageProfile()
129 if ($this->user->id == $this->message->from_profile) {
130 return $this->message->getTo();
131 } else if ($this->user->id == $this->message->to_profile) {
132 return $this->message->getFrom();
134 // This shouldn't happen
140 * Don't show local navigation
145 function showLocalNavBlock()
150 * Don't show page notice
155 function showPageNoticeBlock()
170 * Don't show any instructions
175 function getInstructions()
180 function isReadOnly($args)