mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX: Take account of spam/moderation status when enabling replies to a comment
This commit is contained in:
parent
5ec6724393
commit
551841fbda
@ -665,8 +665,9 @@ class Comment extends DataObject {
|
||||
}
|
||||
|
||||
// Check if depth is limited
|
||||
$maxLevel = $this->getOption('nested_depth');
|
||||
return !$maxLevel || $this->Depth < $maxLevel;
|
||||
$maxLevel = $this->getOption('nested_depth');
|
||||
$notSpam = ($this->SpamClass() == 'notspam');
|
||||
return $notSpam && (!$maxLevel || $this->Depth < $maxLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -966,6 +966,25 @@ class CommentsTest extends FunctionalTest {
|
||||
|
||||
$comment->Depth = 4;
|
||||
$this->assertFalse($comment->getRepliesEnabled());
|
||||
|
||||
|
||||
// 0 indicates no limit for nested_depth
|
||||
Config::inst()->update('CommentableItem', 'comments', array(
|
||||
'nested_comments' => true,
|
||||
'nested_depth' => 0
|
||||
));
|
||||
|
||||
$comment->Depth = 234;
|
||||
$this->assertTrue($comment->getRepliesEnabled());
|
||||
$comment->markUnapproved();
|
||||
$this->assertFalse($comment->getRepliesEnabled());
|
||||
$comment->markSpam();
|
||||
$this->assertFalse($comment->getRepliesEnabled());
|
||||
|
||||
$comment->markApproved();
|
||||
$this->assertTrue($comment->getRepliesEnabled());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testAllReplies() {
|
||||
|
Loading…
Reference in New Issue
Block a user