]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
change function headers to K&R style
[quix0rs-gnu-social.git] / actions / all.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.'/actions/showstream.php');
23
24 class AllAction extends StreamAction {
25
26     function handle($args)
27     {
28
29         parent::handle($args);
30
31         $nickname = common_canonical_nickname($this->arg('nickname'));
32         $user = User::staticGet('nickname', $nickname);
33
34         if (!$user) {
35             $this->client_error(_('No such user.'));
36             return;
37         }
38
39         $profile = $user->getProfile();
40
41         if (!$profile) {
42             common_server_error(_('User has no profile.'));
43             return;
44         }
45
46         # Looks like we're good; show the header
47
48         common_show_header(sprintf(_("%s and friends"), $profile->nickname),
49                            array($this, 'show_header'), $user,
50                            array($this, 'show_top'));
51
52         $this->show_notices($user);
53
54         common_show_footer();
55     }
56
57     function show_header($user)
58     {
59         common_element('link', array('rel' => 'alternate',
60                                      'href' => common_local_url('allrss', array('nickname' =>
61                                                                                $user->nickname)),
62                                      'type' => 'application/rss+xml',
63                                      'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
64     }
65
66     function show_top($user)
67     {
68         $cur = common_current_user();
69
70         if ($cur && $cur->id == $user->id) {
71             common_notice_form('all');
72         }
73
74         $this->views_menu();
75
76         $this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
77                                               'type' => 'rss',
78                                               'version' => 'RSS 1.0',
79                                               'item' => 'allrss')));
80     }
81
82     function show_notices($user)
83     {
84
85         $page = $this->trimmed('page');
86         if (!$page) {
87             $page = 1;
88         }
89
90         $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
91
92         $cnt = $this->show_notice_list($notice);
93
94         common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
95                           $page, 'all', array('nickname' => $user->nickname));
96     }
97 }