3 class PageComment
extends DataObject
{
10 static $has_one = array(
11 "Parent" => "SiteTree",
14 static $casting = array(
15 "RSSTitle" => "Varchar",
18 // Number of comments to show before paginating
19 static $comments_per_page = 10;
22 * Return a link to this comment
23 * @return string link to this comment.
26 return $this->Parent()->Link();
30 function DeleteLink() {
31 if(Permission
::check('CMS_ACCESS_CMSMain')) {
32 return "PageComment/deletecomment/$this->ID";
35 function deletecomment() {
36 if(Permission
::check('CMS_ACCESS_CMSMain')) {
37 $comment = DataObject
::get_by_id("PageComment", $this->urlParams
['ID']);
43 if(Director
::is_ajax()) {
46 Director
::redirectBack();
51 $member = Member
::currentUser();
52 if(SSAkismet
::isEnabled() && Permission
::check('CMS_ACCESS_CMSMain') && !$this->getField('IsSpam')) {
53 return "PageComment/reportspam/$this->ID";
58 $member = Member
::currentUser();
59 if(SSAkismet
::isEnabled() && Permission
::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
60 return "PageComment/reportham/$this->ID";
64 function SpamClass() {
65 if($this->getField('IsSpam')) {
72 function reportspam() {
73 if(SSAkismet
::isEnabled() && Permission
::check('CMS_ACCESS_CMSMain')) {
74 $comment = DataObject
::get_by_id("PageComment", $this->urlParams
['ID']);
78 $akismet = new SSAkismet();
79 $akismet->setCommentAuthor($comment->getField('Name'));
80 $akismet->setCommentContent($comment->getField('Comment'));
82 $akismet->submitSpam();
83 } catch (Exception
$e) {
84 // Akismet didn't work, most likely the service is down.
87 if(SSAkismet
::getSaveSpam()) {
88 $comment->setField('IsSpam', true);
96 if(Director
::is_ajax()) {
97 if(SSAkismet
::getSaveSpam()) {
98 echo $comment->renderWith('PageCommentInterface_singlecomment');
103 Director
::redirectBack();
107 function reportham() {
108 if(SSAkismet
::isEnabled() && Permission
::check('CMS_ACCESS_CMSMain')) {
109 $comment = DataObject
::get_by_id("PageComment", $this->urlParams
['ID']);
113 $akismet = new SSAkismet();
114 $akismet->setCommentAuthor($comment->getField('Name'));
115 $akismet->setCommentContent($comment->getField('Comment'));
117 $akismet->submitHam();
118 } catch (Exception
$e) {
119 // Akismet didn't work, most likely the service is down.
122 $comment->setField('IsSpam', false);
127 if(Director
::is_ajax()) {
128 echo $comment->renderWith('PageCommentInterface_singlecomment');
130 Director
::redirectBack();
134 function RSSTitle() {
135 return "Comment by '$this->Name' on " . $this->Parent()->Title
;
138 $rss = new RSSFeed(DataObject
::get("PageComment", "ParentID > 0", "Created DESC", "", 10), "home/", "Page comments", "", "RSSTitle", "Comment", "Name");
139 $rss->outputToBrowser();