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