diff options
Diffstat (limited to 'actions/leavegroup.php')
-rw-r--r-- | actions/leavegroup.php | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/actions/leavegroup.php b/actions/leavegroup.php index 9b9d83b6c..329b5aafe 100644 --- a/actions/leavegroup.php +++ b/actions/leavegroup.php @@ -62,23 +62,33 @@ class LeavegroupAction extends Action } $nickname_arg = $this->trimmed('nickname'); - $nickname = common_canonical_nickname($nickname_arg); + $id = intval($this->arg('id')); + if ($id) { + $this->group = User_group::staticGet('id', $id); + } else if ($nickname_arg) { + $nickname = common_canonical_nickname($nickname_arg); + + // Permanent redirect on non-canonical nickname + + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + common_redirect(common_local_url('leavegroup', $args), 301); + return false; + } - // Permanent redirect on non-canonical nickname + $local = Local_group::staticGet('nickname', $nickname); - if ($nickname_arg != $nickname) { - $args = array('nickname' => $nickname); - common_redirect(common_local_url('leavegroup', $args), 301); - return false; - } + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } - if (!$nickname) { - $this->clientError(_('No nickname.'), 404); + $this->group = User_group::staticGet('id', $local->group_id); + } else { + $this->clientError(_('No nickname or ID.'), 404); return false; } - $this->group = User_group::staticGet('nickname', $nickname); - if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; |