]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/joingroup.php
Better type check, better URL
[quix0rs-gnu-social.git] / actions / joingroup.php
index 8675dbaed3ddcd2f3cd74e493c55bf3976f55a08..fa5968a2c4c0673f6a244f336dcf540b27119556 100644 (file)
@@ -129,8 +129,12 @@ class JoingroupAction extends Action
         $cur = common_current_user();
 
         try {
-            $cur->joinGroup($this->group);
+            $result = $cur->joinGroup($this->group);
         } catch (Exception $e) {
+               common_log(LOG_ERR, sprintf("Couldn't join user %s to group %s: '%s'",
+                                                                       $cur->nickname,
+                                                                       $this->group->nickname,
+                                                                       $e->getMessage()));
             // 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.'),
@@ -147,8 +151,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 {