X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fjoingroup.php;h=bb7b835915bfc563dd7a7128f8f6befc998c3f11;hb=0dbdcf2936a00282114f1368ead2f5edebc6ae61;hp=7beaf4f64ac22abb393d69a9f7b42359bcfe5056;hpb=47f31bce47b182aa55c02c7872d7e473d3ab10f2;p=quix0rs-gnu-social.git diff --git a/actions/joingroup.php b/actions/joingroup.php index 7beaf4f64a..bb7b835915 100644 --- a/actions/joingroup.php +++ b/actions/joingroup.php @@ -129,15 +129,13 @@ class JoingroupAction extends Action $cur = common_current_user(); try { - if (Event::handle('StartJoinGroup', array($this->group, $cur))) { - Group_member::join($this->group->id, $cur->id); - Event::handle('EndJoinGroup', array($this->group, $cur)); - } + $result = $cur->joinGroup($this->group); } catch (Exception $e) { // TRANS: Server error displayed when joining a group failed in the database. // TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed. $this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'), $cur->nickname, $this->group->nickname)); + return; } if ($this->boolean('ajax')) { @@ -149,8 +147,17 @@ class JoingroupAction extends Action $this->group->nickname)); $this->elementEnd('head'); $this->elementStart('body'); - $lf = new LeaveForm($this, $this->group); - $lf->show(); + + if ($result instanceof Group_member) { + $form = new LeaveForm($this, $this->group); + } else if ($result instanceof Group_join_queue) { + $form = new CancelGroupForm($this, $this->group); + } else { + // wtf? + // TRANS: Exception thrown when there is an unknown error joining a group. + throw new Exception(_("Unknown error joining group.")); + } + $form->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else {