</div>
{if $comment|count}
- <ul data-responses="{@$comment->responses}" class="containerList commentResponseList">
+ <ul data-responses="{if $commentCanModerate}{@$comment->unfilteredResponses}{else}{@$comment->responses}{/if}" class="containerList commentResponseList">
{include file='commentResponseList' responseList=$comment}
</ul>
{/if}
* @property-read string $message comment message
* @property-read integer $responses number of responses on the comment
* @property-read string $responseIDs serialized array with the ids of the five latest comment responses
+ * @property-read integer $unfilteredResponses number of all responses on the comment, including disabled ones
+ * @property-read string $unfilteredResponseIDs serialized array with the ids of the five latest comment responses, including disabled ones
* @property-read integer $enableHtml is 1 if HTML will rendered in the comment, otherwise 0
* @property-read integer $isDisabled is 1 if the comment is disabled, otherwise 0
*/
return $responseIDs;
}
+ /**
+ * Returns a list of unfiltered response ids, including those that are still disabled.
+ *
+ * @return integer[]
+ */
+ public function getUnfilteredResponseIDs() {
+ if ($this->unfilteredResponseIDs === null || $this->unfilteredResponseIDs == '') {
+ return [];
+ }
+
+ $responseIDs = @unserialize($this->unfilteredResponseIDs);
+ if ($responseIDs === false) {
+ return [];
+ }
+
+ return $responseIDs;
+ }
+
/**
* @inheritDoc
*/
$this->createdResponse->setComment($this->comment);
// update response data
- $responseIDs = $this->comment->getResponseIDs();
- if (count($responseIDs) < 5) {
- $responseIDs[] = $this->createdResponse->responseID;
+ $unfilteredResponseIDs = $this->comment->getUnfilteredResponseIDs();
+ if (count($unfilteredResponseIDs) < 5) {
+ $unfilteredResponseIDs[] = $this->createdResponse->responseID;
}
- $responses = $this->comment->responses + 1;
+ $unfilteredResponses = $this->comment->unfilteredResponses + 1;
// update comment
$commentEditor = new CommentEditor($this->comment);
$commentEditor->update([
- 'responseIDs' => serialize($responseIDs),
- 'responses' => $responses
+ 'unfilteredResponseIDs' => serialize($unfilteredResponseIDs),
+ 'unfilteredResponses' => $unfilteredResponses
]);
if (!$this->createdResponse->isDisabled) {
}
}
+ $responses = $this->comment->responses;
+ if ($this->commentProcessor->canModerate($this->parameters['data']['objectTypeID'], $this->parameters['data']['objectID'])) {
+ $responses = $this->comment->unfilteredResponses;
+ }
+
return [
'commentID' => $this->comment->commentID,
'template' => $this->renderResponse($this->createdResponse),
- 'responses' => $responses
+ 'responses' => $responses + 1
];
}
foreach ($this->parameters['responses'] as $response) {
$comment = $response->getComment();
+ // update response count
+ $commentEditor = new CommentEditor($comment);
+ $commentEditor->updateCounters(['responses' => 1]);
+
+ // do not prepend the response id as the approved response can appear anywhere
+ $commentEditor->updateResponseIDs();
+
// update counter
$this->commentProcessor->updateCounter($comment->objectID, 1);
$sql = "SELECT responseID
FROM wcf".WCF_N."_comment_response
WHERE commentID = ?
+ AND isDisabled = ?
ORDER BY time ASC, responseID ASC";
$statement = WCF::getDB()->prepareStatement($sql, 5);
- $statement->execute([$this->commentID]);
+ $statement->execute([$this->commentID, 0]);
$responseIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
$this->update(['responseIDs' => serialize($responseIDs)]);
}
+
+ /**
+ * Updates response ids, including disabled ones.
+ */
+ public function updateUnfilteredResponseIDs() {
+ $sql = "SELECT responseID
+ FROM wcf".WCF_N."_comment_response
+ WHERE commentID = ?
+ ORDER BY time ASC, responseID ASC";
+ $statement = WCF::getDB()->prepareStatement($sql, 5);
+ $statement->execute([$this->commentID]);
+ $responseIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
+
+ $this->update(['unfilteredResponseIDs' => serialize($responseIDs)]);
+ }
}
}
// fetch last responses
- if ( !empty($responseIDs)) {
+ if (!empty($responseIDs)) {
$responseList = new CommentResponseList();
- $responseList->setObjectIDs(array_keys($responseIDs));
+
+ if ($this->commentManager->canModerate($this->objectTypeID, $this->objectID)) {
+ $responseList->setObjectIDs(array_keys($responseIDs));
+ }
+ else {
+ $responseList->getConditionBuilder()->add('comment_response.responseID IN (?)', [array_keys($responseIDs)]);
+
+ if (WCF::getUser()->userID) $responseList->getConditionBuilder()->add('(comment_response.isDisabled = 0 OR comment_response.userID = ?)', [WCF::getUser()->userID]);
+ else $responseList->getConditionBuilder()->add('comment_response.isDisabled = 0');
+ }
+
$responseList->readObjects();
foreach ($responseList as $response) {
message TEXT NOT NULL,
responses MEDIUMINT(7) NOT NULL DEFAULT '0',
responseIDs VARCHAR(255) NOT NULL DEFAULT '',
+ unfilteredResponses MEDIUMINT(7) NOT NULL DEFAULT '0',
+ unfilteredResponseIDs VARCHAR(255) NOT NULL DEFAULT '',
enableHtml TINYINT(1) NOT NULL DEFAULT 0,
isDisabled TINYINT(1) NOT NULL DEFAULT 0,