Completed
Push — master ( b1bf62...c2fee6 )
by Damian
01:51
created

code/admin/CommentsGridFieldBulkAction.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @package comments
5
 */
6
class CommentsGridFieldBulkAction extends GridFieldBulkActionHandler {
7
8
}
9
10
/**
11
 * A {@link GridFieldBulkActionHandler} for bulk marking comments as spam
12
 *
13
 * @package comments
14
 */
15
class CommentsGridFieldBulkAction_Handlers extends CommentsGridFieldBulkAction {
16
17
	private static $allowed_actions = array(
18
		'spam',
19
		'approve',
20
	);
21
22
	private static $url_handlers = array(
23
		'spam' => 'spam',
24
		'approve' => 'approve',
25
	);
26
27
28 View Code Duplication
	public function spam(SS_HTTPRequest $request) {
0 ignored issues
show
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
		$ids = array();
30
31
		foreach($this->getRecords() as $record) {
32
			array_push($ids, $record->ID);
33
			$record->markSpam();
34
		}
35
36
		$response = new SS_HTTPResponse(Convert::raw2json(array(
37
			'done' => true,
38
			'records' => $ids
39
		)));
40
41
		$response->addHeader('Content-Type', 'text/json');
42
43
		return $response;
44
	}
45
46
47 View Code Duplication
	public function approve(SS_HTTPRequest $request) {
0 ignored issues
show
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
		$ids = array();
49
50
		foreach($this->getRecords() as $record) {
51
			array_push($ids, $record->ID);
52
			$record->markApproved();
53
		}
54
55
		$response = new SS_HTTPResponse(Convert::raw2json(array(
56
			'done' => true,
57
			'records' => $ids
58
		)));
59
60
		$response->addHeader('Content-Type', 'text/json');
61
62
		return $response;
63
	}
64
}