X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fatompubshowmembership.php;h=8bf62912f5268eb8fd3891d859d5fb7dd8c12f0b;hb=b1cc12af2ce66d1066c7543c9797b1fba9faf88f;hp=6d848a2290e36e8890307b022cbcac97e23316cd;hpb=6e894c010fc0e7ddaaafa8795634d6343019aafb;p=quix0rs-gnu-social.git diff --git a/actions/atompubshowmembership.php b/actions/atompubshowmembership.php index 6d848a2290..8bf62912f5 100644 --- a/actions/atompubshowmembership.php +++ b/actions/atompubshowmembership.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Show a single membership as an Activity Streams entry - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class AtompubshowmembershipAction extends ApiAuthAction { private $_profile = null; @@ -60,7 +59,6 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); @@ -68,8 +66,9 @@ class AtompubshowmembershipAction extends ApiAuthAction $profileId = $this->trimmed('profile'); $this->_profile = Profile::staticGet('id', $profileId); - + if (empty($this->_profile)) { + // TRANS: Client exception. throw new ClientException(_('No such profile.'), 404); } @@ -78,7 +77,8 @@ class AtompubshowmembershipAction extends ApiAuthAction $this->_group = User_group::staticGet('id', $groupId); if (empty($this->_group)) { - throw new ClientException(_('No such group'), 404); + // TRANS: Client exception thrown when referencing a non-existing group. + throw new ClientException(_('No such group.'), 404); } $kv = array('group_id' => $groupId, @@ -87,7 +87,8 @@ class AtompubshowmembershipAction extends ApiAuthAction $this->_membership = Group_member::pkeyGet($kv); if (empty($this->_membership)) { - throw new ClientException(_('Not a member'), 404); + // TRANS: Client exception thrown when trying to show membership of a non-subscribed group + throw new ClientException(_('Not a member.'), 404); } return true; @@ -100,7 +101,6 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return void */ - function handle($argarray=null) { switch ($_SERVER['REQUEST_METHOD']) { @@ -112,7 +112,8 @@ class AtompubshowmembershipAction extends ApiAuthAction $this->deleteMembership(); break; default: - throw new ClientException(_('Method not supported'), 405); + // TRANS: Client exception thrown when using an unsupported HTTP method. + throw new ClientException(_('HTTP method not supported.'), 405); break; } return; @@ -123,7 +124,6 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return void */ - function showMembership() { $activity = $this->_membership->asActivity(); @@ -142,19 +142,16 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return void */ - function deleteMembership() { if (empty($this->auth_user) || $this->auth_user->id != $this->_profile->id) { - throw new ClientException(_("Can't delete someone else's". - " membership"), 403); + // TRANS: Client exception thrown when deleting someone else's membership. + throw new ClientException(_("Cannot delete someone else's". + " membership."), 403); } - if (Event::handle('StartLeaveGroup', array($this->_group, $this->auth_user))) { - Group_member::leave($this->_group->id, $this->auth_user->id); - Event::handle('EndLeaveGroup', array($this->_group, $this->auth_user)); - } + $this->auth_user->leaveGroup($this->_group); return; } @@ -168,7 +165,6 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return boolean is read only action? */ - function isReadOnly($args) { if ($_SERVER['REQUEST_METHOD'] == 'GET' || @@ -203,7 +199,6 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return string etag http header */ - function etag() { $ctime = strtotime($this->_membership->created); @@ -222,7 +217,6 @@ class AtompubshowmembershipAction extends ApiAuthAction * * @return boolean true if delete, else false */ - function requiresAuth() { if ($_SERVER['REQUEST_METHOD'] == 'GET' ||