use wcf\system\exception\UserInputException;
use wcf\system\flood\FloodControl;
use wcf\system\html\input\HtmlInputProcessor;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\moderation\queue\ModerationQueueActivationManager;
use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\reaction\ReactionHandler;
'com.woltlab.wcf.comment.comment',
$commentIDs
);
+
+ MessageEmbeddedObjectManager::getInstance()->removeObjects(
+ 'com.woltlab.wcf.comment',
+ $commentIDs
+ );
}
return parent::delete();
);
}
+ $htmlInputProcessor->setObjectID($this->createdComment->getObjectID());
+ if (MessageEmbeddedObjectManager::getInstance()->registerObjects($htmlInputProcessor)) {
+ (new CommentEditor($this->createdComment))->update([
+ 'hasEmbeddedObjects' => 1,
+ ]);
+ $this->createdComment = new Comment($this->createdComment->getObjectID());
+ }
+
FloodControl::getInstance()->registerContent('com.woltlab.wcf.comment');
if (!$this->createdComment->userID) {
$this->validateCaptcha();
}
- $this->validateMessage();
+ $this->validateMessage(true);
// validate comment id
$this->validateCommentID();
]);
$this->createdResponse->setComment($this->comment);
+ $htmlInputProcessor->setObjectID($this->createdResponse->getObjectID());
+ if (MessageEmbeddedObjectManager::getInstance()->registerObjects($htmlInputProcessor)) {
+ (new CommentResponseEditor($this->createdResponse))->update([
+ 'hasEmbeddedObjects' => 1,
+ ]);
+ $this->createdResponse = new CommentResponse($this->createdResponse->getObjectID());
+ }
+
// update response data
$unfilteredResponseIDs = $this->comment->getUnfilteredResponseIDs();
if (\count($unfilteredResponseIDs) < 5) {
/** @var HtmlInputProcessor $htmlInputProcessor */
$htmlInputProcessor = $this->parameters['htmlInputProcessor'];
+ $data = [
+ 'message' => $htmlInputProcessor->getHtml(),
+ ];
+
+ $htmlInputProcessor->setObjectID($this->comment->getObjectID());
+ $hasEmbeddedObjects = MessageEmbeddedObjectManager::getInstance()->registerObjects($htmlInputProcessor);
+ if ($this->comment->hasEmbeddedObjects != $hasEmbeddedObjects) {
+ $data['hasEmbeddedObjects'] = $this->comment->hasEmbeddedObjects ? 0 : 1;
+ }
+
$action = new self([$this->comment], 'update', [
- 'data' => [
- 'message' => $htmlInputProcessor->getHtml(),
- ],
+ 'data' => $data,
]);
$action->executeAction();
$comment->setIsDeletable($this->commentProcessor->canDeleteComment($comment->getDecoratedObject()));
$comment->setIsEditable($this->commentProcessor->canEditComment($comment->getDecoratedObject()));
+ if ($comment->hasEmbeddedObjects) {
+ MessageEmbeddedObjectManager::getInstance()->loadObjects(
+ 'com.woltlab.wcf.comment',
+ [$comment->getObjectID()]
+ );
+ }
+ if ($response && $response->hasEmbeddedObjects) {
+ MessageEmbeddedObjectManager::getInstance()->loadObjects(
+ 'com.woltlab.wcf.comment.response',
+ [$response->getObjectID()]
+ );
+ }
+
if ($response !== null) {
// check if response is not visible
/** @var CommentResponse $visibleResponse */
$response->setIsDeletable($this->commentProcessor->canDeleteResponse($response->getDecoratedObject()));
$response->setIsEditable($this->commentProcessor->canEditResponse($response->getDecoratedObject()));
+ if ($response->hasEmbeddedObjects) {
+ MessageEmbeddedObjectManager::getInstance()->loadObjects(
+ 'com.woltlab.wcf.comment.response',
+ [$response->getObjectID()]
+ );
+ }
+
// render response
WCF::getTPL()->assign([
'responseList' => [$response],
*
* @throws UserInputException
*/
- protected function validateMessage()
+ protected function validateMessage(bool $isResponse = false)
{
$this->readString('message', false, 'data');
$this->parameters['data']['message'] = MessageUtil::stripCrap($this->parameters['data']['message']);
CommentHandler::enforceCensorship($this->parameters['data']['message']);
$this->setDisallowedBBCodes();
- $htmlInputProcessor = $this->getHtmlInputProcessor(
- $this->parameters['data']['message'],
- ($this->comment !== null ? $this->comment->commentID : 0)
- );
+
+ $htmlInputProcessor = new HtmlInputProcessor();
+ if ($isResponse) {
+ $htmlInputProcessor->process(
+ $this->parameters['data']['message'],
+ 'com.woltlab.wcf.comment.response'
+ );
+ } else {
+ $htmlInputProcessor->process(
+ $this->parameters['data']['message'],
+ 'com.woltlab.wcf.comment',
+ $this->comment !== null ? $this->comment->getObjectID() : 0
+ );
+ }
// search for disallowed bbcodes
$disallowedBBCodes = $htmlInputProcessor->validate();
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\html\input\HtmlInputProcessor;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\reaction\ReactionHandler;
use wcf\system\user\activity\event\UserActivityEventHandler;
'com.woltlab.wcf.comment.response',
$deletedResponseIDs
);
+
+ MessageEmbeddedObjectManager::getInstance()->removeObjects(
+ 'com.woltlab.wcf.comment',
+ $deletedResponseIDs
+ );
}
return $count;
/** @var HtmlInputProcessor $htmlInputProcessor */
$htmlInputProcessor = $this->parameters['htmlInputProcessor'];
- $action = new self([$this->response], 'update', [
+ $data = [
+ 'message' => $htmlInputProcessor->getHtml(),
+ ];
+
+ $htmlInputProcessor->setObjectID($this->comment->getObjectID());
+ $hasEmbeddedObjects = MessageEmbeddedObjectManager::getInstance()->registerObjects($htmlInputProcessor);
+ if ($this->response->hasEmbeddedObjects != $hasEmbeddedObjects) {
+ $data['hasEmbeddedObjects'] = $this->response->hasEmbeddedObjects ? 0 : 1;
+ }
+
+ (new self([$this->response], 'update', [
'data' => [
'message' => $htmlInputProcessor->getHtml(),
],
- ]);
- $action->executeAction();
+ ]))->executeAction();
+
+ $response = new CommentResponse($this->response->getObjectID());
+
+ if ($response->hasEmbeddedObjects) {
+ MessageEmbeddedObjectManager::getInstance()->loadObjects(
+ 'com.woltlab.wcf.comment.response',
+ [$response->getObjectID()]
+ );
+ }
return [
'actionName' => 'save',
- 'message' => (new CommentResponse($this->response->responseID))->getFormattedMessage(),
+ 'message' => $response->getFormattedMessage(),
];
}
$this->setDisallowedBBCodes();
$htmlInputProcessor = $this->getHtmlInputProcessor(
$this->parameters['data']['message'],
- ($this->comment !== null ? $this->comment->commentID : 0)
+ $this->response !== null ? $this->response->getObjectID() : 0
);
// search for disallowed bbcodes
}
$this->htmlInputProcessor = new HtmlInputProcessor();
- $this->htmlInputProcessor->process($message, 'com.woltlab.wcf.comment', $objectID);
+ $this->htmlInputProcessor->process($message, 'com.woltlab.wcf.comment.response', $objectID);
return $this->htmlInputProcessor;
}