MINOR: merged patch from keeny. Put comment data into Cookie and load if user fails maths spam question. Clear comment cookie on successful posting

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@70530 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2009-01-21 02:43:39 +00:00 committed by Sam Minnee
parent deb84a5c5a
commit fe4e18bc0e
2 changed files with 8 additions and 17 deletions

View File

@ -137,6 +137,8 @@ class PageCommentInterface extends RequestHandler {
$form->loadDataFrom(array(
"Name" => Cookie::get("PageCommentInterface_Name"),
"Comment" => Cookie::get("PageCommentInterface_Comment"),
"URL" => Cookie::get("PageCommentInterface_CommenterURL")
));
return $form;
@ -177,6 +179,10 @@ class PageCommentInterface extends RequestHandler {
class PageCommentInterface_Form extends Form {
function postcomment($data) {
// Spam filtering
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();
@ -212,7 +218,6 @@ class PageCommentInterface_Form extends Form {
return "spamprotectionfailed"; //used by javascript for checking if the spam question was wrong
}
}
Cookie::set("PageCommentInterface_Name", $data['Name']);
// If commenting can only be done by logged in users, make sure the user is logged in
$member = Member::currentUser();
@ -228,7 +233,7 @@ class PageCommentInterface_Form extends Form {
$comment->IsSpam = false;
$comment->NeedsModeration = PageComment::moderationEnabled();
$comment->write();
Cookie::set("PageCommentInterface_Comment", '');
if(Director::is_ajax()) {
if($comment->NeedsModeration){
echo _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awaiting moderation.");

View File

@ -96,24 +96,10 @@ PageCommentInterface.prototype = {
onFailure : function(response) {
alert(response.responseText);
}
});
// Clear the fields
// form.elements.Name.value = "";
form.elements.Comment.value = "";
} else {
message.style.display = '';
message.innerHTML = "Please enter your name and a comment to be posted to the site.";
message.innerHTML = "Please enter your name and a comment to be posted to the site.";
}
return false;