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')) {
34 require_once(INSTALLDIR.'/lib/profilelist.php');
35 require_once INSTALLDIR.'/lib/publicgroupnav.php';
38 * List of group members
42 * @author Evan Prodromou <evan@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
46 class GroupqueueAction extends GroupAction
50 function isReadOnly(array $args=array())
55 // @todo FIXME: most of this belongs in a base class, sounds common to most group actions?
56 protected function prepare(array $args=array())
58 parent::prepare($args);
59 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
61 $nickname_arg = $this->arg('nickname');
62 $nickname = common_canonical_nickname($nickname_arg);
64 // Permanent redirect on non-canonical nickname
66 if ($nickname_arg != $nickname) {
67 $args = array('nickname' => $nickname);
68 if ($this->page != 1) {
69 $args['page'] = $this->page;
71 common_redirect(common_local_url('groupqueue', $args), 301);
75 // TRANS: Client error displayed when trying to view group members without providing a group nickname.
76 $this->clientError(_('No nickname.'), 404);
79 $local = Local_group::getKV('nickname', $nickname);
82 // TRANS: Client error displayed when trying to view group members for a non-existing group.
83 $this->clientError(_('No such group.'), 404);
86 $this->group = User_group::getKV('id', $local->group_id);
89 // TRANS: Client error displayed when trying to view group members for an object that is not a group.
90 $this->clientError(_('No such group.'), 404);
93 $cur = common_current_user();
94 if (!$cur || !$cur->isAdmin($this->group)) {
95 // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
96 $this->clientError(_('Only the group admin may approve users.'));
103 if ($this->page == 1) {
104 // TRANS: Title of the first page showing pending group members still awaiting approval to join the group.
105 // TRANS: %s is the name of the group.
106 return sprintf(_('%s group members awaiting approval'),
107 $this->group->nickname);
109 // TRANS: Title of all but the first page showing pending group members still awaiting approval to join the group.
110 // TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
111 return sprintf(_('%1$s group members awaiting approval, page %2$d'),
112 $this->group->nickname,
117 protected function handle()
123 function showPageNotice()
125 $this->element('p', 'instructions',
126 // TRANS: Page notice for group members page.
127 _('A list of users awaiting approval to join this group.'));
130 function showContent()
132 $offset = ($this->page-1) * PROFILES_PER_PAGE;
133 $limit = PROFILES_PER_PAGE + 1;
137 $members = $this->group->getRequests($offset, $limit);
141 $member_list = new GroupQueueList($members, $this->group, $this);
142 $cnt = $member_list->show();
147 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
148 $this->page, 'groupqueue',
149 array('nickname' => $this->group->nickname));
153 // @todo FIXME: documentation missing.
154 class GroupQueueList extends GroupMemberList
156 function newListItem($profile)
158 return new GroupQueueListItem($profile, $this->group, $this->action);
162 // @todo FIXME: documentation missing.
163 class GroupQueueListItem extends GroupMemberListItem
165 function showActions()
167 $this->startActions();
168 if (Event::handle('StartProfileListItemActionElements', array($this))) {
169 $this->showApproveButtons();
170 Event::handle('EndProfileListItemActionElements', array($this));
175 function showApproveButtons()
177 $this->out->elementStart('li', 'entity_approval');
178 $form = new ApproveGroupForm($this->out, $this->group, $this->profile);
180 $this->out->elementEnd('li');