123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class BlockedfromgroupAction extends GroupAction
- {
- var $page = null;
- function isReadOnly($args)
- {
- return true;
- }
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
- $nickname_arg = $this->arg('nickname');
- $nickname = common_canonical_nickname($nickname_arg);
-
- if ($nickname_arg != $nickname) {
- $args = array('nickname' => $nickname);
- if ($this->page != 1) {
- $args['page'] = $this->page;
- }
- common_redirect(common_local_url('blockedfromgroup', $args), 301);
- }
- if (!$nickname) {
-
- $this->clientError(_('No nickname.'), 404);
- }
- $local = Local_group::getKV('nickname', $nickname);
- if (!$local) {
-
- $this->clientError(_('No such group.'), 404);
- }
- $this->group = User_group::getKV('id', $local->group_id);
- if (!$this->group) {
-
- $this->clientError(_('No such group.'), 404);
- }
- return true;
- }
- function title()
- {
- if ($this->page == 1) {
-
-
- return sprintf(_('%s blocked profiles'),
- $this->group->nickname);
- } else {
-
-
- return sprintf(_('%1$s blocked profiles, page %2$d'),
- $this->group->nickname,
- $this->page);
- }
- }
- protected function handle()
- {
- parent::handle();
- $this->showPage();
- }
- function showPageNotice()
- {
- $this->element('p', 'instructions',
-
- _('A list of the users blocked from joining this group.'));
- }
- function showContent()
- {
- $offset = ($this->page-1) * PROFILES_PER_PAGE;
- $limit = PROFILES_PER_PAGE + 1;
- $cnt = 0;
- $blocked = $this->group->getBlocked($offset, $limit);
- if ($blocked) {
- $blocked_list = new GroupBlockList($blocked, $this->group, $this);
- $cnt = $blocked_list->show();
- }
- $blocked->free();
- $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
- $this->page, 'blockedfromgroup',
- array('nickname' => $this->group->nickname));
- }
- }
- class GroupBlockList extends ProfileList
- {
- var $group = null;
- function __construct($profile, $group, $action)
- {
- parent::__construct($profile, $action);
- $this->group = $group;
- }
- function newListItem(Profile $profile)
- {
- return new GroupBlockListItem($profile, $this->group, $this->action);
- }
- }
- class GroupBlockListItem extends ProfileListItem
- {
- var $group = null;
- function __construct($profile, $group, $action)
- {
- parent::__construct($profile, $action);
- $this->group = $group;
- }
- function showActions()
- {
- $this->startActions();
- $this->showGroupUnblockForm();
- $this->endActions();
- }
- function showGroupUnblockForm()
- {
- $user = common_current_user();
- if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
- $this->out->elementStart('li', 'entity_block');
- $bf = new GroupUnblockForm($this->out, $this->profile, $this->group,
- array('action' => 'blockedfromgroup',
- 'nickname' => $this->group->nickname));
- $bf->show();
- $this->out->elementEnd('li');
- }
- }
- }
- class GroupUnblockForm extends Form
- {
-
- var $profile = null;
-
- var $group = null;
-
- var $args = null;
-
- function __construct($out=null, $profile=null, $group=null, $args=null)
- {
- parent::__construct($out);
- $this->profile = $profile;
- $this->group = $group;
- $this->args = $args;
- }
-
- function id()
- {
-
- return 'unblock-' . $this->profile->id;
- }
-
- function formClass()
- {
- return 'form_group_unblock';
- }
-
- function action()
- {
- return common_local_url('groupunblock');
- }
-
- function formLegend()
- {
-
- $this->out->element('legend', null, _('Unblock user from group'));
- }
-
- function formData()
- {
- $this->out->hidden('unblockto-' . $this->profile->id,
- $this->profile->id,
- 'unblockto');
- $this->out->hidden('unblockgroup-' . $this->group->id,
- $this->group->id,
- 'unblockgroup');
- if ($this->args) {
- foreach ($this->args as $k => $v) {
- $this->out->hidden('returnto-' . $k, $v);
- }
- }
- }
-
- function formActions()
- {
- $this->out->submit('submit',
-
- _m('BUTTON','Unblock'),
- 'submit',
- null,
-
- _('Unblock this user'));
- }
- }
|