1 | <?php |
||
29 | class IncidentsController extends AppController { |
||
30 | public $uses = array("Incident", "Notification"); |
||
31 | |||
32 | 1 | public function create() { |
|
33 | 1 | $bugReport = $this->request->input('json_decode', true); |
|
34 | 1 | $result = $this->Incidents->createIncidentFromBugReport($bugReport); |
|
35 | 1 | if (count($result) > 0 |
|
36 | 1 | && !in_array(false, $result) |
|
37 | ) { |
||
38 | $response = array( |
||
39 | 1 | "success" => true, |
|
40 | 1 | "message" => "Thank you for your submission", |
|
41 | 1 | "incident_id" => $result, // Return a list of incident ids. |
|
42 | ); |
||
43 | } else { |
||
44 | $response = array( |
||
45 | "success" => false, |
||
46 | "message" => "There was a problem with your submission.", |
||
47 | ); |
||
48 | } |
||
49 | 1 | $this->autoRender = false; |
|
50 | 1 | $this->response->header([ |
|
51 | 1 | 'Content-Type' => 'application/json', |
|
52 | 'X-Content-Type-Options' => 'nosniff' |
||
53 | ]); |
||
54 | 1 | $this->response->body(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
|
55 | 1 | return $this->response; |
|
56 | } |
||
57 | |||
58 | 1 | public function json($id) { |
|
78 | |||
79 | 1 | public function view($incidentId) { |
|
96 | } |
||
97 |