chg: [stix2 export] Using the RestResponse view call instead of having view files

pull/3707/head
chrisr3d 2018-07-26 12:10:57 +02:00
parent 7d0ca20476
commit 5dc761ea7b
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
3 changed files with 4 additions and 7 deletions

View File

@ -4033,11 +4033,12 @@ class EventsController extends AppController
$result = $this->Event->stix2($id, $tags, $withAttachments, $this->Auth->user(), 'json', $from, $to, $last);
if ($result['success'] == 1) {
if ($numeric) {
$this->header('Content-Disposition: download; filename="misp.stix2.event' . $id . '.json"');
$filename = 'misp.stix2.event' . $id . '.json'
} else {
$this->header('Content-Disposition: download; filename="misp.stix2.event.collection.json"');
$filename = 'misp.stix2.event.collection.json'
}
$this->set('data', $result['data']);
$this->header('Content-Disposition: download; filename="' . $filename . '"');
return $this->RestResponse->viewData($result['data'], 'application/json', false, true, $filename);
} else {
throw new Exception(h($result['message']));
}

View File

@ -1,2 +0,0 @@
<?php
echo $data;

View File

@ -1,2 +0,0 @@
<?php
echo $data;