3 * StatusNet, the distributed open-source microblogging tool
5 * List of people tagged by the user with a tag
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 Shashi Gowda <connect2shashi@gmail.com>
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 people tagged by the user with a tag
41 * @author Shashi Gowda <connect2shashi@gmail.com>
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 PeopletaggedAction 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 $tagger_arg = $this->arg('tagger');
62 $tag_arg = $this->arg('tag');
63 $tagger = common_canonical_nickname($tagger_arg);
64 $tag = common_canonical_tag($tag_arg);
66 // Permanent redirect on non-canonical nickname
68 if ($tagger_arg != $tagger || $tag_arg != $tag) {
69 $args = array('tagger' => $nickname, 'tag' => $tag);
70 if ($this->page != 1) {
71 $args['page'] = $this->page;
73 common_redirect(common_local_url('peopletagged', $args), 301);
78 // TRANS: Client error displayed when a tagger is expected but not provided.
79 $this->clientError(_('No tagger.'), 404);
83 $user = User::staticGet('nickname', $tagger);
86 // TRANS: Client error displayed when referring to non-existing user.
87 $this->clientError(_('No such user.'), 404);
91 $this->tagger = $user->getProfile();
92 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
94 if (!$this->peopletag) {
95 // TRANS: Client error displayed when referring to a non-existing list.
96 $this->clientError(_('No such list.'), 404);
105 if ($this->page == 1) {
106 // TRANS: Title for list of people listed by the user.
107 // TRANS: %1$s is a list, %2$s is a username.
108 return sprintf(_('People listed in %1$s by %2$s'),
109 $this->peopletag->tag, $this->tagger->nickname);
111 // TRANS: Title for list of people listed by the user.
112 // TRANS: %1$s is a list, %2$s is a username, %2$s is a page number.
113 return sprintf(_('People listed in %1$s by %2$s, page %3$d'),
114 $this->peopletag->tag, $this->user->nickname,
119 function handle($args)
121 parent::handle($args);
125 function showPageNotice()
129 function showLocalNav()
131 $nav = new PeopletagGroupNav($this, $this->peopletag);
135 function showContent()
137 $offset = ($this->page-1) * PROFILES_PER_PAGE;
138 $limit = PROFILES_PER_PAGE + 1;
142 $subs = $this->peopletag->getTagged($offset, $limit);
145 $subscriber_list = new PeopletagMemberList($subs, $this->peopletag, $this);
146 $cnt = $subscriber_list->show();
151 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
152 $this->page, 'peopletagged',
153 array('tagger' => $this->tagger->nickname,
154 'tag' => $this->peopletag->tag));
158 class PeopletagMemberList extends ProfileList
160 var $peopletag = null;
162 function __construct($profile, $peopletag, $action)
164 parent::__construct($profile, $action);
166 $this->peopletag = $peopletag;
169 function newListItem($profile)
171 return new PeopletagMemberListItem($profile, $this->peopletag, $this->action);
175 class PeopletagMemberListItem extends ProfileListItem
177 var $peopletag = null;
179 function __construct($profile, $peopletag, $action)
181 parent::__construct($profile, $action);
183 $this->peopletag = $peopletag;
186 function showFullName()
188 parent::showFullName();
189 if ($this->profile->id == $this->peopletag->tagger) {
190 $this->out->text(' ');
191 // TRANS: Addition in tag membership list for creator of a tag.
192 $this->out->element('span', 'role', _('Creator'));
196 function showActions()
198 $this->startActions();
199 if (Event::handle('StartProfileListItemActionElements', array($this))) {
200 $this->showSubscribeButton();
201 // TODO: Untag button
202 Event::handle('EndProfileListItemActionElements', array($this));
207 function linkAttributes()
209 // tagging people is healthy page-rank flow.
210 return parent::linkAttributes();
214 * Fetch necessary return-to arguments for the profile forms
215 * to return to this list when they're done.
219 protected function returnToArgs()
221 $args = array('action' => 'peopletagged',
222 'tag' => $this->peopletag->tag,
223 'tagger' => $this->profile->nickname);
224 $page = $this->out->arg('page');
226 $args['param-page'] = $page;