X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigroupleave.php;h=bdfa36aa432bf682623a09bd6e82f9e44a80e32f;hb=cc34bb48c7243f78e198ad4d8c1806d5fe886a81;hp=0ceb3523c8483a95f6f45dc1a31a9a4a8d755175;hpb=8d0c014ced78b3b6328105e2a82e3776059b600a;p=quix0rs-gnu-social.git diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php index 0ceb3523c8..bdfa36aa43 100644 --- a/actions/apigroupleave.php +++ b/actions/apigroupleave.php @@ -35,8 +35,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiauth.php'; - /** * Removes the authenticated user from the group specified by ID * @@ -116,22 +114,15 @@ class ApiGroupLeaveAction extends ApiAuthAction return; } - $result = $member->delete(); - - if (!$result) { - common_log_db_error($member, 'DELETE', __FILE__); - $this->serverError( - sprintf( - // TRANS: Server error displayed when leaving a group fails. - // TRANS: %1$s is a user nickname, $2$s is a group nickname. - _('Could not remove user %1$s from group %2$s.'), - $this->user->nickname, - $this->group->nickname - ) - ); + try { + $this->user->leaveGroup($this->group); + } catch (Exception $e) { + // TRANS: Server error displayed when leaving a group failed in the database. + // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed. + $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), + $cur->nickname, $this->group->nickname)); return; } - switch($this->format) { case 'xml': $this->showSingleXmlGroup($this->group); @@ -141,7 +132,7 @@ class ApiGroupLeaveAction extends ApiAuthAction break; default: $this->clientError( - // TRANS: Client error displayed trying to execute an unknown API method leaving a group. + // TRANS: Client error displayed when coming across a non-supported API method. _('API method not found.'), 404, $this->format