3 * StatusNet, the distributed open-source microblogging tool
5 * List of peopletag 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 * @copyright 2008-2011 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 require_once(INSTALLDIR.'/lib/profilelist.php');
37 * List of peopletag subscribers
41 * @author Evan Prodromou <evan@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://status.net/
45 class PeopletagsubscribersAction extends Action
48 var $peopletag = null;
51 function isReadOnly($args)
56 function prepare($args)
58 parent::prepare($args);
59 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
61 if (common_config('singleuser', 'enabled')) {
62 $tagger_arg = User::singleUserNickname();
64 $tagger_arg = $this->arg('tagger');
67 $tag_arg = $this->arg('tag');
68 $tagger = common_canonical_nickname($tagger_arg);
69 $tag = common_canonical_tag($tag_arg);
71 // Permanent redirect on non-canonical nickname
73 if ($tagger_arg != $tagger || $tag_arg != $tag) {
74 $args = array('tagger' => $nickname, 'tag' => $tag);
75 if ($this->page != 1) {
76 $args['page'] = $this->page;
78 common_redirect(common_local_url('peopletagged', $args), 301);
83 // TRANS: Client error displayed when a tagger is expected but not provided.
84 $this->clientError(_('No tagger.'), 404);
88 $user = User::getKV('nickname', $tagger);
91 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
92 $this->clientError(_('No such user.'), 404);
96 $this->tagger = $user->getProfile();
97 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
99 if (!$this->peopletag) {
100 // TRANS: Client error displayed trying to reference a non-existing list.
101 $this->clientError(_('No such list.'), 404);
110 if ($this->page == 1) {
111 // TRANS: Page title for list of list subscribers.
112 // TRANS: %1$s is a list, %2$s is a user nickname.
113 return sprintf(_('Subscribers to list %1$s by %2$s'),
114 $this->peopletag->tag, $this->tagger->nickname);
116 // TRANS: Page title for list of list subscribers.
117 // TRANS: %1$s is a list, %2$s is a user nickname, %3$d is a page number.
118 return sprintf(_('Subscribers to list %1$s by %2$s, page %3$d'),
119 $this->peopletag->tag, $this->tagger->nickname,
124 function handle($args)
126 parent::handle($args);
130 function showPageNotice()
134 function showLocalNav()
136 $nav = new PeopletagGroupNav($this);
140 function showContent()
142 $offset = ($this->page-1) * PROFILES_PER_PAGE;
143 $limit = PROFILES_PER_PAGE + 1;
147 $subs = $this->peopletag->getSubscribers($offset, $limit);
150 $subscriber_list = new PeopletagSubscriberList($subs, $this->peopletag, $this);
151 $cnt = $subscriber_list->show();
156 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
157 $this->page, 'peopletagsubscribers',
158 array('tagger' => $this->tagger->nickname,
159 'tag' => $this->peopletag->tag));
163 class PeopletagSubscriberList extends ProfileList
165 var $peopletag = null;
167 function __construct($profile, $peopletag, $action)
169 parent::__construct($profile, $action);
171 $this->peopletag = $peopletag;
174 function newListItem($profile)
176 return new PeopletagSubscriberListItem($profile, $this->peopletag, $this->action);
180 class PeopletagSubscriberListItem extends ProfileListItem
182 var $peopletag = null;
184 function __construct($profile, $peopletag, $action)
186 parent::__construct($profile, $action);
188 $this->peopletag = $peopletag;
191 function showFullName()
193 parent::showFullName();
194 if ($this->profile->id == $this->peopletag->tagger) {
195 $this->out->text(' ');
196 // TRANS: Addition in tag subscribers list for creator of a tag.
197 $this->out->element('span', 'role', _('Creator'));
201 function showActions()
203 $this->startActions();
204 if (Event::handle('StartProfileListItemActionElements', array($this))) {
205 $this->showSubscribeButton();
206 Event::handle('EndProfileListItemActionElements', array($this));
211 function linkAttributes()
213 $aAttrs = parent::linkAttributes();
215 if (common_config('nofollow', 'members')) {
216 $aAttrs['rel'] .= ' nofollow';
222 function homepageAttributes()
224 $aAttrs = parent::linkAttributes();
226 if (common_config('nofollow', 'members')) {
227 $aAttrs['rel'] = 'nofollow';
234 * Fetch necessary return-to arguments for the profile forms
235 * to return to this list when they're done.
239 protected function returnToArgs()
241 $args = array('action' => 'peopletagsubscribers',
242 'tag' => $this->peopletag->tag,
243 'tagger' => $this->profile->nickname);
244 $page = $this->out->arg('page');
246 $args['param-page'] = $page;