3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
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.
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.
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/>.
20 if (!defined('LACONICA')) { exit(1); }
22 # XXX: make distinct from similar definitions in showstream.php
24 define('SUBSCRIPTIONS_PER_ROW', 8);
25 define('SUBSCRIPTIONS_PER_PAGE', 80);
27 class SubscribedAction extends Action {
29 # Who is subscribed to a given user?
31 function handle($args) {
32 parent::handle($args);
33 $nickname = $this->arg('nickname');
34 $profile = Profile::staticGet('nickname', $nickname);
36 $this->no_such_user();
38 $user = User::staticGet($profile->id);
40 $this->no_such_user();
43 $page = $this->arg('page') || 1;
44 common_show_header($profile->nickname . ": " . _t('Subscribers'));
45 $this->show_subscribed($profile, $page);
49 function show_subscribed($profile, $page) {
52 $subs = DB_DataObject::factory('subscription');
53 $subs->subscribed = $profile->id;
55 $subs->orderBy('created DESC');
57 # We ask for an extra one to know if we need to do another page
59 $subs->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE), SUBSCRIPTIONS_PER_PAGE + 1);
61 $subs_count = $subs->find();
63 common_element_start('div', 'subscriptions');
67 while ($subs->fetch()) {
69 if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
70 common_element_start('div', 'row');
73 $other = Profile::staticGet($subs->subscriber);
75 common_element_start('a', array('title' => ($other->fullname) ?
78 'href' => $other->profileurl,
79 'class' => 'subscription'));
80 $avatar = $other->getAvatar(AVATAR_STREAM_SIZE);
81 common_element('img', array('src' => (($avatar) ? $avatar->url : common_default_avatar(AVATAR_STREAM_SIZE)),
82 'width' => AVATAR_STREAM_SIZE,
83 'height' => AVATAR_STREAM_SIZE,
84 'class' => 'avatar stream',
85 'alt' => ($other->fullname) ?
88 common_element_end('a');
90 # XXX: subscribe form here
92 if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
93 common_element_end('div');
96 if ($idx == SUBSCRIPTIONS_PER_PAGE) {
102 common_element('a', array('href' =>
103 common_local_url('subscriptions',
104 array('nickname' => $profile->nickname,
105 'page' => $page - 1)),
110 if ($subs_count > SUBSCRIPTIONS_PER_PAGE) {
111 common_element('a', array('href' =>
112 common_local_url('subscriptions',
113 array('nickname' => $profile->nickname,
114 'page' => $page + 1)),
118 common_element_end('div');