From cf5cda9799161566f3e6aa7e121d1768623894bd Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 9 Aug 2007 23:19:20 +0000 Subject: [PATCH] Spam, ham and accepting of marked comments git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@39807 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/FeedbackAdmin.php | 98 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/code/FeedbackAdmin.php b/code/FeedbackAdmin.php index 24d64b9a..c4c08a69 100644 --- a/code/FeedbackAdmin.php +++ b/code/FeedbackAdmin.php @@ -46,15 +46,27 @@ class FeedbackAdmin extends LeftAndMain { new TextareaField("Comment", "Comment") ); - $idField = new HiddenField('ID'); + $idField = new HiddenField('ID', '', $section); $table = new CommentTableField($this, "Comments", "PageComment", $section, $tableFields, $popupFields, $filter); $table->setParentClass(false); $fields = new FieldSet($idField, $table); - $actions = new FieldSet( - new FormAction('deletemarked', 'Delete') - ); + $actions = new FieldSet(); + + if($section == 'unmoderated') { + $actions->push(new FormAction('acceptmarked', 'Accept')); + } + + if($section == 'accepted' || $section == 'unmoderated') { + $actions->push(new FormAction('spammarked', 'Mark as spam')); + } + + if($section == 'spam') { + $actions->push(new FormAction('hammarked', 'Mark as not spam')); + } + + $actions->push(new FormAction('deletemarked', 'Delete')); $form = new Form($this, "EditForm", $fields, $actions); @@ -82,6 +94,84 @@ class FeedbackAdmin extends LeftAndMain { $deleteList $('Form_EditForm').getPageFromServer($('Form_EditForm_ID').value); statusMessage("Deleted $numComments comments."); +JS; + } + + function spammarked() { + $numComments = 0; + $folderID = 0; + $deleteList = ''; + + if($_REQUEST['Comments']) { + foreach($_REQUEST['Comments'] as $commentid) { + $comment = DataObject::get_one('PageComment', "`PageComment`.ID = $commentid"); + if($comment) { + $comment->IsSpam = true; + $comment->NeedsModeration = false; + $comment->write(); + $numComments++; + } + } + } else { + user_error("No comments in $commentList could be found!", E_USER_ERROR); + } + + echo <<IsSpam = false; + $comment->NeedsModeration = false; + $comment->write(); + $numComments++; + } + } + } else { + user_error("No comments in $commentList could be found!", E_USER_ERROR); + } + + echo <<IsSpam = false; + $comment->NeedsModeration = false; + $comment->write(); + $numComments++; + } + } + } else { + user_error("No comments in $commentList could be found!", E_USER_ERROR); + } + + echo <<