X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapilistsubscriptions.php;h=e5d8aebc4f7b74e5db898ae4c0fddf10fa061a55;hb=7ccd36849e945260bb8169c816d96901e90f6a26;hp=480523033bbf9d119cb58bc2b0c1da8d4199c90d;hpb=25198a8d4cee5b2182f1ecb99192a4108a01afa4;p=quix0rs-gnu-social.git diff --git a/actions/apilistsubscriptions.php b/actions/apilistsubscriptions.php index 480523033b..e5d8aebc4f 100644 --- a/actions/apilistsubscriptions.php +++ b/actions/apilistsubscriptions.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apibareauth.php'; - class ApiListSubscriptionsAction extends ApiBareAuthAction { var $lists = array(); @@ -48,12 +46,17 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction * @return boolean success flag * */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); $this->cursor = (int) $this->arg('cursor', -1); - $this->user = $this->getTargetUser($this->arg('user')); + $user = $this->getTargetUser($this->arg('user')); + if (!($user instanceof User)) { + // TRANS: Client error displayed trying to perform an action related to a non-existing user. + $this->clientError(_('No such user.'), 404); + } + $this->target = $user->getProfile(); $this->getLists(); return true; @@ -64,19 +67,11 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction * * Show the lists * - * @param array $args $_REQUEST data (unused) - * * @return void */ - function handle($args) + protected function handle() { - parent::handle($args); - - if (empty($this->user)) { - // TRANS: Client error displayed trying to perform an action related to a non-existing user. - $this->clientError(_('No such user.'), 404, $this->format); - return; - } + parent::handle(); switch($this->format) { case 'xml': @@ -86,13 +81,8 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction $this->showJsonLists($this->lists, $this->next_cursor, $this->prev_cursor); break; default: - $this->clientError( - // TRANS: Client error displayed when coming across a non-supported API method. - _('API method not found.'), - 400, - $this->format - ); - break; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.')); } } @@ -112,12 +102,7 @@ class ApiListSubscriptionsAction extends ApiBareAuthAction function getLists() { - if(empty($this->user)) { - return; - } - - $profile = $this->user->getProfile(); - $fn = array($profile, 'getTagSubscriptions'); + $fn = array($this->target, 'getTagSubscriptions'); # 20 lists list($this->lists, $this->next_cursor, $this->prev_cursor) = Profile_list::getAtCursor($fn, array(), $this->cursor, 20);