123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR . '/lib/api/apilistusers.php';
- class ApiListMembersAction extends ApiListUsersAction
- {
-
- function handlePost()
- {
- if($this->auth_user->id != $this->list->tagger) {
-
- $this->clientError(_('You are not allowed to add members to this list.'), 401);
- }
- if (!($this->target instanceof Profile)) {
-
- $this->clientError(_('You must specify a member.'));
- }
- $result = Profile_tag::setTag($this->auth_user->id,
- $this->target->id, $this->list->tag);
- 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()
- {
- if($this->auth_user->id != $this->list->tagger) {
-
- $this->clientError(_('You are not allowed to remove members from this list.'), 401);
- }
- if (!($this->target instanceof Profile)) {
-
- $this->clientError(_('You must specify a member.'));
- }
- $args = array('tagger' => $this->auth_user->id,
- 'tagged' => $this->target->id,
- 'tag' => $this->list->tag);
- $ptag = Profile_tag::pkeyGet($args);
- if (empty($ptag)) {
-
- $this->clientError(_('The user you are trying to remove from the list is not a member.'));
- }
- if (!$ptag->delete()) {
-
- $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, 'getTagged');
- list($this->users, $this->next_cursor, $this->prev_cursor) =
- Profile_list::getAtCursor($fn, array(), $this->cursor, 20);
- }
- }
|