3 * StatusNet, the distributed open-source microblogging tool
5 * Show/add/remove list subscribers.
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 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
25 * @link http://status.net/
28 if (!defined('STATUSNET')) {
32 require_once INSTALLDIR . '/lib/apilistusers.php';
34 class ApiListSubscribersAction extends ApiListUsersAction
39 * @return boolean success
43 $result = Profile_tag_subscription::add($this->list,
47 // TRANS: Client error displayed when an unknown error occurs in the list subscribers action.
48 $this->clientError(_('An error occured.'), 500);
51 switch($this->format) {
53 $this->showSingleXmlList($this->list);
56 $this->showSingleJsonList($this->list);
59 // TRANS: Client error displayed when coming across a non-supported API method.
60 $this->clientError(_('API method not found.'), 404);
64 function handleDelete()
66 $args = array('profile_tag_id' => $this->list->id,
67 'profile_id' => $this->auth_user->id);
68 $ptag = Profile_tag_subscription::pkeyGet($args);
71 // TRANS: Client error displayed when trying to unsubscribe from a non-subscribed list.
72 $this->clientError(_('You are not subscribed to this list.'));
75 $result = Profile_tag_subscription::remove($this->list, $this->auth_user);
78 // TRANS: Client error displayed when an unknown error occurs unsubscribing from a list.
79 $this->clientError(_('An error occured.'), 500);
82 switch($this->format) {
84 $this->showSingleXmlList($this->list);
87 $this->showSingleJsonList($this->list);
90 // TRANS: Client error displayed when coming across a non-supported API method.
91 $this->clientError(_('API method not found.'), 404);
98 $fn = array($this->list, 'getSubscribers');
99 list($this->users, $this->next_cursor, $this->prev_cursor) =
100 Profile_list::getAtCursor($fn, array(), $this->cursor, 20);