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
44 if($this->auth_user->id != $this->list->tagger) {
46 // TRANS: Client error displayed when trying to add members to a list without having the right to do so.
47 _('You are not allowed to add members to this list.'),
54 if($this->user === false) {
56 // TRANS: Client error displayed when trying to modify list members without specifying them.
57 _('You must specify a member.'),
64 $result = Profile_tag::setTag($this->auth_user->id,
65 $this->user->id, $this->list->tag);
69 // TRANS: Client error displayed when an unknown error occurs viewing list members.
70 _('An error occured.'),
77 switch($this->format) {
79 $this->showSingleXmlList($this->list);
82 $this->showSingleJsonList($this->list);
86 // TRANS: Client error displayed when coming across a non-supported API method.
87 _('API method not found.'),
97 * Remove a user from a list (untag someone)
99 * @return boolean success
101 function handleDelete()
103 if($this->auth_user->id != $this->list->tagger) {
105 // TRANS: Client error displayed when trying to remove members from a list without having the right to do so.
106 _('You are not allowed to remove members from this list.'),
113 if($this->user === false) {
115 // TRANS: Client error displayed when trying to modify list members without specifying them.
116 _('You must specify a member.'),
123 $args = array('tagger' => $this->auth_user->id,
124 'tagged' => $this->user->id,
125 'tag' => $this->list->tag);
126 $ptag = Profile_tag::pkeyGet($args);
130 // TRANS: Client error displayed when trying to remove a list member that is not part of a list.
131 _('The user you are trying to remove from the list is not a member.'),
138 $result = $ptag->delete();
142 // TRANS: Client error displayed when an unknown error occurs viewing list members.
143 _('An error occured.'),
150 switch($this->format) {
152 $this->showSingleXmlList($this->list);
155 $this->showSingleJsonList($this->list);
159 // TRANS: Client error displayed when coming across a non-supported API method.
160 _('API method not found.'),
171 * List the members of a list (people tagged)
175 $fn = array($this->list, 'getTagged');
176 list($this->users, $this->next_cursor, $this->prev_cursor) =
177 Profile_list::getAtCursor($fn, array(), $this->cursor, 20);