]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'master' into 0.9.x
authorBrion Vibber <brion@pobox.com>
Tue, 28 Dec 2010 19:37:38 +0000 (11:37 -0800)
committerBrion Vibber <brion@pobox.com>
Tue, 28 Dec 2010 19:37:38 +0000 (11:37 -0800)
actions/newgroup.php
classes/Profile.php
classes/User_group.php
lib/right.php

index 95af6415e507b303272226511e737c0900dfb283..42d488e54ebfef3a09bfd7b3ce15a96a01cf2807 100644 (file)
@@ -66,6 +66,13 @@ class NewgroupAction extends Action
             return false;
         }
 
+        $user = common_current_user();
+        $profile = $user->getProfile();
+        if (!$profile->hasRight(Right::CREATEGROUP)) {
+            // TRANS: Client exception thrown when a user tries to create a group while banned.
+            throw new ClientException(_('You are not allowed to create groups on this site.'), 403);
+        }
+
         return true;
     }
 
index 972351a75b1a9adefe97b755cff8d21b217f6f84..adad0c6157d5d25c7574e70bebce712417257860 100644 (file)
@@ -850,6 +850,7 @@ class Profile extends Memcached_DataObject
             case Right::NEWNOTICE:
             case Right::NEWMESSAGE:
             case Right::SUBSCRIBE:
+            case Right::CREATEGROUP:
                 $result = !$this->isSilenced();
                 break;
             case Right::PUBLICNOTICE:
index cffc7864586d7a542764fcb1ec3d621725ca6ee1..68f61cb7f48a104b43aae7b84fcf5ba4503d7ca3 100644 (file)
@@ -476,6 +476,16 @@ class User_group extends Memcached_DataObject
     }
 
     static function register($fields) {
+        if (!empty($fields['userid'])) {
+            $profile = Profile::staticGet('id', $fields['userid']);
+            if ($profile && !$profile->hasRight(Right::CREATEGROUP)) {
+                common_log(LOG_WARNING, "Attempted group creation from banned user: " . $profile->nickname);
+
+                // TRANS: Client exception thrown when a user tries to create a group while banned.
+                throw new ClientException(_('You are not allowed to create groups on this site.'), 403);
+            }
+        }
+
         // MAGICALLY put fields into current scope
 
         extract($fields);
index 5bf9c41161adf86972068d7ab8196975b9dac6a8..d144b21ae98469595f24c84ffc8dff47ae9e66f3 100644 (file)
@@ -65,5 +65,6 @@ class Right
     const RESTOREACCOUNT     = 'restoreaccount';
     const DELETEACCOUNT      = 'deleteaccount';
     const MOVEACCOUNT        = 'moveaccount';
+    const CREATEGROUP        = 'creategroup';
 }