3 * StatusNet, the distributed open-source microblogging tool
5 * List a user's subscribers
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.
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.
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/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @author Sarven Capadisli <csarven@status.net>
26 * @copyright 2008-2009 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 * List a user's subscribers
40 * @author Evan Prodromou <evan@status.net>
41 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42 * @link http://status.net/
44 class SubscribersAction extends GalleryAction
48 if ($this->page == 1) {
49 // TRANS: Header for list of subscribers for a user (first page).
50 // TRANS: %s is the user's nickname.
51 return sprintf(_('%s subscribers'), $this->user->nickname);
53 // TRANS: Header for list of subscribers for a user (not first page).
54 // TRANS: %1$s is the user's nickname, $2$d is the page number.
55 return sprintf(_('%1$s subscribers, page %2$d'),
56 $this->user->nickname,
61 function showPageNotice()
63 $user = common_current_user();
64 if ($user && ($user->id == $this->profile->id)) {
65 $this->element('p', null,
66 // TRANS: Page notice for page with an overview of all subscribers
67 // TRANS: of the logged in user's own profile.
68 _('These are the people who listen to '.
71 $this->element('p', null,
72 // TRANS: Page notice for page with an overview of all subscribers of a user other
73 // TRANS: than the logged in user. %s is the user nickname.
74 sprintf(_('These are the people who '.
75 'listen to %s\'s notices.'),
76 $this->profile->nickname));
80 function showContent()
82 parent::showContent();
84 $offset = ($this->page-1) * PROFILES_PER_PAGE;
85 $limit = PROFILES_PER_PAGE + 1;
90 $subscribers = $this->user->getTaggedSubscribers($this->tag, $offset, $limit);
92 $subscribers = $this->user->getSubscribers($offset, $limit);
96 $subscribers_list = new SubscribersList($subscribers, $this->user, $this);
97 $cnt = $subscribers_list->show();
99 $this->showEmptyListMessage();
103 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
104 $this->page, 'subscribers',
105 array('nickname' => $this->user->nickname));
108 function showEmptyListMessage()
110 if (common_logged_in()) {
111 $current_user = common_current_user();
112 if ($this->user->id === $current_user->id) {
113 // TRANS: Subscriber list text when the logged in user has no subscribers.
114 $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor.');
116 // TRANS: Subscriber list text when looking at the subscribers for a of a user other
117 // TRANS: than the logged in user that has no subscribers. %s is the user nickname.
118 $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->user->nickname);
122 // TRANS: Subscriber list text when looking at the subscribers for a of a user that has none
123 // TRANS: as an anonymous user. %s is the user nickname.
124 // TRANS: This message contains a Markdown URL. The link description is between
125 // TRANS: square brackets, and the link between parentheses. Do not separate "]("
126 // TRANS: and do not change the URL part.
127 $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->user->nickname);
130 $this->elementStart('div', 'guide');
131 $this->raw(common_markup_to_html($message));
132 $this->elementEnd('div');
135 function showSections()
137 parent::showSections();
141 class SubscribersList extends SubscriptionList
143 function newListItem($profile)
145 return new SubscribersListItem($profile, $this->owner, $this->action);
149 class SubscribersListItem extends SubscriptionListItem
151 function showActions()
153 $this->startActions();
154 if (Event::handle('StartProfileListItemActionElements', array($this))) {
155 $this->showSubscribeButton();
157 $this->showBlockForm();
158 Event::handle('EndProfileListItemActionElements', array($this));
163 function showBlockForm()
165 $user = common_current_user();
167 if (!empty($user) && $this->owner->id == $user->id) {
168 $returnto = array('action' => 'subscribers',
169 'nickname' => $this->owner->nickname);
170 $page = $this->out->arg('page');
172 $returnto['param-page'] = $page;
174 $bf = new BlockForm($this->out, $this->profile, $returnto);
179 function linkAttributes()
181 $aAttrs = parent::linkAttributes();
183 if (common_config('nofollow', 'subscribers')) {
184 $aAttrs['rel'] .= ' nofollow';
190 function homepageAttributes()
192 $aAttrs = parent::linkAttributes();
194 if (common_config('nofollow', 'subscribers')) {
195 $aAttrs['rel'] = 'nofollow';