return false;
}
- $this->group = User_group::staticGet('nickname', $nickname);
+ $groupid = $this->trimmed('groupid');
+ if ($groupid) {
+ $this->group = User_group::staticGet('id', $groupid);
+ } else {
+ $this->group = User_group::staticGet('nickname', $nickname);
+ }
if (!$this->group) {
$this->clientError(_('No such group'), 404);
$cur = common_current_user();
- if (!$cur->isAdmin($group)) {
+ if (!$cur->isAdmin($this->group)) {
$this->clientError(_('You must be an admin to edit the group'), 403);
return false;
}
function trySave()
{
+ $cur = common_current_user();
+ if (!$cur->isAdmin($this->group)) {
+ $this->clientError(_('You must be an admin to edit the group'), 403);
+ return;
+ }
+
+
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
$group != false &&
$group->id != $this->group->id);
}
-}
\ No newline at end of file
+}
+
parent::prepare($args);
if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
+ $this->serverError(_('Inboxes must be enabled for groups to work.'));
return false;
}
if (!common_logged_in()) {
- $this->clientError(_('You must be logged in to join a group.'));
+ $this->clientError(_('You must be logged in to leave a group.'));
return false;
}
}
if (!$nickname) {
- $this->clientError(_('No nickname'), 404);
+ $this->clientError(_('No nickname.'), 404);
return false;
}
$this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) {
- $this->clientError(_('No such group'), 404);
+ $this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
- if (!$cur->isMember($group)) {
- $this->clientError(_('You are not a member of that group'), 403);
+ if (!$cur->isMember($this->group)) {
+ $this->clientError(_('You are not a member of that group.'), 403);
return false;
}
+ if ($cur->isAdmin($this->group)) {
+ $this->clientError(_('You may not leave a group while you are its administrator.'), 403);
+ return false;
+
+ }
+
return true;
}
$this->group->nickname)));
}
}
-}
\ No newline at end of file
+}
$group = User_group::staticGet('nickname', $nickname);
return (!is_null($group) && $group != false);
}
-}
\ No newline at end of file
+}
+
$cur = common_current_user();
if ($cur) {
if ($cur->isMember($this->group)) {
- $lf = new LeaveForm($this, $this->group);
- $lf->show();
+ if (!$cur->isAdmin($this->group)) {
+ $lf = new LeaveForm($this, $this->group);
+ $lf->show();
+ }
} else {
$jf = new JoinForm($this, $this->group);
$jf->show();
{
$this->out->elementStart('ul', 'form_data');
$this->out->elementStart('li');
+ $this->out->hidden('groupid', $this->group->id);
$this->out->input('nickname', _('Nickname'),
($this->out->arg('nickname')) ? $this->out->arg('nickname') : $this->group->nickname,
_('1-64 lowercase letters or numbers, no punctuation or spaces'));