| @@ 21-38 (lines=18) @@ | ||
| 18 | * @param HTTPRequest $request |
|
| 19 | * @return HTTPResponse |
|
| 20 | */ |
|
| 21 | public function index(HTTPRequest $request) |
|
| 22 | { |
|
| 23 | $ids = []; |
|
| 24 | ||
| 25 | foreach ($this->getRecords() as $comment) { |
|
| 26 | array_push($ids, $comment->ID); |
|
| 27 | $this->updateComment($comment); |
|
| 28 | } |
|
| 29 | ||
| 30 | $response = new HTTPResponse(Convert::raw2json([ |
|
| 31 | 'done' => true, |
|
| 32 | 'records' => $ids, |
|
| 33 | ])); |
|
| 34 | ||
| 35 | $response->addHeader('Content-Type', 'application/json'); |
|
| 36 | ||
| 37 | return $response; |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @param Comment $comment |
|
| @@ 31-48 (lines=18) @@ | ||
| 28 | * @param HTTPRequest $request |
|
| 29 | * @return HTTPResponse |
|
| 30 | */ |
|
| 31 | public function spam(HTTPRequest $request) |
|
| 32 | { |
|
| 33 | $ids = array(); |
|
| 34 | ||
| 35 | foreach ($this->getRecords() as $record) { |
|
| 36 | array_push($ids, $record->ID); |
|
| 37 | $record->markSpam(); |
|
| 38 | } |
|
| 39 | ||
| 40 | $response = new HTTPResponse(Convert::raw2json(array( |
|
| 41 | 'done' => true, |
|
| 42 | 'records' => $ids |
|
| 43 | ))); |
|
| 44 | ||
| 45 | $response->addHeader('Content-Type', 'text/json'); |
|
| 46 | ||
| 47 | return $response; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @param HTTPRequest $request |
|
| @@ 54-71 (lines=18) @@ | ||
| 51 | * @param HTTPRequest $request |
|
| 52 | * @return HTTPResponse |
|
| 53 | */ |
|
| 54 | public function approve(HTTPRequest $request) |
|
| 55 | { |
|
| 56 | $ids = array(); |
|
| 57 | ||
| 58 | foreach ($this->getRecords() as $record) { |
|
| 59 | array_push($ids, $record->ID); |
|
| 60 | $record->markApproved(); |
|
| 61 | } |
|
| 62 | ||
| 63 | $response = new HTTPResponse(Convert::raw2json(array( |
|
| 64 | 'done' => true, |
|
| 65 | 'records' => $ids |
|
| 66 | ))); |
|
| 67 | ||
| 68 | $response->addHeader('Content-Type', 'text/json'); |
|
| 69 | ||
| 70 | return $response; |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||