mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Report spam/ham to akismet if it is enabled
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@39887 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d7ea506562
commit
2a64b249a2
@ -48,11 +48,23 @@ class CommentTableField extends ComplexTableField {
|
||||
$childId = Convert::raw2sql($_REQUEST['tf']['childID']);
|
||||
|
||||
if (is_numeric($childId)) {
|
||||
$childObject = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($childObject) {
|
||||
$childObject->IsSpam = true;
|
||||
$childObject->NeedsModeration = false;
|
||||
$childObject->write();
|
||||
$comment = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($comment) {
|
||||
$comment->IsSpam = true;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
$akismet->setCommentAuthor($comment->getField('Name'));
|
||||
$akismet->setCommentContent($comment->getField('Comment'));
|
||||
|
||||
$akismet->submitSpam();
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,11 +79,23 @@ class CommentTableField extends ComplexTableField {
|
||||
$childId = Convert::raw2sql($_REQUEST['tf']['childID']);
|
||||
|
||||
if (is_numeric($childId)) {
|
||||
$childObject = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($childObject) {
|
||||
$childObject->IsSpam = false;
|
||||
$childObject->NeedsModeration = false;
|
||||
$childObject->write();
|
||||
$comment = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($comment) {
|
||||
$comment->IsSpam = false;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
$akismet->setCommentAuthor($comment->getField('Name'));
|
||||
$akismet->setCommentContent($comment->getField('Comment'));
|
||||
|
||||
$akismet->submitHam();
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class FeedbackAdmin extends LeftAndMain {
|
||||
$actions->push(new FormAction('acceptmarked', 'Accept'));
|
||||
}
|
||||
|
||||
if($section == 'accepted' || $section == 'unmoderated') {
|
||||
if($section == 'approved' || $section == 'unmoderated') {
|
||||
$actions->push(new FormAction('spammarked', 'Mark as spam'));
|
||||
}
|
||||
|
||||
@ -119,6 +119,18 @@ JS;
|
||||
$comment->IsSpam = true;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
$akismet->setCommentAuthor($comment->getField('Name'));
|
||||
$akismet->setCommentContent($comment->getField('Comment'));
|
||||
|
||||
$akismet->submitSpam();
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
}
|
||||
$numComments++;
|
||||
}
|
||||
}
|
||||
@ -145,6 +157,19 @@ JS;
|
||||
$comment->IsSpam = false;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
$akismet->setCommentAuthor($comment->getField('Name'));
|
||||
$akismet->setCommentContent($comment->getField('Comment'));
|
||||
|
||||
$akismet->submitSpam();
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
}
|
||||
|
||||
$numComments++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user