3 * StatusNet, the distributed open-source microblogging tool
5 * List/add/remove list 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 Shashi Gowda <connect2shashi@gmail.com>
25 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
26 * @link http://status.net/
29 if (!defined('STATUSNET')) {
33 require_once INSTALLDIR . '/lib/apilistusers.php';
35 class ApiListMembersAction extends ApiListUsersAction
38 * Add a user to a list (tag someone)
40 * @return boolean success
45 if($this->auth_user->id != $this->list->tagger) {
47 _('You aren\'t allowed to add members to this list'),
54 if($this->user === false) {
56 _('You must specify a member'),
63 $result = Profile_tag::setTag($this->auth_user->id,
64 $this->user->id, $this->list->tag);
68 _('An error occured.'),
75 switch($this->format) {
77 $this->showSingleXmlList($this->list);
80 $this->showSingleJsonList($this->list);
84 _('API method not found.'),
94 * Remove a user from a list (untag someone)
96 * @return boolean success
99 function handleDelete()
101 if($this->auth_user->id != $this->list->tagger) {
103 _('You aren\'t allowed to remove members from this list'),
110 if($this->user === false) {
112 _('You must specify a member'),
119 $args = array('tagger' => $this->auth_user->id,
120 'tagged' => $this->user->id,
121 'tag' => $this->list->tag);
122 $ptag = Profile_tag::pkeyGet($args);
126 _('The user you are trying to remove from the list is not a member'),
133 $result = $ptag->delete();
137 _('An error occured.'),
144 switch($this->format) {
146 $this->showSingleXmlList($this->list);
149 $this->showSingleJsonList($this->list);
153 _('API method not found.'),
164 * List the members of a list (people tagged)
169 $fn = array($this->list, 'getTagged');
170 list($this->users, $this->next_cursor, $this->prev_cursor) =
171 Profile_list::getAtCursor($fn, array(), $this->cursor, 20);