Permalink
Browse files

Set bbcode permissions for message rebuilding

See #2524
  • Loading branch information...
dtdesign committed Jan 29, 2018
1 parent a785ac2 commit 7e058783da1378dda5393a9bb4df9cfe94e5b394
@@ -3,6 +3,7 @@
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 @@ public function execute() {
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 @@ public function execute() {
$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);
@@ -3,6 +3,7 @@
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 @@ public function execute() {
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);
@@ -8,6 +8,7 @@
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 @@ public function execute() {
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 @@ public function execute() {
}
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);
}

0 comments on commit 7e05878

Please sign in to comment.