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/stream.php');
24 class ShownoticeAction extends StreamAction {
30 function prepare($args)
33 parent::prepare($args);
35 $id = $this->arg('notice');
36 $this->notice = Notice::staticGet($id);
39 $this->client_error(_('No such notice.'), 404);
43 $this->profile = $this->notice->getProfile();
45 if (!$this->profile) {
46 $this->server_error(_('Notice has no profile'), 500);
50 $this->avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
55 function last_modified()
57 return max(strtotime($this->notice->created),
58 strtotime($this->profile->modified),
59 ($this->avatar) ? strtotime($this->avatar->modified) : 0);
64 return 'W/"' . implode(':', array($this->arg('action'),
67 strtotime($this->notice->created),
68 strtotime($this->profile->modified),
69 ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
72 function handle($args)
75 parent::handle($args);
77 common_show_header(sprintf(_('%1$s\'s status on %2$s'),
78 $this->profile->nickname,
79 common_exact_date($this->notice->created)),
80 array($this, 'show_header'), null,
81 array($this, 'show_top'));
83 common_element_start('ul', array('id' => 'notices'));
84 $nli = new NoticeListItem($this->notice);
86 common_element_end('ul');
91 function show_header()
94 $user = User::staticGet($this->profile->id);
100 if ($user->emailmicroid && $user->email && $this->notice->uri) {
101 common_element('meta', array('name' => 'microid',
102 'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri))));
105 if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
106 common_element('meta', array('name' => 'microid',
107 'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri))));
113 $cur = common_current_user();
114 if ($cur && $cur->id == $this->profile->id) {
115 common_notice_form();
119 function no_such_notice()
121 common_user_error(_('No such notice.'));