ENHANCEMENT: allow PageCommentForm to store all users data, rather than hardcoding the fields

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@111449 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2010-09-30 22:31:01 +00:00 committed by Sam Minnee
parent b76b6f61d2
commit 4cc09f2a39

View File

@ -214,15 +214,14 @@ class PageCommentInterface extends RequestHandler {
Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js'); Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js');
} }
// Load the data from Session
$form->loadDataFrom(array(
"Name" => Cookie::get("PageCommentInterface_Name"),
"Comment" => Cookie::get("PageCommentInterface_Comment"),
"CommenterURL" => Cookie::get("PageCommentInterface_CommenterURL")
));
$this->extend('updatePageCommentForm', $form); $this->extend('updatePageCommentForm', $form);
// Load the users data from a cookie
if($cookie = Cookie::get("PageCommentInterface_Data")) {
Debug::show(unserialize($cookie));
$form->loadDataFrom(unserialize($cookie));
}
return $form; return $form;
} }
@ -269,11 +268,10 @@ class PageCommentInterface extends RequestHandler {
*/ */
class PageCommentInterface_Form extends Form { class PageCommentInterface_Form extends Form {
function postcomment($data) { function postcomment($data) {
// Spam filtering Debug::show($data);
Cookie::set("PageCommentInterface_Name", $data['Name']); Cookie::set("PageCommentInterface_Data", serialize($data));
Cookie::set("PageCommentInterface_CommenterURL", $data['CommenterURL']);
Cookie::set("PageCommentInterface_Comment", $data['Comment']);
// Spam filtering
if(SSAkismet::isEnabled()) { if(SSAkismet::isEnabled()) {
try { try {
$akismet = new SSAkismet(); $akismet = new SSAkismet();
@ -331,7 +329,8 @@ class PageCommentInterface_Form extends Form {
$comment->NeedsModeration = PageComment::moderationEnabled(); $comment->NeedsModeration = PageComment::moderationEnabled();
$comment->write(); $comment->write();
Cookie::set("PageCommentInterface_Comment", ''); unset($data['Comment']);
Cookie::set("PageCommentInterface_Data", serialize($data));
$moderationMsg = _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awaiting moderation."); $moderationMsg = _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awaiting moderation.");