123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR . '/lib/api/apilistusers.php';
- class ApiListSubscribersAction extends ApiListUsersAction
- {
-
- function handlePost()
- {
- $result = Profile_tag_subscription::add($this->list,
- $this->auth_user);
- if(empty($result)) {
-
- $this->clientError(_('An error occured.'), 500);
- }
- switch($this->format) {
- case 'xml':
- $this->showSingleXmlList($this->list);
- break;
- case 'json':
- $this->showSingleJsonList($this->list);
- break;
- default:
-
- $this->clientError(_('API method not found.'), 404);
- }
- }
- function handleDelete()
- {
- $args = array('profile_tag_id' => $this->list->id,
- 'profile_id' => $this->auth_user->id);
- $ptag = Profile_tag_subscription::pkeyGet($args);
- if(empty($ptag)) {
-
- $this->clientError(_('You are not subscribed to this list.'));
- }
- $result = Profile_tag_subscription::remove($this->list, $this->auth_user);
- if (empty($result)) {
-
- $this->clientError(_('An error occured.'), 500);
- }
- switch($this->format) {
- case 'xml':
- $this->showSingleXmlList($this->list);
- break;
- case 'json':
- $this->showSingleJsonList($this->list);
- break;
- default:
-
- $this->clientError(_('API method not found.'), 404);
- }
- return true;
- }
- function getUsers()
- {
- $fn = array($this->list, 'getSubscribers');
- list($this->users, $this->next_cursor, $this->prev_cursor) =
- Profile_list::getAtCursor($fn, array(), $this->cursor, 20);
- }
- }
|