]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/groupmembers.php
Rip out user, group and site design customization code
[quix0rs-gnu-social.git] / actions / groupmembers.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * List of group members
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Group
23  * @package   StatusNet
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/
28  */
29
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once(INSTALLDIR.'/lib/profilelist.php');
35 require_once INSTALLDIR.'/lib/publicgroupnav.php';
36
37 /**
38  * List of group members
39  *
40  * @category Group
41  * @package  StatusNet
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/
45  */
46 class GroupmembersAction extends GroupAction
47 {
48     var $page = null;
49
50     function isReadOnly($args)
51     {
52         return true;
53     }
54
55     function prepare($args)
56     {
57         parent::prepare($args);
58         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
59
60         $nickname_arg = $this->arg('nickname');
61         $nickname = common_canonical_nickname($nickname_arg);
62
63         // Permanent redirect on non-canonical nickname
64
65         if ($nickname_arg != $nickname) {
66             $args = array('nickname' => $nickname);
67             if ($this->page != 1) {
68                 $args['page'] = $this->page;
69             }
70             common_redirect(common_local_url('groupmembers', $args), 301);
71             return false;
72         }
73
74         if (!$nickname) {
75             // TRANS: Client error displayed when trying to view group members without providing a group nickname.
76             $this->clientError(_('No nickname.'), 404);
77             return false;
78         }
79
80         $local = Local_group::staticGet('nickname', $nickname);
81
82         if (!$local) {
83             // TRANS: Client error displayed when trying to view group members for a non-existing group.
84             $this->clientError(_('No such group.'), 404);
85             return false;
86         }
87
88         $this->group = User_group::staticGet('id', $local->group_id);
89
90         if (!$this->group) {
91             // TRANS: Client error displayed when trying to view group members for an object that is not a group.
92             $this->clientError(_('No such group.'), 404);
93             return false;
94         }
95
96         return true;
97     }
98
99     function title()
100     {
101         if ($this->page == 1) {
102             // TRANS: Title of the page showing group members.
103             // TRANS: %s is the name of the group.
104             return sprintf(_('%s group members'),
105                            $this->group->nickname);
106         } else {
107             // TRANS: Title of the page showing group members.
108             // TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
109             return sprintf(_('%1$s group members, page %2$d'),
110                            $this->group->nickname,
111                            $this->page);
112         }
113     }
114
115     function handle($args)
116     {
117         parent::handle($args);
118         $this->showPage();
119     }
120
121     function showPageNotice()
122     {
123         $this->element('p', 'instructions',
124                        // TRANS: Page notice for group members page.
125                        _('A list of the users in this group.'));
126     }
127
128     function showObjectNav()
129     {
130         $nav = new GroupNav($this, $this->group);
131         $nav->show();
132     }
133
134     function showContent()
135     {
136         $offset = ($this->page-1) * PROFILES_PER_PAGE;
137         $limit =  PROFILES_PER_PAGE + 1;
138
139         $cnt = 0;
140
141         $members = $this->group->getMembers($offset, $limit);
142
143         if ($members) {
144             $member_list = new GroupMemberList($members, $this->group, $this);
145             $cnt = $member_list->show();
146         }
147
148         $members->free();
149
150         $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
151                           $this->page, 'groupmembers',
152                           array('nickname' => $this->group->nickname));
153     }
154 }