mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
1900ab14b5
Enable comment moderation per-page
46 lines
865 B
PHP
46 lines
865 B
PHP
<?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;
|
|
}
|
|
} |