From 5dc761ea7bbc99ddaeebb5b9d612b921bef28186 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Thu, 26 Jul 2018 12:10:57 +0200 Subject: [PATCH] chg: [stix2 export] Using the RestResponse view call instead of having view files --- app/Controller/EventsController.php | 7 ++++--- app/View/Events/json/stix2.ctp | 2 -- app/View/Events/stix2.ctp | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 app/View/Events/json/stix2.ctp delete mode 100644 app/View/Events/stix2.ctp diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index 6e3ab6371..0e0989b97 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -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'])); } diff --git a/app/View/Events/json/stix2.ctp b/app/View/Events/json/stix2.ctp deleted file mode 100644 index 9e0ef9858..000000000 --- a/app/View/Events/json/stix2.ctp +++ /dev/null @@ -1,2 +0,0 @@ -