]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/replies.php
mark a bunch of actions read-only
[quix0rs-gnu-social.git] / actions / replies.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * List of replies
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Personal
23  * @package   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @copyright 2008-2009 Control Yourself, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://laconi.ca/
28  */
29
30 if (!defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/personalgroupnav.php';
35 require_once INSTALLDIR.'/lib/noticelist.php';
36 require_once INSTALLDIR.'/lib/feedlist.php';
37
38 /**
39  * List of replies
40  *
41  * @category Personal
42  * @package  Laconica
43  * @author   Evan Prodromou <evan@controlyourself.ca>
44  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45  * @link     http://laconi.ca/
46  */
47
48 class RepliesAction extends Action
49 {
50     var $user = null;
51     var $page = null;
52
53     /**
54      * Prepare the object
55      *
56      * Check the input values and initialize the object.
57      * Shows an error page on bad input.
58      *
59      * @param array $args $_REQUEST data
60      *
61      * @return boolean success flag
62      */
63
64     function prepare($args)
65     {
66         parent::prepare($args);
67
68         $nickname = common_canonical_nickname($this->arg('nickname'));
69
70         $this->user = User::staticGet('nickname', $nickname);
71
72         if (!$this->user) {
73             $this->clientError(_('No such user.'));
74             return false;
75         }
76
77         $profile = $this->user->getProfile();
78
79         if (!$profile) {
80             $this->serverError(_('User has no profile.'));
81             return false;
82         }
83
84         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
85
86         return true;
87     }
88
89     /**
90      * Handle a request
91      *
92      * Just show the page. All args already handled.
93      *
94      * @param array $args $_REQUEST data
95      *
96      * @return void
97      */
98
99     function handle($args)
100     {
101         parent::handle($args);
102         $this->showPage();
103     }
104
105     /**
106      * Title of the page
107      *
108      * Includes name of user and page number.
109      *
110      * @return string title of page
111      */
112
113     function title()
114     {
115         if ($this->page == 1) {
116             return sprintf(_("Replies to %s"), $this->user->nickname);
117         } else {
118             return sprintf(_("Replies to %s, page %d"),
119                            $profile->nickname,
120                            $this->page);
121         }
122     }
123
124     /**
125      * Feeds for the <head> section
126      *
127      * @return void
128      */
129
130     function showFeeds()
131     {
132         $rssurl   = common_local_url('repliesrss',
133                                      array('nickname' => $this->user->nickname));
134         $rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
135
136         $this->element('link', array('rel' => 'alternate',
137                                      'href' => $rssurl,
138                                      'type' => 'application/rss+xml',
139                                      'title' => $rsstitle));
140     }
141
142     /**
143      * show the personal group nav
144      *
145      * @return void
146      */
147
148     function showLocalNav()
149     {
150         $nav = new PersonalGroupNav($this);
151         $nav->show();
152     }
153
154     /**
155      * Show the replies feed links
156      *
157      * @return void
158      */
159
160     function showExportData()
161     {
162         $fl = new FeedList($this);
163
164         $rssurl = common_local_url('repliesrss',
165                                    array('nickname' => $this->user->nickname));
166
167         $fl->show(array(0=>array('href'=> $rssurl,
168                                  'type' => 'rss',
169                                  'version' => 'RSS 1.0',
170                                  'item' => 'repliesrss')));
171     }
172
173     /**
174      * Show the content
175      *
176      * A list of notices that are replies to the user, plus pagination.
177      *
178      * @return void
179      */
180
181     function showContent()
182     {
183         $notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
184                                           NOTICES_PER_PAGE + 1);
185
186         $nl = new NoticeList($notice, $this);
187
188         $cnt = $nl->show();
189
190         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
191                           $this->page, 'replies',
192                           array('nickname' => $this->user->nickname));
193     }
194
195     function isReadOnly()
196     {
197         return true;
198     }
199 }