X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapilist.php;h=94d95df5ef71f1744cb44747a8be3fa94bcd6e64;hb=26703076f66f77f337559416cc02101c532d7aa8;hp=7a9ce70c5c80f8d56a250c6c9462c1910aefc6ac;hpb=e75c9988ebe33822e493ac225859bc593ff9b855;p=quix0rs-gnu-social.git diff --git a/actions/apilist.php b/actions/apilist.php index 7a9ce70c5c..94d95df5ef 100644 --- a/actions/apilist.php +++ b/actions/apilist.php @@ -30,26 +30,21 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apibareauth.php'; - class ApiListAction extends ApiBareAuthAction { /** * The list in question in the current request */ - var $list = null; /** * Is this an update request? */ - var $update = false; /** * Is this a delete request? */ - var $delete = false; /** @@ -64,8 +59,7 @@ class ApiListAction extends ApiBareAuthAction * * @return boolean success flag */ - - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); @@ -81,8 +75,8 @@ class ApiListAction extends ApiBareAuthAction $this->list = $this->getTargetList($this->arg('user'), $this->arg('id')); if (empty($this->list)) { - $this->clientError(_('Not found'), 404, $this->format); - return false; + // TRANS: Client error displayed when referring to a non-existing list. + $this->clientError(_('List not found.'), 404); } return true; @@ -93,10 +87,9 @@ class ApiListAction extends ApiBareAuthAction * * @return boolean success flag */ - - function handle($args) + protected function handle() { - parent::handle($args); + parent::handle(); if($this->delete) { $this->handleDelete(); @@ -116,12 +109,8 @@ class ApiListAction extends ApiBareAuthAction $this->showSingleJsonList($this->list); break; default: - $this->clientError( - _('API method not found.'), - 404, - $this->format - ); - break; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); } } @@ -129,7 +118,6 @@ class ApiListAction extends ApiBareAuthAction * require authentication if it is a write action or user is ambiguous * */ - function requiresAuth() { return parent::requiresAuth() || @@ -141,15 +129,11 @@ class ApiListAction extends ApiBareAuthAction * * @return boolean success */ - function handlePut() { if($this->auth_user->id != $this->list->tagger) { - $this->clientError( - _('You can not update lists that don\'t belong to you.'), - 401, - $this->format - ); + // TRANS: Client error displayed when trying to update another user's list. + $this->clientError(_('You cannot update lists that do not belong to you.'), 401); } $new_list = clone($this->list); @@ -160,11 +144,8 @@ class ApiListAction extends ApiBareAuthAction $result = $new_list->update($this->list); if(!$result) { - $this->clientError( - _('An error occured.'), - 503, - $this->format - ); + // TRANS: Client error displayed when an unknown error occurs updating a list. + $this->clientError(_('An error occured.'), 503); } switch($this->format) { @@ -175,12 +156,8 @@ class ApiListAction extends ApiBareAuthAction $this->showSingleJsonList($new_list); break; default: - $this->clientError( - _('API method not found.'), - 404, - $this->format - ); - break; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); } } @@ -189,15 +166,11 @@ class ApiListAction extends ApiBareAuthAction * * @return boolean success */ - function handleDelete() { if($this->auth_user->id != $this->list->tagger) { - $this->clientError( - _('You can not delete lists that don\'t belong to you.'), - 401, - $this->format - ); + // TRANS: Client error displayed when trying to delete another user's list. + $this->clientError(_('You cannot delete lists that do not belong to you.'), 401); } $record = clone($this->list); @@ -211,12 +184,8 @@ class ApiListAction extends ApiBareAuthAction $this->showSingleJsonList($record); break; default: - $this->clientError( - _('API method not found.'), - 404, - $this->format - ); - break; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); } } @@ -225,8 +194,7 @@ class ApiListAction extends ApiBareAuthAction * * @return boolean is_read-only=false */ - - function isReadOnly($args) + function isReadOnly(array $args=array()) { return false; } @@ -236,7 +204,6 @@ class ApiListAction extends ApiBareAuthAction * * @return String time_last_modified */ - function lastModified() { if(!empty($this->list)) { @@ -253,7 +220,6 @@ class ApiListAction extends ApiBareAuthAction * * @return string etag */ - function etag() { if (!empty($this->list)) { @@ -271,5 +237,4 @@ class ApiListAction extends ApiBareAuthAction return null; } - }