Set bbcode permissions for message rebuilding
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jan 2018 15:19:24 +0000 (16:19 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jan 2018 15:19:24 +0000 (16:19 +0100)
See #2524

wcfsetup/install/files/lib/system/worker/CommentRebuildDataWorker.class.php
wcfsetup/install/files/lib/system/worker/CommentResponseRebuildDataWorker.class.php
wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php

index 7d10a017d008b4e8cceb03e3fd55d8e0337b6846..9e095ec362e3a95e64897deee3320b143f4f9997 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system\worker;
 use wcf\data\comment\Comment;
 use wcf\data\comment\CommentEditor;
 use wcf\data\comment\CommentList;
+use wcf\system\bbcode\BBCodeHandler;
 use wcf\system\html\input\HtmlInputProcessor;
 use wcf\system\WCF;
 
@@ -62,6 +63,13 @@ class CommentRebuildDataWorker extends AbstractRebuildDataWorker {
                        return;
                }
                
+               // retrieve permissions
+               $userIDs = [];
+               foreach ($this->objectList as $comment) {
+                       $userIDs[] = $comment->userID;
+               }
+               $userPermissions = $this->getBulkUserPermissions($userIDs, ['user.comment.disallowedBBCodes']);
+               
                WCF::getDB()->beginTransaction();
                /** @var Comment $comment */
                foreach ($this->objectList as $comment) {
@@ -70,6 +78,8 @@ class CommentRebuildDataWorker extends AbstractRebuildDataWorker {
                        $commentEditor->updateResponseIDs();
                        $commentEditor->updateUnfilteredResponseIDs();
                        
+                       BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', $this->getBulkUserPermissionValue($userPermissions, $comment->userID, 'user.comment.disallowedBBCodes')));
+                       
                        // update message
                        if (!$comment->enableHtml) {
                                $this->getHtmlInputProcessor()->process($comment->message, 'com.woltlab.wcf.comment', $comment->commentID, true);
index 8080dbfcec83ae5c0659c99029b2c2f949f2ea21..396342ad0de1775645a8a82dbff88888f1ec7aac 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system\worker;
 use wcf\data\comment\response\CommentResponse;
 use wcf\data\comment\response\CommentResponseEditor;
 use wcf\data\comment\response\CommentResponseList;
+use wcf\system\bbcode\BBCodeHandler;
 use wcf\system\html\input\HtmlInputProcessor;
 use wcf\system\WCF;
 
@@ -62,11 +63,20 @@ class CommentResponseRebuildDataWorker extends AbstractRebuildDataWorker {
                        return;
                }
                
+               // retrieve permissions
+               $userIDs = [];
+               foreach ($this->objectList as $response) {
+                       $userIDs[] = $response->userID;
+               }
+               $userPermissions = $this->getBulkUserPermissions($userIDs, ['user.comment.disallowedBBCodes']);
+               
                WCF::getDB()->beginTransaction();
                /** @var CommentResponse $response */
                foreach ($this->objectList as $response) {
                        $responseEditor = new CommentResponseEditor($response);
                        
+                       BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', $this->getBulkUserPermissionValue($userPermissions, $response->userID, 'user.comment.disallowedBBCodes')));
+                       
                        // update message
                        if (!$response->enableHtml) {
                                $this->getHtmlInputProcessor()->process($response->message, 'com.woltlab.wcf.comment.response', $response->responseID, true);
index 55fdc31ad4a1eb696c8063e93205d2337d04c98a..9ef2855ebbf73212367257d33cc65fab4bae461f 100644 (file)
@@ -8,6 +8,7 @@ use wcf\data\user\User;
 use wcf\data\user\UserEditor;
 use wcf\data\user\UserList;
 use wcf\data\user\UserProfileAction;
+use wcf\system\bbcode\BBCodeHandler;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
 use wcf\system\html\input\HtmlInputProcessor;
@@ -110,10 +111,19 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker {
                                WHERE   userID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        
+                       // retrieve permissions
+                       $userIDs = [];
+                       foreach ($users as $user) {
+                               $userIDs[] = $user->userID;
+                       }
+                       $userPermissions = $this->getBulkUserPermissions($userIDs, ['user.message.disallowedBBCodes', 'user.signature.disallowedBBCodes']);
+                       
                        $htmlInputProcessor = new HtmlInputProcessor();
                        WCF::getDB()->beginTransaction();
                        /** @var UserEditor $user */
                        foreach ($users as $user) {
+                               BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', $this->getBulkUserPermissionValue($userPermissions, $user->userID, 'user.signature.disallowedBBCodes')));
+                               
                                if (!$user->signatureEnableHtml) {
                                        $htmlInputProcessor->process($user->signature, 'com.woltlab.wcf.user.signature', $user->userID, true);
                                        
@@ -128,6 +138,8 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker {
                                }
                                
                                if ($user->aboutMe) {
+                                       BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', $this->getBulkUserPermissionValue($userPermissions, $user->userID, 'user.message.disallowedBBCodes')));
+                                       
                                        if (!$user->signatureEnableHtml) {
                                                $htmlInputProcessor->process($user->aboutMe, 'com.woltlab.wcf.user.aboutMe', $user->userID, true);
                                        }