Added censorship-function
authorMarcel Werk <burntime@woltlab.com>
Sun, 3 Mar 2013 20:05:12 +0000 (21:05 +0100)
committerMarcel Werk <burntime@woltlab.com>
Sun, 3 Mar 2013 20:05:12 +0000 (21:05 +0100)
files/lib/data/conversation/message/ConversationMessageAction.class.php
templates/conversationAdd.tpl

index 2c2ff526512ab68802d9803c99b2e830ecd11c1c..740e80c1938ca81ddb6b095150f4632384eca367 100644 (file)
@@ -9,6 +9,7 @@ use wcf\data\IMessageInlineEditorAction;
 use wcf\data\IMessageQuoteAction;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
+use wcf\system\message\censorship\Censorship;
 use wcf\system\message\quote\MessageQuoteManager;
 use wcf\system\message\QuickReplyManager;
 use wcf\system\request\LinkHandler;
@@ -350,7 +351,15 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
        /**
         * @see wcf\data\IMessageQuickReplyAction::validateMessage()
         */
-       public function validateMessage(DatabaseObject $container, $message) { }
+       public function validateMessage(DatabaseObject $container, $message) {
+               // search for censored words
+               if (ENABLE_CENSORSHIP) {
+                       $result = Censorship::getInstance()->test($message);
+                       if ($result) {
+                               throw new UserInputException('message', 'wcf.message.error.censoredWordsFound', array('censoredWords' => $result));
+                       }
+               }
+       }
        
        /**
         * @see wcf\data\IMessageQuickReply::getPageNo()
index 72835c5b949fabe2f40b25ccc652f8d43b7644fe..f5aadbc86a6f92711a369436358744f15a7f67e2 100644 (file)
@@ -45,6 +45,8 @@
                                                <small class="innerError">
                                                        {if $errorType == 'empty'}
                                                                {lang}wcf.global.form.error.empty{/lang}
+                                                       {elseif $errorType == 'censoredWordsFound'}
+                                                               {lang}wcf.message.error.censoredWordsFound{/lang}
                                                        {else}
                                                                {lang}wcf.conversation.subject.error.{@$errorType}{/lang}
                                                        {/if}
                                                                {lang}wcf.global.form.error.empty{/lang}
                                                        {elseif $errorType == 'tooLong'}
                                                                {lang}wcf.message.error.tooLong{/lang}
+                                                       {elseif $errorType == 'censoredWordsFound'}
+                                                               {lang}wcf.message.error.censoredWordsFound{/lang}
                                                        {else}
                                                                {lang}wcf.conversation.message.error.{@$errorType}{/lang}
                                                        {/if}