mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
NEW: Add BulkEditing tool for managing comments. (Fixes #9)
This commit is contained in:
parent
5cfa476264
commit
5f6336646a
@ -46,7 +46,17 @@ class CommentAdmin extends LeftAndMain {
|
|||||||
new GridFieldDetailForm(),
|
new GridFieldDetailForm(),
|
||||||
new GridFieldExportButton(),
|
new GridFieldExportButton(),
|
||||||
new GridFieldEditButton(),
|
new GridFieldEditButton(),
|
||||||
new GridFieldDetailForm()
|
new GridFieldDetailForm(),
|
||||||
|
$manager = new GridFieldBulkManager()
|
||||||
|
);
|
||||||
|
|
||||||
|
$manager->addBulkAction(
|
||||||
|
'markAsSpam', 'Mark as spam', 'CommentsGridFieldBulkAction_MarkAsSpam',
|
||||||
|
array(
|
||||||
|
'isAjax' => true,
|
||||||
|
'icon' => 'delete',
|
||||||
|
'isDestructive' => true
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$needs = new GridField(
|
$needs = new GridField(
|
||||||
|
46
code/CommentsGridFieldBulkAction.php
Normal file
46
code/CommentsGridFieldBulkAction.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package comments
|
||||||
|
*/
|
||||||
|
class CommentsGridFieldBulkAction extends GridFieldBulkActionHandler {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GridFieldBulkActionHandler} for bulk marking comments as spam
|
||||||
|
*
|
||||||
|
* @package comments
|
||||||
|
*/
|
||||||
|
class CommentsGridFieldBulkAction_MarkAsSpam extends CommentsGridFieldBulkAction {
|
||||||
|
|
||||||
|
private static $allowed_actions = array(
|
||||||
|
'markAsSpam'
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $url_handlers = array(
|
||||||
|
'markAsSpam' => 'markAsSpam'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public function markAsSpam(SS_HTTPRequest $request) {
|
||||||
|
$ids = array();
|
||||||
|
|
||||||
|
foreach($this->getRecords() as $record) {
|
||||||
|
array_push($ids, $record->ID);
|
||||||
|
|
||||||
|
$record->Moderated = 1;
|
||||||
|
$record->IsSpam = 1;
|
||||||
|
$record->write();
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new SS_HTTPResponse(Convert::raw2json(array(
|
||||||
|
'done' => true,
|
||||||
|
'records' => $ids
|
||||||
|
)));
|
||||||
|
|
||||||
|
$response->addHeader('Content-Type', 'text/json');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,8 @@
|
|||||||
"email": "will@fullscreen.io"
|
"email": "will@fullscreen.io"
|
||||||
}],
|
}],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "~3.1"
|
"silverstripe/framework": "~3.1",
|
||||||
|
"colymba/gridfield-bulk-editing-tools": "dev-master"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ezyang/htmlpurifier": "4.*"
|
"ezyang/htmlpurifier": "4.*"
|
||||||
|
Loading…
Reference in New Issue
Block a user