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/
44 class BlockedfromgroupAction extends GroupDesignAction
48 function isReadOnly($args)
53 function prepare($args)
55 parent::prepare($args);
56 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
58 $nickname_arg = $this->arg('nickname');
59 $nickname = common_canonical_nickname($nickname_arg);
61 // Permanent redirect on non-canonical nickname
63 if ($nickname_arg != $nickname) {
64 $args = array('nickname' => $nickname);
65 if ($this->page != 1) {
66 $args['page'] = $this->page;
68 common_redirect(common_local_url('blockedfromgroup', $args), 301);
73 $this->clientError(_('No nickname.'), 404);
77 $local = Local_group::staticGet('nickname', $nickname);
80 $this->clientError(_('No such group.'), 404);
84 $this->group = User_group::staticGet('id', $local->group_id);
87 $this->clientError(_('No such group.'), 404);
96 if ($this->page == 1) {
97 return sprintf(_('%s blocked profiles'),
98 $this->group->nickname);
100 return sprintf(_('%1$s blocked profiles, page %2$d'),
101 $this->group->nickname,
106 function handle($args)
108 parent::handle($args);
112 function showPageNotice()
114 $this->element('p', 'instructions',
115 _('A list of the users blocked from joining this group.'));
118 function showLocalNav()
120 $nav = new GroupNav($this, $this->group);
124 function showContent()
126 $offset = ($this->page-1) * PROFILES_PER_PAGE;
127 $limit = PROFILES_PER_PAGE + 1;
131 $blocked = $this->group->getBlocked($offset, $limit);
134 $blocked_list = new GroupBlockList($blocked, $this->group, $this);
135 $cnt = $blocked_list->show();
140 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
141 $this->page, 'blockedfromgroup',
142 array('nickname' => $this->group->nickname));
146 class GroupBlockList extends ProfileList
150 function __construct($profile, $group, $action)
152 parent::__construct($profile, $action);
154 $this->group = $group;
157 function newListItem($profile)
159 return new GroupBlockListItem($profile, $this->group, $this->action);
163 class GroupBlockListItem extends ProfileListItem
167 function __construct($profile, $group, $action)
169 parent::__construct($profile, $action);
171 $this->group = $group;
174 function showActions()
176 $this->startActions();
177 $this->showGroupUnblockForm();
181 function showGroupUnblockForm()
183 $user = common_current_user();
185 if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
186 $this->out->elementStart('li', 'entity_block');
187 $bf = new GroupUnblockForm($this->out, $this->profile, $this->group,
188 array('action' => 'blockedfromgroup',
189 'nickname' => $this->group->nickname));
191 $this->out->elementEnd('li');
197 * Form for unblocking a user from a group
201 * @author Evan Prodromou <evan@status.net>
202 * @author Sarven Capadisli <csarven@status.net>
203 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
204 * @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
238 function __construct($out=null, $profile=null, $group=null, $args=null)
240 parent::__construct($out);
242 $this->profile = $profile;
243 $this->group = $group;
250 * @return int ID of the form
255 // This should be unique for the page.
256 return 'unblock-' . $this->profile->id;
262 * @return string class of the form
267 return 'form_group_unblock';
273 * @return string URL of the action
278 return common_local_url('groupunblock');
286 function formLegend()
288 $this->out->element('legend', null, _('Unblock user from group'));
292 * Data elements of the form
299 $this->out->hidden('unblockto-' . $this->profile->id,
302 $this->out->hidden('unblockgroup-' . $this->group->id,
306 foreach ($this->args as $k => $v) {
307 $this->out->hidden('returnto-' . $k, $v);
318 function formActions()
320 $this->out->submit('submit', _('Unblock'), 'submit', null, _('Unblock this user'));