]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
change all evans to evan@status.net
[quix0rs-gnu-social.git] / actions / all.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, 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  * @category Actions
20  * @package  Actions
21  * @author   Evan Prodromou <evan@status.net>
22  * @author   Evan Prodromou <evan@status.net>
23  * @author   Mike Cochrane <mikec@mikenz.geek.nz>
24  * @author   Robin Millette <millette@controlyourself.ca>
25  * @author   Adrian Lang <mail@adrianlang.de>
26  * @author   Meitar Moscovitz <meitarm@gmail.com>
27  * @author   Sarven Capadisli <csarven@controlyourself.ca>
28  * @author   Craig Andrews <candrews@integralblue.com>
29  * @author   Evan Prodromou <evan@status.net>
30  * @author   Evan Prodromou <evan@status.net>
31  * @author   Jeffery To <jeffery.to@gmail.com>
32  * @author   Zach Copley <zach@controlyourself.ca>
33  * @author   csarven <csarven@controlyourself.ca>
34  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
35  * @link     http://status.net
36  */
37
38 if (!defined('STATUSNET') && !defined('LACONICA')) { 
39     exit(1); 
40 }
41
42 require_once INSTALLDIR.'/lib/personalgroupnav.php';
43 require_once INSTALLDIR.'/lib/noticelist.php';
44 require_once INSTALLDIR.'/lib/feedlist.php';
45
46 class AllAction extends ProfileAction
47 {
48     var $notice;
49
50     function isReadOnly($args)
51     {
52         return true;
53     }
54
55     function prepare($args)
56     {
57         parent::prepare($args);
58         $cur = common_current_user();
59
60         if (!empty($cur) && $cur->id == $this->user->id) {
61             $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
62         } else {
63             $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
64         }
65
66         if ($this->page > 1 && $this->notice->N == 0) {
67             $this->serverError(_('No such page'), $code = 404);
68         }
69
70         return true;
71     }
72
73     function handle($args)
74     {
75         parent::handle($args);
76
77         if (!$this->user) {
78             $this->clientError(_('No such user.'));
79             return;
80         }
81
82         $this->showPage();
83     }
84
85     function title()
86     {
87         if ($this->page > 1) {
88             return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
89         } else {
90             return sprintf(_("%s and friends"), $this->user->nickname);
91         }
92     }
93
94     function getFeeds()
95     {
96         return array(
97             new Feed(Feed::RSS1,
98                 common_local_url(
99                     'allrss', array(
100                         'nickname' =>
101                         $this->user->nickname)
102                 ),
103                 sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
104             new Feed(Feed::RSS2,
105                 common_local_url(
106                     'api', array(
107                         'apiaction' => 'statuses',
108                         'method' => 'friends_timeline',
109                         'argument' => $this->user->nickname.'.rss'
110                     )
111                 ),
112                 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
113             new Feed(Feed::ATOM,
114                 common_local_url(
115                     'api', array(
116                         'apiaction' => 'statuses',
117                         'method' => 'friends_timeline',
118                         'argument' => $this->user->nickname.'.atom'
119                     )
120                 ),
121                 sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))
122         );
123     }
124
125     function showLocalNav()
126     {
127         $nav = new PersonalGroupNav($this);
128         $nav->show();
129     }
130
131     function showEmptyListMessage()
132     {
133         $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' ';
134
135         if (common_logged_in()) {
136             $current_user = common_current_user();
137             if ($this->user->id === $current_user->id) {
138                 $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
139             } else {
140                 $message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
141             }
142         } else {
143             $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
144         }
145
146         $this->elementStart('div', 'guide');
147         $this->raw(common_markup_to_html($message));
148         $this->elementEnd('div');
149     }
150
151     function showContent()
152     {
153         $nl = new NoticeList($this->notice, $this);
154
155         $cnt = $nl->show();
156
157         if (0 == $cnt) {
158             $this->showEmptyListMessage();
159         }
160
161         $this->pagination(
162             $this->page > 1, $cnt > NOTICES_PER_PAGE,
163             $this->page, 'all', array('nickname' => $this->user->nickname)
164         );
165     }
166
167     function showPageTitle()
168     {
169         $user =& common_current_user();
170         if ($user && ($user->id == $this->user->id)) {
171             $this->element('h1', null, _("You and friends"));
172         } else {
173             $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname));
174         }
175     }
176
177 }