3 * StatusNet, the distributed open-source microblogging tool
5 * List a group's 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 Craig Andrews <candrews@integralblue.com>
25 * @author Evan Prodromou <evan@status.net>
26 * @author Jeffery To <jeffery.to@gmail.com>
27 * @author Zach Copley <zach@status.net>
28 * @copyright 2009 StatusNet, Inc.
29 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
30 * @link http://status.net/
33 if (!defined('STATUSNET')) {
37 require_once INSTALLDIR . '/lib/apiprivateauth.php';
40 * List 20 newest members of the group specified by name or ID.
44 * @author Craig Andrews <candrews@integralblue.com>
45 * @author Evan Prodromou <evan@status.net>
46 * @author Jeffery To <jeffery.to@gmail.com>
47 * @author Zach Copley <zach@status.net>
48 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
49 * @link http://status.net/
52 class ApiGroupMembershipAction extends ApiPrivateAuthAction
58 * Take arguments for running
60 * @param array $args $_REQUEST args
62 * @return boolean success flag
66 function prepare($args)
68 parent::prepare($args);
70 $this->group = $this->getTargetGroup($this->arg('id'));
71 $this->profiles = $this->getProfiles();
79 * Show the members of the group
81 * @param array $args $_REQUEST data (unused)
86 function handle($args)
88 parent::handle($args);
92 switch($this->format) {
94 $this->showTwitterXmlUsers($this->profiles);
97 $this->showJsonUsers($this->profiles);
101 _('API method not found!'),
110 * Fetch the members of a group
112 * @return array $profiles list of profiles
115 function getProfiles()
119 $profile = $this->group->getMembers(
120 ($this->page - 1) * $this->count,
127 while ($profile->fetch()) {
128 $profiles[] = clone($profile);
135 * Is this action read only?
137 * @param array $args other arguments
139 * @return boolean true
142 function isReadOnly($args)
148 * When was this list of profiles last modified?
150 * @return string datestamp of the lastest profile in the group
153 function lastModified()
155 if (!empty($this->profiles) && (count($this->profiles) > 0)) {
156 return strtotime($this->profiles[0]->created);
163 * An entity tag for this list of groups
165 * Returns an Etag based on the action name, language
166 * the group id, and timestamps of the first and last
167 * user who has joined the group
169 * @return string etag
174 if (!empty($this->profiles) && (count($this->profiles) > 0)) {
176 $last = count($this->profiles) - 1;
178 return '"' . implode(
180 array($this->arg('action'),
183 strtotime($this->profiles[0]->created),
184 strtotime($this->profiles[$last]->created))