FIX: Take account of spam/moderation status when enabling replies to a comment

This commit is contained in:
Gordon Anderson 2016-02-13 21:22:07 +07:00
parent 5ec6724393
commit 551841fbda
2 changed files with 22 additions and 2 deletions

View File

@ -666,7 +666,8 @@ class Comment extends DataObject {
// Check if depth is limited
$maxLevel = $this->getOption('nested_depth');
return !$maxLevel || $this->Depth < $maxLevel;
$notSpam = ($this->SpamClass() == 'notspam');
return $notSpam && (!$maxLevel || $this->Depth < $maxLevel);
}
/**

View File

@ -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() {