2007-08-08 03:16:02 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class FeedbackAdmin extends LeftAndMain {
|
|
|
|
|
|
|
|
public function init() {
|
|
|
|
parent::init();
|
|
|
|
|
|
|
|
Requirements::javascript("cms/javascript/FeedbackAdmin_right.js");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Link($action = null) {
|
|
|
|
return "admin/feedback/$action";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function showtable($params) {
|
|
|
|
return $this->getLastFormIn($this->renderWith('FeedbackAdmin_right'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function EditForm() {
|
|
|
|
$url = rtrim($_SERVER['REQUEST_URI'], '/');
|
2007-08-10 00:59:20 +02:00
|
|
|
if(strrpos($url, '&')) {
|
|
|
|
$url = substr($url, 0, strrpos($url, '&'));
|
|
|
|
}
|
2007-08-08 03:16:02 +02:00
|
|
|
$section = substr($url, strrpos($url, '/') + 1);
|
|
|
|
|
|
|
|
if($section != 'accepted' && $section != 'unmoderated' && $section != 'spam') {
|
|
|
|
$section = 'accepted';
|
|
|
|
}
|
|
|
|
|
|
|
|
if($section == 'accepted') {
|
|
|
|
$filter = 'IsSpam=0 AND NeedsModeration=0';
|
2007-08-08 08:00:20 +02:00
|
|
|
} else if($section == 'unmoderated') {
|
2007-08-08 03:16:02 +02:00
|
|
|
$filter = 'NeedsModeration=1';
|
|
|
|
} else {
|
|
|
|
$filter = 'IsSpam=1';
|
|
|
|
}
|
|
|
|
|
2007-08-08 05:59:50 +02:00
|
|
|
$tableFields = array(
|
2007-08-08 08:00:20 +02:00
|
|
|
"Name" => "Author",
|
2007-08-08 05:59:50 +02:00
|
|
|
"Comment" => "Comment",
|
|
|
|
"PageTitle" => "Page"
|
|
|
|
);
|
|
|
|
|
2007-08-08 08:00:20 +02:00
|
|
|
$popupFields = new FieldSet(
|
|
|
|
new TextField("Name"),
|
|
|
|
new TextareaField("Comment", "Comment")
|
|
|
|
);
|
|
|
|
|
2007-08-08 03:16:02 +02:00
|
|
|
$idField = new HiddenField('ID');
|
2007-08-08 08:00:20 +02:00
|
|
|
$table = new CommentTableField($this, "Comments", "PageComment", $section, $tableFields, $popupFields, $filter);
|
|
|
|
$table->setParentClass(false);
|
2007-08-08 03:16:02 +02:00
|
|
|
|
|
|
|
$fields = new FieldSet($idField, $table);
|
2007-08-10 00:59:20 +02:00
|
|
|
|
|
|
|
$actions = new FieldSet(
|
|
|
|
new FormAction('deletemarked', 'Delete')
|
|
|
|
);
|
|
|
|
|
2007-08-08 03:16:02 +02:00
|
|
|
$form = new Form($this, "EditForm", $fields, $actions);
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
}
|
2007-08-10 00:59:20 +02:00
|
|
|
|
|
|
|
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 <<<JS
|
|
|
|
$deleteList
|
|
|
|
$('Form_EditForm').getPageFromServer($('Form_EditForm_ID').value);
|
|
|
|
statusMessage("Deleted $numComments comments.");
|
|
|
|
JS;
|
|
|
|
}
|
2007-08-08 03:16:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|