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 GroupDesignAction
50 function isReadOnly($args)
55 // @todo FIXME: most of this belongs in a base class, sounds common to most group actions?
56 function prepare($args)
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);
76 // TRANS: Client error displayed when trying to view group members without providing a group nickname.
77 $this->clientError(_('No nickname.'), 404);
81 $local = Local_group::staticGet('nickname', $nickname);
84 // TRANS: Client error displayed when trying to view group members for a non-existing group.
85 $this->clientError(_('No such group.'), 404);
89 $this->group = User_group::staticGet('id', $local->group_id);
92 // TRANS: Client error displayed when trying to view group members for an object that is not a group.
93 $this->clientError(_('No such group.'), 404);
97 $cur = common_current_user();
98 if (!$cur || !$cur->isAdmin($this->group)) {
99 // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
100 $this->clientError(_('Only the group admin may approve users.'));
108 if ($this->page == 1) {
109 // TRANS: Title of the first page showing pending group members still awaiting approval to join the group.
110 // TRANS: %s is the name of the group.
111 return sprintf(_('%s group members awaiting approval'),
112 $this->group->nickname);
114 // TRANS: Title of all but the first page showing pending group members still awaiting approval to join the group.
115 // TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
116 return sprintf(_('%1$s group members awaiting approval, page %2$d'),
117 $this->group->nickname,
122 function handle($args)
124 parent::handle($args);
128 function showPageNotice()
130 $this->element('p', 'instructions',
131 // TRANS: Page notice for group members page.
132 _('A list of users awaiting approval to join this group.'));
135 function showObjectNav()
137 $nav = new GroupNav($this, $this->group);
141 function showContent()
143 $offset = ($this->page-1) * PROFILES_PER_PAGE;
144 $limit = PROFILES_PER_PAGE + 1;
148 $members = $this->group->getRequests($offset, $limit);
152 $member_list = new GroupQueueList($members, $this->group, $this);
153 $cnt = $member_list->show();
158 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
159 $this->page, 'groupqueue',
160 array('nickname' => $this->group->nickname));
164 class GroupQueueList extends GroupMemberList
166 function newListItem($profile)
168 return new GroupQueueListItem($profile, $this->group, $this->action);
172 class GroupQueueListItem extends GroupMemberListItem
174 function showActions()
176 $this->startActions();
177 if (Event::handle('StartProfileListItemActionElements', array($this))) {
178 $this->showApproveButtons();
179 Event::handle('EndProfileListItemActionElements', array($this));
184 function showApproveButtons()
186 $this->out->elementStart('li', 'entity_approval');
187 $form = new ApproveGroupForm($this->out, $this->group, $this->profile);
189 $this->out->elementEnd('li');