* 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
exit(1);
}
-require_once INSTALLDIR . '/lib/apiauth.php';
-
/**
* Show (or delete) a single membership event as an ActivityStreams entry
*
* @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;
*
* @return boolean true
*/
-
function prepare($argarray)
{
parent::prepare($argarray);
$profileId = $this->trimmed('profile');
- $this->_profile = Profile::staticGet('id', $profileId);
-
+ $this->_profile = Profile::getKV('id', $profileId);
+
if (empty($this->_profile)) {
+ // TRANS: Client exception.
throw new ClientException(_('No such profile.'), 404);
}
$groupId = $this->trimmed('group');
- $this->_group = User_group::staticGet('id', $groupId);
+ $this->_group = User_group::getKV('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,
$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;
*
* @return void
*/
-
function handle($argarray=null)
{
switch ($_SERVER['REQUEST_METHOD']) {
$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;
*
* @return void
*/
-
function showMembership()
{
$activity = $this->_membership->asActivity();
*
* @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;
}
*
* @return boolean is read only action?
*/
-
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
*
* @return string etag http header
*/
-
function etag()
{
$ctime = strtotime($this->_membership->created);
*
* @return boolean true if delete, else false
*/
-
function requiresAuth()
{
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||