本文整理汇总了PHP中Group_member::leave方法的典型用法代码示例。如果您正苦于以下问题:PHP Group_member::leave方法的具体用法?PHP Group_member::leave怎么用?PHP Group_member::leave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group_member
的用法示例。
在下文中一共展示了Group_member::leave方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the request
*
* On POST, add the current user to the group
*
* @param array $args unused
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$cur = common_current_user();
try {
if (Event::handle('StartLeaveGroup', array($this->group, $cur))) {
Group_member::leave($this->group->id, $cur->id);
Event::handle('EndLeaveGroup', array($this->group, $cur));
}
} 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;
}
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title for leave group page after leaving.
$this->element('title', null, sprintf(_m('TITLE', '%1$s left group %2$s'), $cur->nickname, $this->group->nickname));
$this->elementEnd('head');
$this->elementStart('body');
$jf = new JoinForm($this, $this->group);
$jf->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
}
}
示例2: handle
function handle($channel)
{
$group = $this->getGroup($this->other);
$cur = $this->user;
if (!$group) {
$channel->error($cur, _('No such group.'));
return;
}
if (!$cur->isMember($group)) {
$channel->error($cur, _('You are not a member of that group.'));
return;
}
try {
if (Event::handle('StartLeaveGroup', array($group, $cur))) {
Group_member::leave($group->id, $cur->id);
Event::handle('EndLeaveGroup', array($group, $cur));
}
} catch (Exception $e) {
$channel->error($cur, sprintf(_('Could not remove user %s to group %s'), $cur->nickname, $group->nickname));
return;
}
$channel->output($cur, sprintf(_('%s left group %s'), $cur->nickname, $group->nickname));
}
示例3: handleLeave
/**
* A remote user left our group.
*/
function handleLeave()
{
$oprofile = $this->ensureProfile();
if (!$oprofile) {
$this->clientError(_m("Can't read profile to cancel group membership."));
}
if ($oprofile->isGroup()) {
$this->clientError(_m("Groups can't join groups."));
}
common_log(LOG_INFO, "Remote profile {$oprofile->uri} leaving local group {$this->group->nickname}");
$profile = $oprofile->localProfile();
try {
// @fixme event needs to be refactored as above
//if (Event::handle('StartLeaveGroup', array($this->group, $profile))) {
Group_member::leave($this->group->id, $profile->id);
//Event::handle('EndLeaveGroup', array($this->group, $profile));
//}
} catch (Exception $e) {
// TRANS: Server error. %1$s is a profile URI, %2$s is a group nickname.
$this->serverError(sprintf(_m('Could not remove remote user %1$s from group %2$s.'), $oprofile->uri, $this->group->nickname));
return;
}
}
示例4: moveActivity
function moveActivity($act, $sink, $user, $remote)
{
if (empty($user)) {
throw new Exception(sprintf(_("No such user %s."), $act->actor->id));
}
switch ($act->verb) {
case ActivityVerb::FAVORITE:
$this->log(LOG_INFO, "Moving favorite of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
// push it, then delete local
$sink->postActivity($act);
$notice = Notice::staticGet('uri', $act->objects[0]->id);
if (!empty($notice)) {
$fave = Fave::pkeyGet(array('user_id' => $user->id, 'notice_id' => $notice->id));
$fave->delete();
}
break;
case ActivityVerb::POST:
$this->log(LOG_INFO, "Moving notice {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
// XXX: send a reshare, not a post
$sink->postActivity($act);
$notice = Notice::staticGet('uri', $act->objects[0]->id);
if (!empty($notice)) {
$notice->delete();
}
break;
case ActivityVerb::JOIN:
$this->log(LOG_INFO, "Moving group join of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
$sink->postActivity($act);
$group = User_group::staticGet('uri', $act->objects[0]->id);
if (!empty($group)) {
Group_member::leave($group->id, $user->id);
}
break;
case ActivityVerb::FOLLOW:
if ($act->actor->id == $user->uri) {
$this->log(LOG_INFO, "Moving subscription to {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
$sink->postActivity($act);
$other = Profile::fromURI($act->objects[0]->id);
if (!empty($other)) {
Subscription::cancel($user->getProfile(), $other);
}
} else {
$otherUser = User::staticGet('uri', $act->actor->id);
if (!empty($otherUser)) {
$this->log(LOG_INFO, "Changing sub to {$act->objects[0]->id}" . "by {$act->actor->id} to {$remote->nickname}.");
$otherProfile = $otherUser->getProfile();
Subscription::start($otherProfile, $remote);
Subscription::cancel($otherProfile, $user->getProfile());
} else {
$this->log(LOG_NOTICE, "Not changing sub to {$act->objects[0]->id}" . "by remote {$act->actor->id} " . "to {$remote->nickname}.");
}
}
break;
}
}
示例5: deleteMembership
/**
* Delete the membership (leave the group)
*
* @return void
*/
function deleteMembership()
{
if (empty($this->auth_user) || $this->auth_user->id != $this->_profile->id) {
// 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));
}
return;
}
示例6: leaveGroup
/**
* Leave a group that this profile is a member of.
*
* @param User_group $group
*/
function leaveGroup(User_group $group)
{
if (Event::handle('StartLeaveGroup', array($group, $this))) {
Group_member::leave($group->id, $this->id);
self::blow('profile:groups:%d', $this->id);
self::blow('group:member_ids:%d', $group->id);
self::blow('group:member_count:%d', $group->id);
Event::handle('EndLeaveGroup', array($group, $this));
}
}
示例7: handle
/**
* Handle the request
*
* Save the new message
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(_('This method requires a POST.'), 400, $this->format);
return;
}
if (empty($this->user)) {
// TRANS: Client error displayed when trying to have a non-existing user leave a group.
$this->clientError(_('No such user.'), 404, $this->format);
return;
}
if (empty($this->group)) {
// TRANS: Client error displayed when trying to leave a group that does not exist.
$this->clientError(_('Group not found.'), 404, $this->format);
return false;
}
$member = new Group_member();
$member->group_id = $this->group->id;
$member->profile_id = $this->auth_user->id;
if (!$member->find(true)) {
// TRANS: Server error displayed when trying to leave a group the user is not a member of.
$this->serverError(_('You are not a member of this group.'));
return;
}
try {
if (Event::handle('StartLeaveGroup', array($this->group, $this->user))) {
Group_member::leave($this->group->id, $this->user->id);
Event::handle('EndLeaveGroup', array($this->group, $this->user));
}
} 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);
break;
case 'json':
$this->showSingleJsonGroup($this->group);
break;
default:
$this->clientError(_('API method not found.'), 404, $this->format);
break;
}
}
示例8: handle
/**
* Handle the request
*
* On POST, add the current user to the group
*
* @param array $args unused
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$cur = common_current_user();
try {
if (Event::handle('StartLeaveGroup', array($this->group, $cur))) {
Group_member::leave($this->group->id, $cur->id);
Event::handle('EndLeaveGroup', array($this->group, $cur));
}
} catch (Exception $e) {
$this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $cur->nickname, $this->group->nickname));
return;
}
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
$this->element('title', null, sprintf(_('%1$s left group %2$s'), $cur->nickname, $this->group->nickname));
$this->elementEnd('head');
$this->elementStart('body');
$jf = new JoinForm($this, $this->group);
$jf->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
}
}