2013-12-21 00:19:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package comments
|
|
|
|
*/
|
|
|
|
class CommentsGridFieldBulkAction extends GridFieldBulkActionHandler {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A {@link GridFieldBulkActionHandler} for bulk marking comments as spam
|
|
|
|
*
|
|
|
|
* @package comments
|
|
|
|
*/
|
2015-04-13 05:41:18 +02:00
|
|
|
class CommentsGridFieldBulkAction_Handlers extends CommentsGridFieldBulkAction {
|
2013-12-21 00:19:11 +01:00
|
|
|
|
|
|
|
private static $allowed_actions = array(
|
2015-04-13 05:41:18 +02:00
|
|
|
'markAsSpam',
|
|
|
|
'markAsNotSpam',
|
2013-12-21 00:19:11 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
private static $url_handlers = array(
|
2015-04-13 05:41:18 +02:00
|
|
|
'markAsSpam' => 'markAsSpam',
|
|
|
|
'markAsNotSpam' => 'markAsNotSpam',
|
2013-12-21 00:19:11 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2015-04-13 05:41:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
public function markAsNotSpam(SS_HTTPRequest $request) {
|
|
|
|
$ids = array();
|
|
|
|
|
|
|
|
foreach($this->getRecords() as $record) {
|
|
|
|
array_push($ids, $record->ID);
|
|
|
|
|
|
|
|
$record->Moderated = 1;
|
|
|
|
$record->IsSpam = 0;
|
|
|
|
$record->write();
|
|
|
|
}
|
|
|
|
|
|
|
|
$response = new SS_HTTPResponse(Convert::raw2json(array(
|
|
|
|
'done' => true,
|
|
|
|
'records' => $ids
|
|
|
|
)));
|
|
|
|
|
|
|
|
$response->addHeader('Content-Type', 'text/json');
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
}
|
2013-12-21 00:19:11 +01:00
|
|
|
}
|