123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ApiGroupIsMemberAction extends ApiBareAuthAction
- {
- var $group = null;
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $this->target = $this->getTargetProfile(null);
- $this->group = $this->getTargetGroup(null);
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
- if (empty($this->target)) {
-
- $this->clientError(_('No such user.'), 404);
- }
- if (empty($this->group)) {
-
- $this->clientError(_('Group not found.'), 404);
- }
- $is_member = $this->target->isMember($this->group);
- switch($this->format) {
- case 'xml':
- $this->initDocument('xml');
- $this->element('is_member', null, $is_member);
- $this->endDocument('xml');
- break;
- case 'json':
- $this->initDocument('json');
- $this->showJsonObjects(array('is_member' => $is_member));
- $this->endDocument('json');
- break;
- default:
-
- $this->clientError(_('API method not found.'));
- }
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|