]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/leavegroup.php
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
[quix0rs-gnu-social.git] / actions / leavegroup.php
index 587208b36a1768e4268296a8f47db96477c94c58..1d85aa3d521f2e68a1e84760e017a25693e8f017 100644 (file)
@@ -57,12 +57,12 @@ class LeavegroupAction extends Action
         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;
         }
 
@@ -73,29 +73,35 @@ class LeavegroupAction extends Action
 
         if ($nickname_arg != $nickname) {
             $args = array('nickname' => $nickname);
-            common_redirect(common_local_url('editgroup', $args), 301);
+            common_redirect(common_local_url('leavegroup', $args), 301);
             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;
     }
 
@@ -150,4 +156,4 @@ class LeavegroupAction extends Action
                                                                    $this->group->nickname)));
         }
     }
-}
\ No newline at end of file
+}