summaryrefslogtreecommitdiff
path: root/actions/joingroup.php
diff options
context:
space:
mode:
Diffstat (limited to 'actions/joingroup.php')
-rw-r--r--actions/joingroup.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/actions/joingroup.php b/actions/joingroup.php
index 235e5ab4c..f87e5dae2 100644
--- a/actions/joingroup.php
+++ b/actions/joingroup.php
@@ -62,23 +62,33 @@ class JoingroupAction 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('joingroup', $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;