mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Don't show unmoderated comments unless user is admin, add link to accept comment
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@39818 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e3445db25b
commit
6de32f6edc
@ -52,18 +52,23 @@ class PageComment extends DataObject {
|
|||||||
|
|
||||||
function SpamLink() {
|
function SpamLink() {
|
||||||
$member = Member::currentUser();
|
$member = Member::currentUser();
|
||||||
if(SSAkismet::isEnabled() && Permission::check('CMS_ACCESS_CMSMain') && !$this->getField('IsSpam')) {
|
if(Permission::check('CMS_ACCESS_CMSMain') && !$this->getField('IsSpam')) {
|
||||||
return "PageComment/reportspam/$this->ID";
|
return "PageComment/reportspam/$this->ID";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function HamLink() {
|
function HamLink() {
|
||||||
$member = Member::currentUser();
|
if(Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
|
||||||
if(SSAkismet::isEnabled() && Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
|
|
||||||
return "PageComment/reportham/$this->ID";
|
return "PageComment/reportham/$this->ID";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AcceptLink() {
|
||||||
|
if(Permission::check('CMS_ACCESS_CMSMain') && $this->getField('NeedsModeration')) {
|
||||||
|
return "PageComment/accept/$this->ID";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function SpamClass() {
|
function SpamClass() {
|
||||||
if($this->getField('IsSpam')) {
|
if($this->getField('IsSpam')) {
|
||||||
return 'spam';
|
return 'spam';
|
||||||
@ -72,8 +77,23 @@ class PageComment extends DataObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function accept() {
|
||||||
|
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||||
|
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||||
|
$comment->NeedsModeration = false;
|
||||||
|
$comment->write();
|
||||||
|
|
||||||
|
if(Director::is_ajax()) {
|
||||||
|
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||||
|
} else {
|
||||||
|
Director::redirectBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function reportspam() {
|
function reportspam() {
|
||||||
if(SSAkismet::isEnabled() && Permission::check('CMS_ACCESS_CMSMain')) {
|
if(SSAkismet::isEnabled()) {
|
||||||
|
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||||
|
|
||||||
if($comment) {
|
if($comment) {
|
||||||
@ -106,9 +126,11 @@ class PageComment extends DataObject {
|
|||||||
Director::redirectBack();
|
Director::redirectBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function reportham() {
|
function reportham() {
|
||||||
if(SSAkismet::isEnabled() && Permission::check('CMS_ACCESS_CMSMain')) {
|
if(SSAkismet::isEnabled()) {
|
||||||
|
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||||
|
|
||||||
if($comment) {
|
if($comment) {
|
||||||
@ -133,6 +155,7 @@ class PageComment extends DataObject {
|
|||||||
Director::redirectBack();
|
Director::redirectBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function RSSTitle() {
|
function RSSTitle() {
|
||||||
return "Comment by '". Convert::raw2xml($this->Name) . "' on " . $this->Parent()->Title;
|
return "Comment by '". Convert::raw2xml($this->Name) . "' on " . $this->Parent()->Title;
|
||||||
@ -158,7 +181,7 @@ class PageComment extends DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function moderationEnabled() {
|
static function moderationEnabled() {
|
||||||
return self::moderate;
|
return self::$moderate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,9 +142,9 @@ class PageCommentInterface_Form extends Form {
|
|||||||
$comment = Object::create('PageComment');
|
$comment = Object::create('PageComment');
|
||||||
$this->saveInto($comment);
|
$this->saveInto($comment);
|
||||||
$comment->IsSpam = false;
|
$comment->IsSpam = false;
|
||||||
$comment->write();
|
$comment->NeedsModeration = PageComment::moderationEnabled();
|
||||||
|
|
||||||
$comment->NeedsModeration = PageComment::moderationEnable();
|
$comment->write();
|
||||||
|
|
||||||
if(Director::is_ajax()) {
|
if(Director::is_ajax()) {
|
||||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||||
|
@ -19,6 +19,9 @@ PageCommentInterface.prototype = {
|
|||||||
},
|
},
|
||||||
'#PageComments a.hamlink' : {
|
'#PageComments a.hamlink' : {
|
||||||
onclick : this.reportHam
|
onclick : this.reportHam
|
||||||
|
},
|
||||||
|
'#PageComments a.acceptlink' : {
|
||||||
|
onclick : this.acceptComment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -179,6 +182,33 @@ PageCommentInterface.prototype = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajax handler of ham reporting
|
||||||
|
*/
|
||||||
|
acceptComment: function() {
|
||||||
|
var __comment = this.parentNode.parentNode.parentNode;
|
||||||
|
|
||||||
|
__comment.getElementsByTagName('span')[0].innerHTML = "Marking comment as accepted...";
|
||||||
|
|
||||||
|
new Ajax.Request(this.href + '?ajax=1', {
|
||||||
|
onSuccess : function(response) {
|
||||||
|
// Load the response into the <li>
|
||||||
|
__comment.innerHTML = response.responseText;
|
||||||
|
Behaviour.apply(__comment);
|
||||||
|
|
||||||
|
// Flash it using Scriptaculous
|
||||||
|
new Effect.Highlight(__comment, { endcolor: '#e9e9e9' } );
|
||||||
|
__comment.className = 'notspam';
|
||||||
|
},
|
||||||
|
|
||||||
|
onFailure : function(response) {
|
||||||
|
alert(response.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
<p class="comment" id="PageComment_$ID">$Comment.XML</p>
|
<p class="comment" id="PageComment_$ID">
|
||||||
|
<% if NeedsModeration %>
|
||||||
|
<p><b>Unmoderated comment</b></p>
|
||||||
|
<% end_if %>
|
||||||
|
$Comment.XML
|
||||||
|
</p>
|
||||||
<p class="info">
|
<p class="info">
|
||||||
<span>Posted by $Name.XML, $Created.Nice ($Created.Ago)</span>
|
<span>Posted by $Name.XML, $Created.Nice ($Created.Ago)</span>
|
||||||
<br />
|
<br />
|
||||||
<span>
|
<span>
|
||||||
<% if DeleteLink %>
|
<% if AcceptLink %>
|
||||||
<a href="$DeleteLink" class="deletelink">remove this comment</a>
|
<a href="$AcceptLink" class="acceptlink">accept this comment</a>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
<% if SpamLink %>
|
<% if SpamLink %>
|
||||||
<a href="$SpamLink" class="spamlink">this comment is spam</a>
|
<a href="$SpamLink" class="spamlink">this comment is spam</a>
|
||||||
@ -12,5 +17,8 @@
|
|||||||
<% if HamLink %>
|
<% if HamLink %>
|
||||||
<a href="$HamLink" class="hamlink">this comment is not spam</a>
|
<a href="$HamLink" class="hamlink">this comment is not spam</a>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
<% if DeleteLink %>
|
||||||
|
<a href="$DeleteLink" class="deletelink">remove this comment</a>
|
||||||
|
<% end_if %>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user