3 * StatusNet, the distributed open-source microblogging tool
5 * List of group members
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-2009 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')) {
35 * List of profiles blocked from this group
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
43 class BlockedfromgroupAction extends GroupAction
47 function isReadOnly($args)
52 function prepare($args)
54 parent::prepare($args);
55 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
57 $nickname_arg = $this->arg('nickname');
58 $nickname = common_canonical_nickname($nickname_arg);
60 // Permanent redirect on non-canonical nickname
62 if ($nickname_arg != $nickname) {
63 $args = array('nickname' => $nickname);
64 if ($this->page != 1) {
65 $args['page'] = $this->page;
67 common_redirect(common_local_url('blockedfromgroup', $args), 301);
72 // TRANS: Client error displayed when requesting a list of blocked users for a group without providing a group nickname.
73 $this->clientError(_('No nickname.'), 404);
77 $local = Local_group::getKV('nickname', $nickname);
80 // TRANS: Client error displayed when requesting a list of blocked users for a non-local group.
81 $this->clientError(_('No such group.'), 404);
85 $this->group = User_group::getKV('id', $local->group_id);
88 // TRANS: Client error displayed when requesting a list of blocked users for a non-existing group.
89 $this->clientError(_('No such group.'), 404);
98 if ($this->page == 1) {
99 // TRANS: Title for first page with list of users blocked from a group.
100 // TRANS: %s is a group nickname.
101 return sprintf(_('%s blocked profiles'),
102 $this->group->nickname);
104 // TRANS: Title for any but the first page with list of users blocked from a group.
105 // TRANS: %1$s is a group nickname, %2$d is a page number.
106 return sprintf(_('%1$s blocked profiles, page %2$d'),
107 $this->group->nickname,
112 function handle($args)
114 parent::handle($args);
118 function showPageNotice()
120 $this->element('p', 'instructions',
121 // TRANS: Instructions for list of users blocked from a group.
122 _('A list of the users blocked from joining this group.'));
125 function showContent()
127 $offset = ($this->page-1) * PROFILES_PER_PAGE;
128 $limit = PROFILES_PER_PAGE + 1;
132 $blocked = $this->group->getBlocked($offset, $limit);
135 $blocked_list = new GroupBlockList($blocked, $this->group, $this);
136 $cnt = $blocked_list->show();
141 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
142 $this->page, 'blockedfromgroup',
143 array('nickname' => $this->group->nickname));
147 class GroupBlockList extends ProfileList
151 function __construct($profile, $group, $action)
153 parent::__construct($profile, $action);
155 $this->group = $group;
158 function newListItem($profile)
160 return new GroupBlockListItem($profile, $this->group, $this->action);
164 class GroupBlockListItem extends ProfileListItem
168 function __construct($profile, $group, $action)
170 parent::__construct($profile, $action);
172 $this->group = $group;
175 function showActions()
177 $this->startActions();
178 $this->showGroupUnblockForm();
182 function showGroupUnblockForm()
184 $user = common_current_user();
186 if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
187 $this->out->elementStart('li', 'entity_block');
188 $bf = new GroupUnblockForm($this->out, $this->profile, $this->group,
189 array('action' => 'blockedfromgroup',
190 'nickname' => $this->group->nickname));
192 $this->out->elementEnd('li');
198 * Form for unblocking a user from a group
202 * @author Evan Prodromou <evan@status.net>
203 * @author Sarven Capadisli <csarven@status.net>
204 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
205 * @link http://status.net/
209 class GroupUnblockForm extends Form
212 * Profile of user to block
218 * Group to block the user from
232 * @param HTMLOutputter $out output channel
233 * @param Profile $profile profile of user to block
234 * @param User_group $group group to block user from
235 * @param array $args return-to args
237 function __construct($out=null, $profile=null, $group=null, $args=null)
239 parent::__construct($out);
241 $this->profile = $profile;
242 $this->group = $group;
249 * @return int ID of the form
253 // This should be unique for the page.
254 return 'unblock-' . $this->profile->id;
260 * @return string class of the form
264 return 'form_group_unblock';
270 * @return string URL of the action
274 return common_local_url('groupunblock');
282 function formLegend()
284 // TRANS: Form legend for unblocking a user from a group.
285 $this->out->element('legend', null, _('Unblock user from group'));
289 * Data elements of the form
295 $this->out->hidden('unblockto-' . $this->profile->id,
298 $this->out->hidden('unblockgroup-' . $this->group->id,
302 foreach ($this->args as $k => $v) {
303 $this->out->hidden('returnto-' . $k, $v);
313 function formActions()
315 $this->out->submit('submit',
316 // TRANS: Button text for unblocking a user from a group.
317 _m('BUTTON','Unblock'),
320 // TRANS: Tooltip for button for unblocking a user from a group.
321 _('Unblock this user'));