Added user ban function
authorMarcel Werk <burntime@woltlab.com>
Mon, 8 Apr 2013 23:30:25 +0000 (01:30 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 8 Apr 2013 23:30:25 +0000 (01:30 +0200)
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index dc5feddc673ae087b9f5f6295e7720d7227fc6e8..f075bcd885983dbe442052314fd940c08bb0807a 100644 (file)
@@ -8,7 +8,9 @@ use wcf\data\package\PackageEditor;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\cache\builder\CoreObjectCacheBuilder;
 use wcf\system\cronjob\CronjobScheduler;
+use wcf\system\exception\AJAXException;
 use wcf\system\exception\IPrintableException;
+use wcf\system\exception\NamedUserException;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\SystemException;
 use wcf\system\language\LanguageFactory;
@@ -369,6 +371,16 @@ class WCF {
                                throw new PermissionDeniedException();
                        }
                }
+               
+               // handle banned users
+               if (WCF::getUser()->userID && WCF::getUser()->banned) {
+                       if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) {
+                               throw new AJAXException(WCF::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'), AJAXException::INSUFFICIENT_PERMISSIONS);
+                       }
+                       else {
+                               throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'));
+                       }
+               }
        }
        
        /**
index 2e973ea22b6be913a4188feaaf0b7165b23401ec..9780c340cf9baa768e8e54a5bed7692fda2f0c0d 100644 (file)
@@ -51,7 +51,7 @@ class RequestHandler extends SingletonFactory {
                // handle offline mode
                if (!$isACPRequest && defined('OFFLINE') && OFFLINE) {
                        if (!WCF::getSession()->getPermission('admin.general.canViewPageDuringOfflineMode') && !$this->activeRequest->isAvailableDuringOfflineMode()) {
-                               if (isset($_SERVER['X-Requested-With']) && ($_SERVER['X-Requested-With'] == 'XMLHttpRequest')) {
+                               if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) {
                                        throw new AJAXException(WCF::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                                }
                                else {
index 8cf5d9126242320cfff96715f6392ee67244cb88..b90e8a00a48d90be1b50e59983efac59e693f8f8 100644 (file)
                <item name="wcf.user.option.error.tooLong"><![CDATA[Der eingegebene Text ist zu lang.]]></item>
                <item name="wcf.user.option.error.tooShort"><![CDATA[Der eingegebene Text ist zu kurz.]]></item>
                <item name="wcf.user.option.error.validationFailed"><![CDATA[Sie haben einen ungültigen Inhalt eingegeben.]]></item>
+               <item name="wcf.user.error.isBanned"><![CDATA[Ihr Benutzeraccount wurde gesperrt{if $__wcf->user->banReason}: {@$__wcf->user->banReason|htmlspecialchars|nl2br}{else}.{/if}]]></item>
        </category>
 </language>
index da2a3ce378fabde3a0adc8666b967e9c3c03051d..9b0167ca96555861a1b59e8ef4532b354d5c13a4 100644 (file)
                <item name="wcf.user.option.error.tooLong"><![CDATA[Entered text is too long.]]></item>
                <item name="wcf.user.option.error.tooShort"><![CDATA[Entered text is too short.]]></item>
                <item name="wcf.user.option.error.validationFailed"><![CDATA[Entered text is invalid.]]></item>
+               <item name="wcf.user.error.isBanned"><![CDATA[Your user account has been banned{if $__wcf->user->banReason}: {@$__wcf->user->banReason|htmlspecialchars|nl2br}{else}.{/if}]]></item>
        </category>
 </language>
index 56c35bbd9a2ddaf1eaec5cd47efc828c84acf534..82e592e516382acca4b400ae6bc73779248b666b 100644 (file)
@@ -620,6 +620,8 @@ CREATE TABLE wcf1_user (
        languageID INT(10) NOT NULL DEFAULT 0,
        registrationDate INT(10) NOT NULL DEFAULT 0,
        styleID INT(10) NOT NULL DEFAULT 0,
+       banned TINYINT(1) NOT NULL DEFAULT 0,
+       banReason MEDIUMTEXT NULL,
        
        KEY username (username),
        KEY registrationDate (registrationDate),