From 4cbc4642b6d1565172c864604fa061b8aa7d816c Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 9 Aug 2007 22:59:20 +0000 Subject: [PATCH] Added deleting of marked comments git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@39805 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/FeedbackAdmin.php | 33 ++++++++++++++++++++++- javascript/FeedbackAdmin_right.js | 7 +++-- templates/Includes/FeedbackAdmin_right.ss | 3 +++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/code/FeedbackAdmin.php b/code/FeedbackAdmin.php index 7fcffc6b..24d64b9a 100644 --- a/code/FeedbackAdmin.php +++ b/code/FeedbackAdmin.php @@ -18,6 +18,9 @@ class FeedbackAdmin extends LeftAndMain { public function EditForm() { $url = rtrim($_SERVER['REQUEST_URI'], '/'); + if(strrpos($url, '&')) { + $url = substr($url, 0, strrpos($url, '&')); + } $section = substr($url, strrpos($url, '/') + 1); if($section != 'accepted' && $section != 'unmoderated' && $section != 'spam') { @@ -48,11 +51,39 @@ class FeedbackAdmin extends LeftAndMain { $table->setParentClass(false); $fields = new FieldSet($idField, $table); - $actions = new FieldSet(); + + $actions = new FieldSet( + new FormAction('deletemarked', 'Delete') + ); + $form = new Form($this, "EditForm", $fields, $actions); return $form; } + + function deletemarked() { + $numComments = 0; + $folderID = 0; + $deleteList = ''; + + if($_REQUEST['Comments']) { + foreach($_REQUEST['Comments'] as $commentid) { + $comment = DataObject::get_one('PageComment', "`PageComment`.ID = $commentid"); + if($comment) { + $comment->delete(); + $numComments++; + } + } + } else { + user_error("No comments in $commentList could be found!", E_USER_ERROR); + } + + echo << \ No newline at end of file diff --git a/javascript/FeedbackAdmin_right.js b/javascript/FeedbackAdmin_right.js index 8a97178d..8cf265a3 100644 --- a/javascript/FeedbackAdmin_right.js +++ b/javascript/FeedbackAdmin_right.js @@ -4,7 +4,10 @@ Behaviour.register({ statusMessage("loading..."); var requestURL = 'admin/feedback/showtable/' + id; - new Ajax.Request(requestURL, { + + this.loadURLFromServer(requestURL); + + /*new Ajax.Request(requestURL, { asynchronous : true, method : 'post', postBody : 'ajax=1', @@ -12,7 +15,7 @@ Behaviour.register({ onFailure : function(response) { errorMessage('error loading page',response); } - }); + });*/ } } }); \ No newline at end of file diff --git a/templates/Includes/FeedbackAdmin_right.ss b/templates/Includes/FeedbackAdmin_right.ss index 5e7bcaef..937f95da 100644 --- a/templates/Includes/FeedbackAdmin_right.ss +++ b/templates/Includes/FeedbackAdmin_right.ss @@ -1,5 +1,8 @@
Feedback Management
+
+
+ <% if EditForm %> $EditForm <% else %>