3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 require_once(INSTALLDIR.'/lib/mailbox.php');
24 class ShowmessageAction extends MailboxAction {
26 function handle($args) {
28 Action::handle($args);
30 $id = $this->trimmed('id');
32 $message = Message::staticGet('id', $id);
35 $this->client_error(_('No such message.'), 404);
39 $cur = common_current_user();
42 $cur->id != $message->from_profile &&
43 $cur->id != $message->to_profile)
45 $this->client_error(_('Only the sender and recipient may read this message.'), 404);
49 $this->show_page($cur, 1);
52 function get_message() {
53 $id = $this->trimmed('id');
54 $message = Message::staticGet('id', $id);
58 function get_title($user, $page) {
59 $message = $this->get_message();
64 if ($user->id == $message->from_profile) {
65 $to = $message->getTo();
66 $title = sprintf(_("Message to %1\$s on %2\$s"),
68 common_exact_date($message->created));
69 } else if ($user->id == $message->to_profile) {
70 $from = $message->getFrom();
71 $title = sprintf(_("Message from %1\$s on %2\$s"),
73 common_exact_date($message->created));
78 function get_messages($user, $page) {
79 return $this->get_message();
82 function get_message_profile($message) {
83 $user = common_current_user();
84 if ($user->id == $message->from_profile) {
85 return $message->getTo();
86 } else if ($user->id == $message->to_profile) {
87 return $message->getFrom();
89 # This shouldn't happen
94 function get_instructions() {