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 {
26 function init($args) {
30 $id = $this->arg('notice');
31 $this->notice = Notice::staticGet($id);
34 $this->client_error(_('No such notice.'), 404);
38 $this->profile = $this->notice->getProfile();
40 if (!$this->profile) {
41 $this->server_error(_('Notice has no profile'), 500);
45 $this->avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
50 function last_modified() {
51 return max(strtotime($this->notice->created),
52 strtotime($this->profile->modified),
53 ($this->avatar) ? strtotime($this->avatar->modified) : 0);
57 return 'W/"' . implode(':', array($this->arg('action'),
60 strtotime($this->notice->created),
61 strtotime($this->profile->modified),
62 ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
65 function handle($args) {
67 parent::handle($args);
69 common_show_header(sprintf(_('%1$s\'s status on %2$s'),
70 $this->profile->nickname,
71 common_exact_date($this->notice->created)),
72 array($this, 'show_header'), NULL,
73 array($this, 'show_top'));
75 common_element_start('ul', array('id' => 'notices'));
76 $this->show_notice($this->notice);
77 common_element_end('ul');
82 function show_header() {
84 $user = User::staticGet($this->profile->id);
90 if ($user->emailmicroid && $user->email && $this->notice->uri) {
91 common_element('meta', array('name' => 'microid',
92 'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri))));
95 if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
96 common_element('meta', array('name' => 'microid',
97 'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri))));
101 function show_top() {
102 $cur = common_current_user();
103 if ($cur && $cur->id == $this->profile->id) {
104 common_notice_form();
108 function no_such_notice() {
109 common_user_error(_('No such notice.'));