getLastFormIn($this->renderWith('FeedbackAdmin_right')); } 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') { $section = 'accepted'; } if($section == 'accepted') { $filter = 'IsSpam=0 AND NeedsModeration=0'; $title = "

Accepted Comments

"; } else if($section == 'unmoderated') { $filter = 'NeedsModeration=1'; $title = "

Comments Awaiting Moderation

"; } else { $filter = 'IsSpam=1'; $title = "

Spam

"; } $tableFields = array( "Name" => "Author", "Comment" => "Comment", "PageTitle" => "Page", "Created" => "Date Posted" ); $popupFields = new FieldSet( new TextField("Name"), new TextareaField("Comment", "Comment") ); $idField = new HiddenField('ID', '', $section); $table = new CommentTableField($this, "Comments", "PageComment", $section, $tableFields, $popupFields, array($filter)); $table->setParentClass(false); $fields = new FieldSet(new LiteralField("Title", $title), $idField, $table); $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); 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 <<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 <<