use wcf\data\comment\response\CommentResponse;
use wcf\data\comment\response\CommentResponseAction;
use wcf\data\comment\response\CommentResponseEditor;
-use wcf\data\comment\response\CommentResponseList;
use wcf\data\comment\response\StructuredCommentResponse;
use wcf\data\IMessageInlineEditorAction;
use wcf\data\object\type\ObjectType;
use wcf\system\html\upcast\HtmlUpcastProcessor;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\moderation\queue\ModerationQueueActivationManager;
-use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\reaction\ReactionHandler;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
/**
* captcha object type used for comments
* @var ObjectType
+ * @deprecated 6.1
*/
public $captchaObjectType;
/**
* comment object
* @var Comment
+ * @deprecated 6.1
*/
protected $comment;
/**
* comment processor
* @var ICommentManager
+ * @deprecated 6.1
*/
protected $commentProcessor;
/**
* @var HtmlInputProcessor
+ * @deprecated 6.1
*/
protected $htmlInputProcessor;
/**
* response object
* @var CommentResponse
+ * @deprecated 6.1
*/
protected $response;
/**
* comment object created by addComment()
* @var Comment
+ * @deprecated 6.1
*/
public $createdComment;
/**
* response object created by addResponse()
* @var CommentResponse
+ * @deprecated 6.1
*/
public $createdResponse;
/**
* errors occurring through the validation of addComment or addResponse
* @var array
+ * @deprecated 6.1
*/
public $validationErrors = [];
- /**
- * @inheritDoc
- */
- public function validateDelete()
- {
- $this->readObjects();
-
- if ($this->getObjects() === []) {
- throw new UserInputException('objectIDs');
- }
-
- foreach ($this->getObjects() as $comment) {
- $objectType = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID);
- $processor = $objectType->getProcessor();
- if (!$processor->canDeleteComment($comment->getDecoratedObject())) {
- throw new PermissionDeniedException();
- }
- }
- }
-
- /**
- * @inheritDoc
- */
- public function delete()
- {
- if (empty($this->objects)) {
- $this->readObjects();
- }
-
- // update counters
- /** @var ICommentManager[] $processors */
- $processors = [];
- $groupCommentIDs = $commentIDs = [];
- foreach ($this->getObjects() as $comment) {
- if (!isset($processors[$comment->objectTypeID])) {
- $objectType = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID);
- $processors[$comment->objectTypeID] = $objectType->getProcessor();
-
- $groupCommentIDs[$comment->objectTypeID] = [];
- }
-
- if (!$comment->isDisabled) {
- $processors[$comment->objectTypeID]->updateCounter($comment->objectID, -1 * ($comment->responses + 1));
- }
-
- $groupCommentIDs[$comment->objectTypeID][] = $comment->commentID;
- $commentIDs[] = $comment->commentID;
- }
-
- if (!empty($groupCommentIDs)) {
- $likeObjectIDs = [];
- $notificationObjectTypes = [];
- foreach ($groupCommentIDs as $objectTypeID => $objectIDs) {
- // remove activity events
- $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
- if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType . '.recentActivityEvent')) {
- UserActivityEventHandler::getInstance()->removeEvents(
- $objectType->objectType . '.recentActivityEvent',
- $objectIDs
- );
- }
-
- $likeObjectIDs = \array_merge($likeObjectIDs, $objectIDs);
-
- // delete notifications
- $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
- if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.notification')) {
- UserNotificationHandler::getInstance()->removeNotifications(
- $objectType->objectType . '.notification',
- $objectIDs
- );
- }
-
- if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.like.notification')) {
- $notificationObjectTypes[] = $objectType->objectType . '.like.notification';
- }
- }
-
- // remove likes
- ReactionHandler::getInstance()->removeReactions(
- 'com.woltlab.wcf.comment',
- $likeObjectIDs,
- $notificationObjectTypes
- );
- }
-
- if (!empty($commentIDs)) {
- // delete responses
- $commentResponseList = new CommentResponseList();
- $commentResponseList->getConditionBuilder()->add('comment_response.commentID IN (?)', [$commentIDs]);
- $commentResponseList->readObjectIDs();
- if (\count($commentResponseList->getObjectIDs())) {
- $action = new CommentResponseAction($commentResponseList->getObjectIDs(), 'delete', [
- 'ignoreCounters' => true,
- ]);
- $action->executeAction();
- }
-
- ModerationQueueManager::getInstance()->removeQueues(
- 'com.woltlab.wcf.comment.comment',
- $commentIDs
- );
-
- MessageEmbeddedObjectManager::getInstance()->removeObjects(
- 'com.woltlab.wcf.comment',
- $commentIDs
- );
- }
-
- return parent::delete();
- }
-
/**
* Validates parameters to load comments.
*
* @throws PermissionDeniedException
+ * @deprecated 6.1
*/
public function validateLoadComments()
{
* Returns parsed comments.
*
* @return array
+ * @deprecated 6.1
*/
public function loadComments()
{
*
* @throws PermissionDeniedException
* @since 3.1
+ * @deprecated 6.1
*/
public function validateLoadComment()
{
*
* @return string[]
* @since 3.1
+ * @deprecated 6.1
*/
public function loadComment()
{
* Validates the `loadResponse` action.
*
* @since 3.1
+ * @deprecated 6.1
*/
public function validateLoadResponse()
{
*
* @return string[]
* @since 3.1
+ * @deprecated 6.1
*/
public function loadResponse()
{
* Validates parameters to add a comment.
*
* @throws PermissionDeniedException
+ * @deprecated 6.1
*/
public function validateAddComment()
{
* Adds a comment.
*
* @return string[]
+ * @deprecated 6.1
*/
public function addComment()
{
];
}
+ /**
+ * @deprecated 6.1
+ */
public function triggerPublication()
{
if (!empty($this->parameters['commentProcessor'])) {
* Validates parameters to add a response.
*
* @throws PermissionDeniedException
+ * @deprecated 6.1
*/
public function validateAddResponse()
{
* Adds a response.
*
* @return array
+ * @deprecated 6.1
*/
public function addResponse()
{
/**
* Publishes a response.
+ * @deprecated 6.1
*/
public function triggerPublicationResponse()
{
* Validates the `enable` action.
*
* @throws PermissionDeniedException
+ * @deprecated 6.1
*/
public function validateEnable()
{
* Enables a comment.
*
* @return int[]
+ * @deprecated 6.1
*/
public function enable()
{
*
* @throws PermissionDeniedException
* @throws UserInputException
- * @deprecated 6.0 use `CommentResponseAction::validateEnable()` instead
+ * @deprecated 6.0
*/
public function validateEnableResponse()
{
* Enables a response.
*
* @return int[]
- * @deprecated 6.0 use `CommentResponseAction::enable()` instead
+ * @deprecated 6.0
*/
public function enableResponse()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function validateBeginEdit()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function beginEdit()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function validateSave()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function save()
{
*
* @throws PermissionDeniedException
* @throws UserInputException
- * @deprecated 6.0 use `delete()` instead
+ * @deprecated 6.0
*/
public function validateRemove()
{
* Removes a comment or response.
*
* @return int[]
- * @deprecated 6.0 use `delete()` instead
+ * @deprecated 6.0
*/
public function remove()
{
/**
* @since 6.0
+ * @deprecated 6.1
*/
private function validateGetGuestDialog(): void
{
* them enter a username and solving a captcha.
*
* @throws SystemException
+ * @deprecated 6.1
*/
private function getGuestDialog(): ?string
{
* @param Comment $comment
* @param CommentResponse $response
* @return string|string[]
+ * @deprecated 6.1
*/
protected function renderComment(Comment $comment, ?CommentResponse $response = null)
{
*
* @param CommentResponse $response
* @return string
+ * @deprecated 6.1
*/
protected function renderResponse(CommentResponse $response)
{
* Validates message parameters.
*
* @throws UserInputException
+ * @deprecated 6.1
*/
protected function validateMessage(bool $isResponse = false)
{
* @param int $objectTypeID
* @return ObjectType
* @throws UserInputException
+ * @deprecated 6.1
*/
protected function validateObjectType($objectTypeID = null)
{
* Validates comment id parameter.
*
* @throws UserInputException
- * @deprecated 6.0 obsolete
+ * @deprecated 6.0
*/
protected function validateCommentID()
{
* Validates response id parameter.
*
* @throws UserInputException
- * @deprecated 6.0 obsolete
+ * @deprecated 6.0
*/
protected function validateResponseID()
{
/**
* Validates the username parameter.
+ * @deprecated 6.1
*/
protected function validateUsername()
{
* Validates the captcha challenge.
*
* @throws SystemException
+ * @deprecated 6.1
*/
protected function validateCaptcha()
{
/**
* Sets the list of disallowed bbcodes for comments.
+ * @deprecated 6.1
*/
protected function setDisallowedBBCodes()
{
* @param string|null $message source message
* @param int $objectID object id
* @return HtmlInputProcessor
+ * @deprecated 6.1
*/
public function getHtmlInputProcessor($message = null, $objectID = 0)
{
* Returns the comment object.
*
* @return Comment
+ * @deprecated 6.1
*/
public function getComment()
{
* Returns the comment response object.
*
* @return CommentResponse
+ * @deprecated 6.1
*/
public function getResponse()
{
* Returns the comment manager.
*
* @return ICommentManager
+ * @deprecated 6.1
*/
public function getCommentManager()
{
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\comment\Comment;
use wcf\data\comment\CommentAction;
-use wcf\data\comment\CommentEditor;
-use wcf\data\comment\CommentList;
use wcf\data\object\type\ObjectType;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\bbcode\BBCodeHandler;
use wcf\system\html\upcast\HtmlUpcastProcessor;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\moderation\queue\ModerationQueueActivationManager;
-use wcf\system\moderation\queue\ModerationQueueManager;
-use wcf\system\reaction\ReactionHandler;
-use wcf\system\user\activity\event\UserActivityEventHandler;
-use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\WCF;
use wcf\util\MessageUtil;
/**
* comment object
* @var Comment
+ * @deprecated 6.1
*/
public $comment;
/**
* comment manager object
* @var ICommentManager
+ * @deprecated 6.1
*/
public $commentManager;
/**
* comment processor
* @var ICommentManager
+ * @deprecated 6.1
*/
protected $commentProcessor;
/**
* @var HtmlInputProcessor
+ * @deprecated 6.1
*/
protected $htmlInputProcessor;
/**
* response object
* @var CommentResponse
+ * @deprecated 6.1
*/
protected $response;
- /**
- * @inheritDoc
- */
- public function validateDelete()
- {
- $this->readObjects();
-
- if ($this->getObjects() === []) {
- throw new UserInputException('objectIDs');
- }
-
- foreach ($this->getObjects() as $response) {
- $comment = $response->getComment();
- $objectType = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID);
- $processor = $objectType->getProcessor();
- if (!$processor->canDeleteResponse($response->getDecoratedObject())) {
- throw new PermissionDeniedException();
- }
- }
- }
-
- /**
- * @inheritDoc
- */
- public function delete()
- {
- if (empty($this->objects)) {
- $this->readObjects();
- }
-
- if (empty($this->objects)) {
- return 0;
- }
-
- $ignoreCounters = !empty($this->parameters['ignoreCounters']);
-
- // read object type ids for comments
- $commentIDs = [];
- foreach ($this->getObjects() as $response) {
- $commentIDs[] = $response->commentID;
- }
-
- $commentList = new CommentList();
- $commentList->setObjectIDs($commentIDs);
- $commentList->readObjects();
- $comments = $commentList->getObjects();
-
- // update counters
- /** @var ICommentManager[] $processors */
- $processors = $responseIDs = [];
- foreach ($this->getObjects() as $response) {
- $objectTypeID = $comments[$response->commentID]->objectTypeID;
-
- if (!isset($processors[$objectTypeID])) {
- $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
- $processors[$objectTypeID] = $objectType->getProcessor();
- $responseIDs[$objectTypeID] = [];
- }
- $responseIDs[$objectTypeID][] = $response->responseID;
-
- if (!$ignoreCounters && !$response->isDisabled) {
- $processors[$objectTypeID]->updateCounter($comments[$response->commentID]->objectID, -1);
- }
- }
-
- // remove responses
- $count = parent::delete();
-
- // update comment responses and cached response ids
- if (!$ignoreCounters) {
- foreach ($comments as $comment) {
- $commentEditor = new CommentEditor($comment);
- $commentEditor->updateResponseIDs();
- $commentEditor->updateUnfilteredResponseIDs();
- $commentEditor->updateResponses();
- $commentEditor->updateUnfilteredResponses();
- }
- }
-
- $deletedResponseIDs = [];
- $notificationObjectTypes = [];
- foreach ($responseIDs as $objectTypeID => $objectIDs) {
- // remove activity events
- $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
- if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectType->objectType . '.response.recentActivityEvent')) {
- UserActivityEventHandler::getInstance()->removeEvents(
- $objectType->objectType . '.response.recentActivityEvent',
- $objectIDs
- );
- }
-
- // delete notifications
- if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.response.notification')) {
- UserNotificationHandler::getInstance()->removeNotifications(
- $objectType->objectType . '.response.notification',
- $objectIDs
- );
- }
-
- $deletedResponseIDs = \array_merge($deletedResponseIDs, $objectIDs);
-
- if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType . '.response.like.notification')) {
- $notificationObjectTypes[] = $objectType->objectType . '.response.like.notification';
- }
- }
-
- if (!empty($deletedResponseIDs)) {
- // remove likes
- ReactionHandler::getInstance()->removeReactions(
- 'com.woltlab.wcf.comment.response',
- $deletedResponseIDs,
- $notificationObjectTypes
- );
-
- ModerationQueueManager::getInstance()->removeQueues(
- 'com.woltlab.wcf.comment.response',
- $deletedResponseIDs
- );
-
- MessageEmbeddedObjectManager::getInstance()->removeObjects(
- 'com.woltlab.wcf.comment.response',
- $deletedResponseIDs
- );
- }
-
- return $count;
- }
-
/**
* Validates parameters to load responses for a given comment id.
+ * @deprecated 6.1
*/
public function validateLoadResponses()
{
* Returns parsed responses for given comment id.
*
* @return array
+ * @deprecated 6.1
*/
public function loadResponses()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function validateBeginEdit()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function beginEdit()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function validateSave()
{
/**
* @inheritDoc
+ * @deprecated 6.1
*/
public function save()
{
* Validates message parameter.
*
* @throws UserInputException
+ * @deprecated 6.1
*/
protected function validateMessage()
{
* @param int $objectTypeID
* @return ObjectType
* @throws UserInputException
+ * @deprecated 6.1
*/
protected function validateObjectType($objectTypeID = null)
{
/**
* Sets the list of disallowed bbcodes for comments.
+ * @deprecated 6.1
*/
protected function setDisallowedBBCodes()
{
* @param string|null $message source message
* @param int $objectID object id
* @return HtmlInputProcessor
+ * @deprecated 6.1
*/
public function getHtmlInputProcessor($message = null, $objectID = 0)
{
* @throws PermissionDeniedException
* @throws UserInputException
* @since 6.0
+ * @deprecated 6.1
*/
public function validateEnable(): void
{
/**
* @since 6.0
+ * @deprecated 6.1
*/
public function enable(): void
{