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);
82 // TRANS: Client error displayed when a tagger is expected but not provided.
83 $this->clientError(_('No tagger.'), 404);
86 $user = User::getKV('nickname', $tagger);
89 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
90 $this->clientError(_('No such user.'), 404);
93 $this->tagger = $user->getProfile();
94 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
96 if (!$this->peopletag) {
97 // TRANS: Client error displayed trying to reference a non-existing list.
98 $this->clientError(_('No such list.'), 404);
106 if ($this->page == 1) {
107 // TRANS: Page title for list of list subscribers.
108 // TRANS: %1$s is a list, %2$s is a user nickname.
109 return sprintf(_('Subscribers to list %1$s by %2$s'),
110 $this->peopletag->tag, $this->tagger->nickname);
112 // TRANS: Page title for list of list subscribers.
113 // TRANS: %1$s is a list, %2$s is a user nickname, %3$d is a page number.
114 return sprintf(_('Subscribers to list %1$s by %2$s, page %3$d'),
115 $this->peopletag->tag, $this->tagger->nickname,
120 function handle($args)
122 parent::handle($args);
126 function showPageNotice()
130 function showLocalNav()
132 $nav = new PeopletagGroupNav($this);
136 function showContent()
138 $offset = ($this->page-1) * PROFILES_PER_PAGE;
139 $limit = PROFILES_PER_PAGE + 1;
143 $subs = $this->peopletag->getSubscribers($offset, $limit);
146 $subscriber_list = new PeopletagSubscriberList($subs, $this->peopletag, $this);
147 $cnt = $subscriber_list->show();
152 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
153 $this->page, 'peopletagsubscribers',
154 array('tagger' => $this->tagger->nickname,
155 'tag' => $this->peopletag->tag));
159 class PeopletagSubscriberList extends ProfileList
161 var $peopletag = null;
163 function __construct($profile, $peopletag, $action)
165 parent::__construct($profile, $action);
167 $this->peopletag = $peopletag;
170 function newListItem($profile)
172 return new PeopletagSubscriberListItem($profile, $this->peopletag, $this->action);
176 class PeopletagSubscriberListItem extends ProfileListItem
178 var $peopletag = null;
180 function __construct($profile, $peopletag, $action)
182 parent::__construct($profile, $action);
184 $this->peopletag = $peopletag;
187 function showFullName()
189 parent::showFullName();
190 if ($this->profile->id == $this->peopletag->tagger) {
191 $this->out->text(' ');
192 // TRANS: Addition in tag subscribers list for creator of a tag.
193 $this->out->element('span', 'role', _('Creator'));
197 function showActions()
199 $this->startActions();
200 if (Event::handle('StartProfileListItemActionElements', array($this))) {
201 $this->showSubscribeButton();
202 Event::handle('EndProfileListItemActionElements', array($this));
207 function linkAttributes()
209 $aAttrs = parent::linkAttributes();
211 if (common_config('nofollow', 'members')) {
212 $aAttrs['rel'] .= ' nofollow';
218 function homepageAttributes()
220 $aAttrs = parent::linkAttributes();
222 if (common_config('nofollow', 'members')) {
223 $aAttrs['rel'] = 'nofollow';
230 * Fetch necessary return-to arguments for the profile forms
231 * to return to this list when they're done.
235 protected function returnToArgs()
237 $args = array('action' => 'peopletagsubscribers',
238 'tag' => $this->peopletag->tag,
239 'tagger' => $this->profile->nickname);
240 $page = $this->out->arg('page');
242 $args['param-page'] = $page;