2010-11-29 23:24:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package comments
|
|
|
|
*/
|
|
|
|
class CommentsTest extends FunctionalTest {
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public static $fixture_file = 'comments/tests/CommentsTest.yml';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
protected $extraDataObjects = array(
|
|
|
|
'CommentableItem'
|
|
|
|
);
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2015-04-07 05:56:00 +02:00
|
|
|
Config::nest();
|
|
|
|
}
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
public function tearDown() {
|
|
|
|
Config::unnest();
|
|
|
|
parent::tearDown();
|
2012-07-31 10:45:29 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 09:29:11 +01:00
|
|
|
public function testCommentsList() {
|
|
|
|
// comments don't require moderation so unmoderated comments can be
|
|
|
|
// shown but not spam posts
|
2015-04-07 05:56:00 +02:00
|
|
|
Config::inst()->update('CommentableItem', 'comments', array('require_moderation' => false));
|
2013-11-28 09:29:11 +01:00
|
|
|
|
|
|
|
$item = $this->objFromFixture('CommentableItem', 'spammed');
|
|
|
|
|
|
|
|
$this->assertDOSEquals(array(
|
|
|
|
array('Name' => 'Comment 1'),
|
|
|
|
array('Name' => 'Comment 3')
|
2015-04-07 05:56:00 +02:00
|
|
|
), $item->Comments(), 'Only 2 non spam posts should be shown');
|
2013-11-28 09:29:11 +01:00
|
|
|
|
|
|
|
// when moderated, only moderated, non spam posts should be shown.
|
2015-04-07 05:56:00 +02:00
|
|
|
Config::inst()->update('CommentableItem', 'comments', array('require_moderation' => true));
|
2013-11-28 09:29:11 +01:00
|
|
|
|
|
|
|
$this->assertDOSEquals(array(
|
|
|
|
array('Name' => 'Comment 3')
|
2015-04-07 05:56:00 +02:00
|
|
|
), $item->Comments(), 'Only 1 non spam, moderated post should be shown');
|
2013-11-28 09:29:11 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
// As of 2.0, logging in with admin no longer grants special privileges to view frontend comments and should
|
|
|
|
// be done via the CMS
|
2013-11-28 09:29:11 +01:00
|
|
|
$this->logInWithPermission('CMS_ACCESS_CommentAdmin');
|
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
Config::inst()->update('CommentableItem', 'comments', array('require_moderation' => true));
|
|
|
|
$this->assertEquals(1, $item->Comments()->Count());
|
2013-11-28 09:29:11 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
Config::inst()->update('CommentableItem', 'comments', array('require_moderation' => false));
|
|
|
|
$this->assertEquals(2, $item->Comments()->Count());
|
2013-11-28 09:29:11 +01:00
|
|
|
}
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public function testCanView() {
|
2010-11-29 23:24:17 +01:00
|
|
|
$visitor = $this->objFromFixture('Member', 'visitor');
|
|
|
|
$admin = $this->objFromFixture('Member', 'commentadmin');
|
2010-12-11 05:59:46 +01:00
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2010-11-29 23:24:17 +01:00
|
|
|
$this->assertTrue($comment->canView($visitor),
|
2012-07-31 10:45:29 +02:00
|
|
|
'Unauthenticated members can view comments associated to a object with ProvideComments=1'
|
2010-11-29 23:24:17 +01:00
|
|
|
);
|
|
|
|
$this->assertTrue($comment->canView($admin),
|
|
|
|
'Admins with CMS_ACCESS_CommentAdmin permissions can view comments associated to a page with ProvideComments=1'
|
|
|
|
);
|
|
|
|
|
2010-12-11 05:59:46 +01:00
|
|
|
$disabledComment = $this->objFromFixture('Comment', 'disabledCom');
|
2010-11-29 23:24:17 +01:00
|
|
|
|
|
|
|
$this->assertFalse($disabledComment->canView($visitor),
|
2012-07-31 10:45:29 +02:00
|
|
|
'Unauthenticated members can not view comments associated to a object with ProvideComments=0'
|
2010-11-29 23:24:17 +01:00
|
|
|
);
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2010-11-29 23:24:17 +01:00
|
|
|
$this->assertTrue($disabledComment->canView($admin),
|
|
|
|
'Admins with CMS_ACCESS_CommentAdmin permissions can view comments associated to a page with ProvideComments=0'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public function testCanEdit() {
|
2010-11-29 23:24:17 +01:00
|
|
|
$visitor = $this->objFromFixture('Member', 'visitor');
|
|
|
|
$admin = $this->objFromFixture('Member', 'commentadmin');
|
2010-12-11 05:59:46 +01:00
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
2010-11-29 23:24:17 +01:00
|
|
|
|
|
|
|
$this->assertFalse($comment->canEdit($visitor));
|
|
|
|
$this->assertTrue($comment->canEdit($admin));
|
|
|
|
}
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public function testCanDelete() {
|
2010-11-29 23:24:17 +01:00
|
|
|
$visitor = $this->objFromFixture('Member', 'visitor');
|
|
|
|
$admin = $this->objFromFixture('Member', 'commentadmin');
|
2010-12-11 05:59:46 +01:00
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
2010-11-29 23:24:17 +01:00
|
|
|
|
|
|
|
$this->assertFalse($comment->canEdit($visitor));
|
|
|
|
$this->assertTrue($comment->canEdit($admin));
|
|
|
|
}
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public function testDeleteComment() {
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test anonymous user
|
|
|
|
if($member = Member::currentUser()) $member->logOut();
|
2012-07-31 10:45:29 +02:00
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
2015-03-27 05:40:00 +01:00
|
|
|
$commentID = $comment->ID;
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->DeleteLink(), 'No permission to see delete link');
|
2015-03-30 07:57:29 +02:00
|
|
|
$delete = $this->get('CommentingController/delete/'.$comment->ID.'?ajax=1');
|
2015-03-27 05:40:00 +01:00
|
|
|
$this->assertEquals(403, $delete->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->assertTrue($check && $check->exists());
|
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test non-authenticated user
|
|
|
|
$this->logInAs('visitor');
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->DeleteLink(), 'No permission to see delete link');
|
2015-03-27 05:40:00 +01:00
|
|
|
|
|
|
|
// Test authenticated user
|
2010-11-29 23:24:17 +01:00
|
|
|
$this->logInAs('commentadmin');
|
2015-03-27 05:40:00 +01:00
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
|
|
|
$commentID = $comment->ID;
|
|
|
|
$adminComment1Link = $comment->DeleteLink();
|
|
|
|
$this->assertContains('CommentingController/delete/'.$commentID.'?t=', $adminComment1Link);
|
|
|
|
|
|
|
|
// Test that this link can't be shared / XSS exploited
|
|
|
|
$this->logInAs('commentadmin2');
|
|
|
|
$delete = $this->get($adminComment1Link);
|
|
|
|
$this->assertEquals(400, $delete->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
|
|
|
$this->assertTrue($check && $check->exists());
|
|
|
|
|
|
|
|
// Test that this other admin can delete the comment with their own link
|
|
|
|
$adminComment2Link = $comment->DeleteLink();
|
|
|
|
$this->assertNotEquals($adminComment2Link, $adminComment1Link);
|
|
|
|
$this->autoFollowRedirection = false;
|
|
|
|
$delete = $this->get($adminComment2Link);
|
|
|
|
$this->assertEquals(302, $delete->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->assertFalse($check && $check->exists());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpamComment() {
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test anonymous user
|
|
|
|
if($member = Member::currentUser()) $member->logOut();
|
2012-07-31 10:45:29 +02:00
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
2015-03-27 05:40:00 +01:00
|
|
|
$commentID = $comment->ID;
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->SpamLink(), 'No permission to see mark as spam link');
|
2015-03-30 07:57:29 +02:00
|
|
|
$spam = $this->get('CommentingController/spam/'.$comment->ID.'?ajax=1');
|
2015-03-27 05:40:00 +01:00
|
|
|
$this->assertEquals(403, $spam->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
|
|
|
$this->assertEquals(0, $check->IsSpam, 'No permission to mark as spam');
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test non-authenticated user
|
|
|
|
$this->logInAs('visitor');
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->SpamLink(), 'No permission to see mark as spam link');
|
2015-03-27 05:40:00 +01:00
|
|
|
|
|
|
|
// Test authenticated user
|
|
|
|
$this->logInAs('commentadmin');
|
|
|
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
|
|
|
$commentID = $comment->ID;
|
|
|
|
$adminComment1Link = $comment->SpamLink();
|
|
|
|
$this->assertContains('CommentingController/spam/'.$commentID.'?t=', $adminComment1Link);
|
|
|
|
|
|
|
|
// Test that this link can't be shared / XSS exploited
|
|
|
|
$this->logInAs('commentadmin2');
|
|
|
|
$spam = $this->get($adminComment1Link);
|
|
|
|
$this->assertEquals(400, $spam->getStatusCode());
|
2012-07-31 10:45:29 +02:00
|
|
|
$check = DataObject::get_by_id('Comment', $comment->ID);
|
|
|
|
$this->assertEquals(0, $check->IsSpam, 'No permission to mark as spam');
|
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test that this other admin can spam the comment with their own link
|
|
|
|
$adminComment2Link = $comment->SpamLink();
|
|
|
|
$this->assertNotEquals($adminComment2Link, $adminComment1Link);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->autoFollowRedirection = false;
|
2015-03-27 05:40:00 +01:00
|
|
|
$spam = $this->get($adminComment2Link);
|
|
|
|
$this->assertEquals(302, $spam->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->assertEquals(1, $check->IsSpam);
|
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Cannot re-spam spammed comment
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($check->SpamLink());
|
2012-07-31 10:45:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testHamComment() {
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test anonymous user
|
|
|
|
if($member = Member::currentUser()) $member->logOut();
|
2012-07-31 10:45:29 +02:00
|
|
|
$comment = $this->objFromFixture('Comment', 'secondComC');
|
2015-03-27 05:40:00 +01:00
|
|
|
$commentID = $comment->ID;
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->HamLink(), 'No permission to see mark as ham link');
|
2015-03-30 07:57:29 +02:00
|
|
|
$ham = $this->get('CommentingController/ham/'.$comment->ID.'?ajax=1');
|
2015-03-27 05:40:00 +01:00
|
|
|
$this->assertEquals(403, $ham->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
|
|
|
$this->assertEquals(1, $check->IsSpam, 'No permission to mark as ham');
|
|
|
|
|
|
|
|
// Test non-authenticated user
|
|
|
|
$this->logInAs('visitor');
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->HamLink(), 'No permission to see mark as ham link');
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test authenticated user
|
|
|
|
$this->logInAs('commentadmin');
|
|
|
|
$comment = $this->objFromFixture('Comment', 'secondComC');
|
|
|
|
$commentID = $comment->ID;
|
|
|
|
$adminComment1Link = $comment->HamLink();
|
|
|
|
$this->assertContains('CommentingController/ham/'.$commentID.'?t=', $adminComment1Link);
|
|
|
|
|
|
|
|
// Test that this link can't be shared / XSS exploited
|
|
|
|
$this->logInAs('commentadmin2');
|
|
|
|
$ham = $this->get($adminComment1Link);
|
|
|
|
$this->assertEquals(400, $ham->getStatusCode());
|
2012-07-31 10:45:29 +02:00
|
|
|
$check = DataObject::get_by_id('Comment', $comment->ID);
|
|
|
|
$this->assertEquals(1, $check->IsSpam, 'No permission to mark as ham');
|
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test that this other admin can ham the comment with their own link
|
|
|
|
$adminComment2Link = $comment->HamLink();
|
|
|
|
$this->assertNotEquals($adminComment2Link, $adminComment1Link);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->autoFollowRedirection = false;
|
2015-03-27 05:40:00 +01:00
|
|
|
$ham = $this->get($adminComment2Link);
|
|
|
|
$this->assertEquals(302, $ham->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->assertEquals(0, $check->IsSpam);
|
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Cannot re-ham hammed comment
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($check->HamLink());
|
2010-11-29 23:24:17 +01:00
|
|
|
}
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public function testApproveComment() {
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test anonymous user
|
|
|
|
if($member = Member::currentUser()) $member->logOut();
|
2012-07-31 10:45:29 +02:00
|
|
|
$comment = $this->objFromFixture('Comment', 'secondComB');
|
2015-03-27 05:40:00 +01:00
|
|
|
$commentID = $comment->ID;
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->ApproveLink(), 'No permission to see approve link');
|
2015-03-30 07:57:29 +02:00
|
|
|
$approve = $this->get('CommentingController/approve/'.$comment->ID.'?ajax=1');
|
2015-03-27 05:40:00 +01:00
|
|
|
$this->assertEquals(403, $approve->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
|
|
|
$this->assertEquals(0, $check->Moderated, 'No permission to approve');
|
|
|
|
|
|
|
|
// Test non-authenticated user
|
|
|
|
$this->logInAs('visitor');
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($comment->ApproveLink(), 'No permission to see approve link');
|
2015-03-27 05:40:00 +01:00
|
|
|
|
|
|
|
// Test authenticated user
|
|
|
|
$this->logInAs('commentadmin');
|
|
|
|
$comment = $this->objFromFixture('Comment', 'secondComB');
|
|
|
|
$commentID = $comment->ID;
|
|
|
|
$adminComment1Link = $comment->ApproveLink();
|
|
|
|
$this->assertContains('CommentingController/approve/'.$commentID.'?t=', $adminComment1Link);
|
|
|
|
|
|
|
|
// Test that this link can't be shared / XSS exploited
|
|
|
|
$this->logInAs('commentadmin2');
|
|
|
|
$approve = $this->get($adminComment1Link);
|
|
|
|
$this->assertEquals(400, $approve->getStatusCode());
|
2012-07-31 10:45:29 +02:00
|
|
|
$check = DataObject::get_by_id('Comment', $comment->ID);
|
2015-03-27 05:40:00 +01:00
|
|
|
$this->assertEquals(0, $check->Moderated, 'No permission to approve');
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Test that this other admin can approve the comment with their own link
|
|
|
|
$adminComment2Link = $comment->ApproveLink();
|
|
|
|
$this->assertNotEquals($adminComment2Link, $adminComment1Link);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->autoFollowRedirection = false;
|
2015-03-27 05:40:00 +01:00
|
|
|
$approve = $this->get($adminComment2Link);
|
|
|
|
$this->assertEquals(302, $approve->getStatusCode());
|
|
|
|
$check = DataObject::get_by_id('Comment', $commentID);
|
2012-07-31 10:45:29 +02:00
|
|
|
$this->assertEquals(1, $check->Moderated);
|
|
|
|
|
2015-03-27 05:40:00 +01:00
|
|
|
// Cannot re-approve approved comment
|
2015-04-01 03:58:03 +02:00
|
|
|
$this->assertNull($check->ApproveLink());
|
2012-07-31 10:45:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCommenterURLWrite() {
|
2010-12-11 05:59:46 +01:00
|
|
|
$comment = new Comment();
|
2010-11-29 23:24:17 +01:00
|
|
|
// We only care about the CommenterURL, so only set that
|
|
|
|
// Check a http and https URL. Add more test urls here as needed.
|
|
|
|
$protocols = array(
|
|
|
|
'Http',
|
|
|
|
'Https',
|
|
|
|
);
|
|
|
|
$url = '://example.com';
|
2012-07-31 10:45:29 +02:00
|
|
|
|
2010-11-29 23:24:17 +01:00
|
|
|
foreach($protocols as $protocol) {
|
|
|
|
$comment->CommenterURL = $protocol . $url;
|
|
|
|
// The protocol should stay as if, assuming it is valid
|
|
|
|
$comment->write();
|
|
|
|
$this->assertEquals($comment->CommenterURL, $protocol . $url, $protocol . ':// is a valid protocol');
|
|
|
|
}
|
|
|
|
}
|
2013-02-21 16:39:57 +01:00
|
|
|
|
|
|
|
public function testSanitizesWithAllowHtml() {
|
|
|
|
if(!class_exists('HTMLPurifier')) {
|
|
|
|
$this->markTestSkipped('HTMLPurifier class not found');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$origAllowed = Commenting::get_config_value('CommentableItem','html_allowed');
|
|
|
|
|
|
|
|
// Without HTML allowed
|
|
|
|
$comment1 = new Comment();
|
|
|
|
$comment1->BaseClass = 'CommentableItem';
|
|
|
|
$comment1->Comment = '<p><script>alert("w00t")</script>my comment</p>';
|
|
|
|
$comment1->write();
|
|
|
|
$this->assertEquals(
|
|
|
|
'<p><script>alert("w00t")</script>my comment</p>',
|
|
|
|
$comment1->Comment,
|
|
|
|
'Does not remove HTML tags with html_allowed=false, ' .
|
|
|
|
'which is correct behaviour because the HTML will be escaped'
|
|
|
|
);
|
|
|
|
|
|
|
|
// With HTML allowed
|
|
|
|
Commenting::set_config_value('CommentableItem','html_allowed', true);
|
|
|
|
$comment2 = new Comment();
|
|
|
|
$comment2->BaseClass = 'CommentableItem';
|
|
|
|
$comment2->Comment = '<p><script>alert("w00t")</script>my comment</p>';
|
|
|
|
$comment2->write();
|
|
|
|
$this->assertEquals(
|
|
|
|
'<p>my comment</p>',
|
|
|
|
$comment2->Comment,
|
|
|
|
'Removes HTML tags which are not on the whitelist'
|
|
|
|
);
|
|
|
|
|
|
|
|
Commenting::set_config_value('CommentableItem','html_allowed', $origAllowed);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDefaultTemplateRendersHtmlWithAllowHtml() {
|
|
|
|
if(!class_exists('HTMLPurifier')) {
|
|
|
|
$this->markTestSkipped('HTMLPurifier class not found');
|
|
|
|
}
|
|
|
|
|
|
|
|
$origAllowed = Commenting::get_config_value('CommentableItem', 'html_allowed');
|
|
|
|
$item = new CommentableItem();
|
|
|
|
$item->write();
|
|
|
|
|
|
|
|
// Without HTML allowed
|
|
|
|
$comment = new Comment();
|
|
|
|
$comment->Comment = '<p>my comment</p>';
|
|
|
|
$comment->ParentID = $item->ID;
|
|
|
|
$comment->BaseClass = 'CommentableItem';
|
|
|
|
$comment->write();
|
|
|
|
|
|
|
|
$html = $item->customise(array('CommentsEnabled' => true))->renderWith('CommentsInterface');
|
|
|
|
$this->assertContains(
|
|
|
|
'<p>my comment</p>',
|
|
|
|
$html
|
|
|
|
);
|
|
|
|
|
|
|
|
Commenting::set_config_value('CommentableItem','html_allowed', true);
|
|
|
|
$html = $item->customise(array('CommentsEnabled' => true))->renderWith('CommentsInterface');
|
|
|
|
$this->assertContains(
|
|
|
|
'<p>my comment</p>',
|
|
|
|
$html
|
|
|
|
);
|
|
|
|
|
|
|
|
Commenting::set_config_value('CommentableItem','html_allowed', $origAllowed);
|
|
|
|
}
|
2013-11-28 09:29:11 +01:00
|
|
|
|
2010-11-29 23:24:17 +01:00
|
|
|
}
|
2012-07-31 10:45:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package comments
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class CommentableItem extends DataObject implements TestOnly {
|
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $db = array(
|
2012-07-31 10:45:29 +02:00
|
|
|
'ProvideComments' => 'Boolean',
|
|
|
|
'Title' => 'Varchar'
|
|
|
|
);
|
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
private static $extensions = array(
|
|
|
|
'CommentsExtension'
|
|
|
|
);
|
|
|
|
|
2012-07-31 10:45:29 +02:00
|
|
|
public function RelativeLink() {
|
|
|
|
return "CommentableItem_Controller";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canView($member = null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Link() {
|
|
|
|
return $this->RelativeLink();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function AbsoluteLink() {
|
|
|
|
return Director::absoluteURL($this->RelativeLink());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package comments
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class CommentableItem_Controller extends Controller implements TestOnly {
|
|
|
|
|
|
|
|
public function index() {
|
|
|
|
return CommentableItem::get()->first()->CommentsForm();
|
|
|
|
}
|
|
|
|
}
|