/** * Removes all comments for given objects. * * @param string $objectType * @param array<integer> $objectIDs */ public function deleteObjects($objectType, array $objectIDs) { $objectTypeID = $this->getObjectTypeID($objectType); $objectTypeObj = $this->getObjectType($objectTypeID); // get comment ids $commentList = new CommentList(); $commentList->getConditionBuilder()->add('comment.objectTypeID = ?', array($objectTypeID)); $commentList->getConditionBuilder()->add('comment.objectID IN (?)', array($objectIDs)); $commentList->readObjectIDs(); $commentIDs = $commentList->getObjectIDs(); // no comments -> skip if (empty($commentIDs)) { return; } // get response ids $responseList = new CommentResponseList(); $responseList->getConditionBuilder()->add('comment_response.commentID IN (?)', array($commentIDs)); $responseList->readObjectIDs(); $responseIDs = $responseList->getObjectIDs(); // delete likes $notificationObjectTypes = array(); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.like.notification')) { $notificationObjectTypes[] = $objectTypeObj->objectType . '.like.notification'; } LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment', $commentIDs, $notificationObjectTypes); // delete activity events if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.recentActivityEvent')) { UserActivityEventHandler::getInstance()->removeEvents($objectTypeObj->objectType . '.recentActivityEvent', $commentIDs); } // delete notifications if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.notification')) { UserNotificationHandler::getInstance()->removeNotifications($objectTypeObj->objectType . '.notification', $commentIDs); } if (!empty($responseIDs)) { // delete likes (for responses) $notificationObjectTypes = array(); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.response.like.notification')) { $notificationObjectTypes[] = $objectTypeObj->objectType . '.response.like.notification'; } LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment.response', $responseIDs, $notificationObjectTypes); // delete activity events (for responses) if (UserActivityEventHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.response.recentActivityEvent')) { UserActivityEventHandler::getInstance()->removeEvents($objectTypeObj->objectType . '.response.recentActivityEvent', $responseIDs); } // delete notifications (for responses) if (UserNotificationHandler::getInstance()->getObjectTypeID($objectTypeObj->objectType . '.response.notification')) { UserNotificationHandler::getInstance()->removeNotifications($objectTypeObj->objectType . '.response.notification', $responseIDs); } } // delete comments / responses CommentEditor::deleteAll($commentIDs); }