We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

all.php 3.05 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Evan Prodromou's avatar
Evan Prodromou committed
2
/*
Evan Prodromou's avatar
Evan Prodromou committed
3 4
 * Laconica - a distributed open-source microblogging tool
 * Copyright (C) 2008, Controlez-Vous, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
5
 *
Evan Prodromou's avatar
Evan Prodromou committed
6 7 8 9
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
Evan Prodromou's avatar
Evan Prodromou committed
10
 *
Evan Prodromou's avatar
Evan Prodromou committed
11 12 13 14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
Evan Prodromou's avatar
Evan Prodromou committed
15
 *
Evan Prodromou's avatar
Evan Prodromou committed
16 17 18 19
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

Evan Prodromou's avatar
Evan Prodromou committed
20
if (!defined('LACONICA')) { exit(1); }
Evan Prodromou's avatar
Evan Prodromou committed
21

Evan Prodromou's avatar
Evan Prodromou committed
22 23
require_once(INSTALLDIR.'/actions/showstream.php');

24 25
class AllAction extends StreamAction
{
Evan Prodromou's avatar
Evan Prodromou committed
26

27 28
    function handle($args)
    {
Evan Prodromou's avatar
Evan Prodromou committed
29

30
        parent::handle($args);
Evan Prodromou's avatar
Evan Prodromou committed
31

32 33
        $nickname = common_canonical_nickname($this->arg('nickname'));
        $user = User::staticGet('nickname', $nickname);
Evan Prodromou's avatar
Evan Prodromou committed
34

35
        if (!$user) {
36
            $this->clientError(_('No such user.'));
37 38
            return;
        }
Evan Prodromou's avatar
Evan Prodromou committed
39

40
        $profile = $user->getProfile();
Evan Prodromou's avatar
Evan Prodromou committed
41

42
        if (!$profile) {
43
            $this->serverError(_('User has no profile.'));
44 45
            return;
        }
Evan Prodromou's avatar
Evan Prodromou committed
46

47
        # Looks like we're good; show the header
Evan Prodromou's avatar
Evan Prodromou committed
48

49 50 51
        common_show_header(sprintf(_("%s and friends"), $profile->nickname),
                           array($this, 'show_header'), $user,
                           array($this, 'show_top'));
52

53
        $this->show_notices($user);
54

55 56
        common_show_footer();
    }
57

58 59
    function show_header($user)
    {
60
        $this->element('link', array('rel' => 'alternate',
61 62 63 64 65
                                     'href' => common_local_url('allrss', array('nickname' =>
                                                                               $user->nickname)),
                                     'type' => 'application/rss+xml',
                                     'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
    }
Evan Prodromou's avatar
Evan Prodromou committed
66

67 68
    function show_top($user)
    {
69
        $cur = common_current_user();
70

71 72 73
        if ($cur && $cur->id == $user->id) {
            common_notice_form('all');
        }
74

75
        $this->views_menu();
csarven's avatar
csarven committed
76

77 78 79 80 81
        $this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
                                              'type' => 'rss',
                                              'version' => 'RSS 1.0',
                                              'item' => 'allrss')));
    }
82

83 84
    function show_notices($user)
    {
Evan Prodromou's avatar
Evan Prodromou committed
85

86 87 88 89
        $page = $this->trimmed('page');
        if (!$page) {
            $page = 1;
        }
90

91
        $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
92 93

        $cnt = $this->show_notice_list($notice);
94

95 96 97
        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
                          $page, 'all', array('nickname' => $user->nickname));
    }
Evan Prodromou's avatar
Evan Prodromou committed
98
}