X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapilistmembers.php;h=bd78451d5ee76c180d2995ddb996b936647b9ae0;hb=c114c6bbad8a26465a379ef9852a8dcb7cb94e1f;hp=c6e92fa61279805ea4af5419aaab237a8843a981;hpb=e75c9988ebe33822e493ac225859bc593ff9b855;p=quix0rs-gnu-social.git diff --git a/actions/apilistmembers.php b/actions/apilistmembers.php index c6e92fa612..bd78451d5e 100644 --- a/actions/apilistmembers.php +++ b/actions/apilistmembers.php @@ -39,37 +39,24 @@ class ApiListMembersAction extends ApiListUsersAction * * @return boolean success */ - function handlePost() { if($this->auth_user->id != $this->list->tagger) { - $this->clientError( - _('You aren\'t allowed to add members to this list'), - 401, - $this->format - ); - return false; + // TRANS: Client error displayed when trying to add members to a list without having the right to do so. + $this->clientError(_('You are not allowed to add members to this list.'), 401); } - if($this->user === false) { - $this->clientError( - _('You must specify a member'), - 400, - $this->format - ); - return false; + if (!($this->target instanceof Profile)) { + // TRANS: Client error displayed when trying to modify list members without specifying them. + $this->clientError(_('You must specify a member.')); } $result = Profile_tag::setTag($this->auth_user->id, - $this->user->id, $this->list->tag); + $this->target->id, $this->list->tag); if(empty($result)) { - $this->clientError( - _('An error occured.'), - 500, - $this->format - ); - return false; + // TRANS: Client error displayed when an unknown error occurs viewing list members. + $this->clientError(_('An error occured.'), 500); } switch($this->format) { @@ -80,13 +67,8 @@ class ApiListMembersAction extends ApiListUsersAction $this->showSingleJsonList($this->list); break; default: - $this->clientError( - _('API method not found.'), - 404, - $this->format - ); - return false; - break; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); } } @@ -95,50 +77,31 @@ class ApiListMembersAction extends ApiListUsersAction * * @return boolean success */ - function handleDelete() { if($this->auth_user->id != $this->list->tagger) { - $this->clientError( - _('You aren\'t allowed to remove members from this list'), - 401, - $this->format - ); - return false; + // TRANS: Client error displayed when trying to remove members from a list without having the right to do so. + $this->clientError(_('You are not allowed to remove members from this list.'), 401); } - if($this->user === false) { - $this->clientError( - _('You must specify a member'), - 400, - $this->format - ); - return false; + if (!($this->target instanceof Profile)) { + // TRANS: Client error displayed when trying to modify list members without specifying them. + $this->clientError(_('You must specify a member.')); } $args = array('tagger' => $this->auth_user->id, - 'tagged' => $this->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'), - 400, - $this->format - ); - return false; + if (empty($ptag)) { + // TRANS: Client error displayed when trying to remove a list member that is not part of a list. + $this->clientError(_('The user you are trying to remove from the list is not a member.')); } - $result = $ptag->delete(); - - if(empty($result)) { - $this->clientError( - _('An error occured.'), - 500, - $this->format - ); - return false; + if (!$ptag->delete()) { + // TRANS: Client error displayed when an unknown error occurs viewing list members. + $this->clientError(_('An error occured.'), 500); } switch($this->format) { @@ -149,21 +112,16 @@ class ApiListMembersAction extends ApiListUsersAction $this->showSingleJsonList($this->list); break; default: - $this->clientError( - _('API method not found.'), - 404, - $this->format - ); - return false; - break; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); } + return true; } /** * List the members of a list (people tagged) */ - function getUsers() { $fn = array($this->list, 'getTagged');