Adds allowed BBCode consideration and adds missing error messages in templates
authorMatthias Schmidt <gravatronics@live.com>
Sun, 10 Mar 2013 14:46:48 +0000 (15:46 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 10 Mar 2013 14:46:48 +0000 (15:46 +0100)
files/lib/data/conversation/message/ConversationMessageAction.class.php
templates/conversationAdd.tpl
templates/conversationMessageAdd.tpl
templates/conversationMessageEdit.tpl

index 2f05419a8da5393a3247b1e11e2b5dd9d8316196..2e9ccb1a2cd480abd3202f86f6cbd0f2f468a0e6 100644 (file)
@@ -7,6 +7,7 @@ use wcf\data\DatabaseObject;
 use wcf\data\IExtendedMessageQuickReplyAction;
 use wcf\data\IMessageInlineEditorAction;
 use wcf\data\IMessageQuoteAction;
+use wcf\system\bbcode\BBCodeParser;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
 use wcf\system\message\censorship\Censorship;
@@ -369,6 +370,12 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
                        throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.tooLong', array('maxTextLength' => WCF::getSession()->getPermission('user.conversation.maxLength'))));
                }
                
+               // search for disallowed bbcodes
+               $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($message, explode(',', WCF::getSession()->getPermission('user.message.allowedBBCodes')));
+               if (!empty($disallowedBBCodes)) {
+                       throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array('disallowedBBCodes' => $disallowedBBCodes)));
+               }
+               
                // search for censored words
                if (ENABLE_CENSORSHIP) {
                        $result = Censorship::getInstance()->test($message);
index 1f1917d1e2eb632a39e1429dca25dda2029fca41..5fd0e79fcfe50eefb2a31a4ae3b06a93384c0402 100644 (file)
                                                                {lang}wcf.message.error.tooLong{/lang}
                                                        {elseif $errorType == 'censoredWordsFound'}
                                                                {lang}wcf.message.error.censoredWordsFound{/lang}
+                                                       {elseif $errorType == 'disallowedBBCodes'}
+                                                               {lang}wcf.message.error.disallowedBBCodes{/lang}
                                                        {else}
                                                                {lang}wcf.conversation.message.error.{@$errorType}{/lang}
                                                        {/if}
index af3faebee04125d100c7e421cca222c8a208d6a1..d0e3a078fa06a28527c83cf2677673d7a6b9c105 100644 (file)
                                                                {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}
+                                                       {elseif $errorType == 'disallowedBBCodes'}
+                                                               {lang}wcf.message.error.disallowedBBCodes{/lang}
                                                        {else}
                                                                {lang}wcf.conversation.message.error.{@$errorType}{/lang}
                                                        {/if}
index 6b9ca63b8e5e9e76aa9610b70f78d7c3279fbad8..b0889caec6dfc4d3ea8a6bf382df8050a407ee1d 100644 (file)
                                                                {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}
+                                                       {elseif $errorType == 'disallowedBBCodes'}
+                                                               {lang}wcf.message.error.disallowedBBCodes{/lang}
                                                        {else}
                                                                {lang}wcf.conversation.message.error.{@$errorType}{/lang}
                                                        {/if}