X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapilistmembers.php;h=bd78451d5ee76c180d2995ddb996b936647b9ae0;hb=c95f74018d8e997fabc07a42afb75e39c769531f;hp=0c003fd6dccb18763efe56ec729515e0e5c797cc;hpb=c97048d01bea468e0cf8865b60c3c250b4515c39;p=quix0rs-gnu-social.git diff --git a/actions/apilistmembers.php b/actions/apilistmembers.php index 0c003fd6dc..bd78451d5e 100644 --- a/actions/apilistmembers.php +++ b/actions/apilistmembers.php @@ -42,36 +42,21 @@ class ApiListMembersAction extends ApiListUsersAction function handlePost() { if($this->auth_user->id != $this->list->tagger) { - $this->clientError( - // TRANS: Client error displayed when trying to add members to a list without having the right to do so. - _('You are not 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( - // TRANS: Client error displayed when trying to modify list members without specifying them. - _('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( - // TRANS: Client error displayed when an unknown error occurs viewing list members. - _('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) { @@ -82,14 +67,8 @@ class ApiListMembersAction extends ApiListUsersAction $this->showSingleJsonList($this->list); break; default: - $this->clientError( - // TRANS: Client error displayed when coming across a non-supported API method. - _('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); } } @@ -101,50 +80,28 @@ class ApiListMembersAction extends ApiListUsersAction function handleDelete() { if($this->auth_user->id != $this->list->tagger) { - $this->clientError( - // TRANS: Client error displayed when trying to remove members from a list without having the right to do so. - _('You are not 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( - // TRANS: Client error displayed when trying to modify list members without specifying them. - _('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( - // TRANS: Client error displayed when trying to remove a list member that is not part of a list. - _('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( - // TRANS: Client error displayed when an unknown error occurs viewing list members. - _('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) { @@ -155,15 +112,10 @@ class ApiListMembersAction extends ApiListUsersAction $this->showSingleJsonList($this->list); break; default: - $this->clientError( - // TRANS: Client error displayed when coming across a non-supported API method. - _('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; }