]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - _darcs/pristine/actions/shownotice.php
add standard directories
[quix0rs-gnu-social.git] / _darcs / pristine / actions / shownotice.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 require_once(INSTALLDIR.'/lib/stream.php');
23
24 class ShownoticeAction extends StreamAction {
25
26         var $notice = NULL;
27         var $profile = NULL;
28         var $avatar = NULL;
29
30         function prepare($args) {
31
32                 parent::prepare($args);
33
34                 $id = $this->arg('notice');
35                 $this->notice = Notice::staticGet($id);
36
37                 if (!$this->notice) {
38                         $this->client_error(_('No such notice.'), 404);
39                         return false;
40                 }
41
42                 $this->profile = $this->notice->getProfile();
43
44                 if (!$this->profile) {
45                         $this->server_error(_('Notice has no profile'), 500);
46                         return false;
47                 }
48
49                 $this->avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
50
51                 return true;
52         }
53
54         function last_modified() {
55                 return max(strtotime($this->notice->created),
56                                    strtotime($this->profile->modified),
57                                    ($this->avatar) ? strtotime($this->avatar->modified) : 0);
58         }
59
60         function etag() {
61                 return 'W/"' . implode(':', array($this->arg('action'),
62                                                                                   common_language(),
63                                                                                   $this->notice->id,
64                                                                                   strtotime($this->notice->created),
65                                                                                   strtotime($this->profile->modified),
66                                                                                   ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
67         }
68
69         function handle($args) {
70
71                 parent::handle($args);
72
73                 common_show_header(sprintf(_('%1$s\'s status on %2$s'),
74                                                                    $this->profile->nickname,
75                                                                    common_exact_date($this->notice->created)),
76                                                    array($this, 'show_header'), NULL,
77                                                    array($this, 'show_top'));
78
79                 common_element_start('ul', array('id' => 'notices'));
80         $nli = new NoticeListItem($this->notice);
81         $nli->show();
82                 common_element_end('ul');
83
84                 common_show_footer();
85         }
86
87         function show_header() {
88
89                 $user = User::staticGet($this->profile->id);
90
91                 if (!$user) {
92                         return;
93                 }
94
95                 if ($user->emailmicroid && $user->email && $this->notice->uri) {
96                         common_element('meta', array('name' => 'microid',
97                                                                                  'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri))));
98                 }
99
100                 if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
101                         common_element('meta', array('name' => 'microid',
102                                                                                  'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri))));
103                 }
104         }
105
106         function show_top() {
107                 $cur = common_current_user();
108                 if ($cur && $cur->id == $this->profile->id) {
109                         common_notice_form();
110                 }
111         }
112
113         function no_such_notice() {
114                 common_user_error(_('No such notice.'));
115         }
116 }