Merge pull request #172 from gordonbanderson/issue170_can_reply_spam

FIX: Take account of spam/moderation status when enabling replies
This commit is contained in:
Damian Mooyman 2016-02-15 11:35:32 +13:00
commit 7721c20e80
2 changed files with 22 additions and 2 deletions

View File

@ -665,8 +665,9 @@ class Comment extends DataObject {
} }
// Check if depth is limited // Check if depth is limited
$maxLevel = $this->getOption('nested_depth'); $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; $comment->Depth = 4;
$this->assertFalse($comment->getRepliesEnabled()); $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() { public function testAllReplies() {