]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Ban certain users from posting by nickname and/or ID
authorZach Copley <zach@controlyourself.ca>
Wed, 10 Dec 2008 19:13:37 +0000 (14:13 -0500)
committerZach Copley <zach@controlyourself.ca>
Wed, 10 Dec 2008 19:13:37 +0000 (14:13 -0500)
darcs-hash:20081210191337-7b5ce-f9a083596b3f5627405c9e233c1994d8338f5731.gz

classes/Notice.php
config.php.sample
lib/common.php

index 77e0948dc28d6421c421454dd5801a74ae70fcc9..031ccd58386a3a115038121fc6f6e461946fe93f 100644 (file)
@@ -92,7 +92,10 @@ class Notice extends Memcached_DataObject
        }
 
        static function saveNew($profile_id, $content, $source=NULL, $is_local=1, $reply_to=NULL, $uri=NULL) {
-        if (!Profile::staticGet($profile_id)) {
+
+               $profile = Profile::staticGet($profile_id);
+
+        if (!$profile) {
             common_log(LOG_ERR, 'Problem saving notice. Unknown user.');
             return _('Problem saving notice. Unknown user.');
         }
@@ -102,6 +105,13 @@ class Notice extends Memcached_DataObject
                        return _('Too many notices too fast; take a breather and post again in a few minutes.');
         }
 
+               $banned = common_config('profile', 'banned');
+
+               if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) {
+                       common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id).");
+            return _('You are banned from posting notices on this site.');
+               }
+
                $notice = new Notice();
                $notice->profile_id = $profile_id;
 
index 1cfbffd8dda36421acbd2b11f69cc0952857809f..3a13072a476833eb1244e7d8e47bc38c29a33f14 100644 (file)
@@ -129,4 +129,8 @@ $config['sphinx']['port'] = 3312;
 
 #$config['throttle']['enabled'] = true;
 #$config['throttle']['count'] = 100;
-#$config['throttle']['timespan'] = 3600;
\ No newline at end of file
+#$config['throttle']['timespan'] = 3600;
+
+# List of users banned from posting (nicknames and/or IDs)
+#$config['profile']['banned'][] = 'hacker';
+#$config['profile']['banned'][] = 12345;
index 8543b09c7bf23368d1f217443d713eead2721453..141887ceb38884c0e498c49106be47c0caaf6663 100644 (file)
@@ -85,6 +85,8 @@ $config =
                'nickname' =>
                array('blacklist' => array(),
                          'featured' => array()),
+               'profile' =>
+               array('banned' => array()),
                'avatar' =>
                array('server' => NULL),
                'public' =>