mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
MINOR: fixed whitespace issue and added SessionID to page comment
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@72903 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
27bfe60a33
commit
5e5a06d8e9
@ -11,7 +11,8 @@ class PageComment extends DataObject {
|
||||
"Comment" => "Text",
|
||||
"IsSpam" => "Boolean",
|
||||
"NeedsModeration" => "Boolean",
|
||||
"CommenterURL" => "Varchar(255)"
|
||||
"CommenterURL" => "Varchar(255)",
|
||||
"SessionID" => "Varchar(255)"
|
||||
);
|
||||
|
||||
static $has_one = array(
|
||||
@ -185,6 +186,8 @@ class PageComment_Controller extends Controller {
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
// @todo Report to spamprotecter this is true
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
@ -194,68 +197,80 @@ class PageComment_Controller extends Controller {
|
||||
}
|
||||
|
||||
function reportspam() {
|
||||
if(SSAkismet::isEnabled()) {
|
||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||
|
||||
if($comment) {
|
||||
// check they have access
|
||||
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||
|
||||
if($comment) {
|
||||
// if spam protection module exists
|
||||
if(class_exists('SpamProtecterManager')) {
|
||||
SpamProtecterManager::send_feedback($comment, 'spam');
|
||||
$comment->setField('IsSpam', true);
|
||||
$comment->write();
|
||||
}
|
||||
|
||||
// If Akismet is enabled
|
||||
else 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.
|
||||
}
|
||||
|
||||
|
||||
if(SSAkismet::getSaveSpam()) {
|
||||
$comment->setField('IsSpam', true);
|
||||
$comment->write();
|
||||
} else {
|
||||
$comment->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
if(SSAkismet::getSaveSpam()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
echo '';
|
||||
}
|
||||
} else {
|
||||
Director::redirectBack();
|
||||
}
|
||||
}
|
||||
if(Director::is_ajax()) {
|
||||
if(SSAkismet::getSaveSpam()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
echo '';
|
||||
}
|
||||
} else {
|
||||
Director::redirectBack();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a Spam Comment as valid comment (not spam)
|
||||
*/
|
||||
function reportham() {
|
||||
if(SSAkismet::isEnabled()) {
|
||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||
if($comment) {
|
||||
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||
|
||||
// if spam protection module exists
|
||||
if(class_exists('SpamProtecterManager')) {
|
||||
SpamProtecterManager::send_feedback($comment, 'ham');
|
||||
$comment->setField('IsSpam', false);
|
||||
$comment->write();
|
||||
}
|
||||
|
||||
if($comment) {
|
||||
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.
|
||||
}
|
||||
|
||||
$comment->setField('IsSpam', false);
|
||||
$comment->write();
|
||||
}
|
||||
}
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
Director::redirectBack();
|
||||
}
|
||||
}
|
||||
if(Director::is_ajax()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
Director::redirectBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ class PageCommentInterface_Form extends Form {
|
||||
Cookie::set("PageCommentInterface_Name", $data['Name']);
|
||||
Cookie::set("PageCommentInterface_CommenterURL", $data['CommenterURL']);
|
||||
Cookie::set("PageCommentInterface_Comment", $data['Comment']);
|
||||
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
@ -251,10 +251,10 @@ class PageCommentInterface_Form extends Form {
|
||||
//check if spam question was right.
|
||||
if(MathSpamProtection::isEnabled()){
|
||||
if(!MathSpamProtection::correctAnswer($data['Math'])){
|
||||
if(!Director::is_ajax()) {
|
||||
Director::redirectBack();
|
||||
}
|
||||
return "spamprotectionfailed"; //used by javascript for checking if the spam question was wrong
|
||||
if(!Director::is_ajax()) {
|
||||
Director::redirectBack();
|
||||
}
|
||||
return "spamprotectionfailed"; //used by javascript for checking if the spam question was wrong
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,9 +269,16 @@ class PageCommentInterface_Form extends Form {
|
||||
|
||||
$comment = Object::create('PageComment');
|
||||
$this->saveInto($comment);
|
||||
|
||||
// Store the Session ID if needed for Spamprotection
|
||||
if($session = Session::get('mollom_user_session_id')) {
|
||||
$comment->SessionID = $session;
|
||||
Session::clear('mollom_user_session_id');
|
||||
}
|
||||
$comment->IsSpam = false;
|
||||
$comment->NeedsModeration = PageComment::moderationEnabled();
|
||||
$comment->write();
|
||||
|
||||
Cookie::set("PageCommentInterface_Comment", '');
|
||||
if(Director::is_ajax()) {
|
||||
if($comment->NeedsModeration){
|
||||
|
Loading…
Reference in New Issue
Block a user