diff --git a/code/CommentTableField.php b/code/CommentTableField.php index 6584009f..a87325b4 100644 --- a/code/CommentTableField.php +++ b/code/CommentTableField.php @@ -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. + } + } } } } diff --git a/code/FeedbackAdmin.php b/code/FeedbackAdmin.php index 6698a10b..5a92e371 100644 --- a/code/FeedbackAdmin.php +++ b/code/FeedbackAdmin.php @@ -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++; } }