diff --git a/app/Controller/SightingsController.php b/app/Controller/SightingsController.php index e4d395e82..ac1ea801b 100644 --- a/app/Controller/SightingsController.php +++ b/app/Controller/SightingsController.php @@ -244,12 +244,11 @@ class SightingsController extends AppController throw new MethodNotAllowedException(_('An id must be provided if the context is set.')); } - $sightings = $this->Sighting->getSightingsForTime($this->Auth->user(), $returnFormat, $filters); + $sightings = $this->Sighting->restSearch($this->Auth->user(), $returnFormat, $filters); $validFormats = $this->Sighting->validFormats; $responseType = $validFormats[$returnFormat][0]; return $this->RestResponse->viewData($sightings, $responseType, false, true); - //return $this->RestResponse->viewData($sightings); } public function listSightings($id, $context = 'attribute', $org_id = false) diff --git a/app/Lib/Export/CsvExport.php b/app/Lib/Export/CsvExport.php index 684b60945..c4ee1afd4 100644 --- a/app/Lib/Export/CsvExport.php +++ b/app/Lib/Export/CsvExport.php @@ -48,8 +48,8 @@ class CsvExport return $this->__addLine($attribute, $options); } - private function __sightingsHandler($sighting, $options) - { + private function __sightingsHandler($sighting, $options) + { $lines = ''; if (isset($sighting['Sighting']['Event'])) { foreach($sighting['Sighting']['Event'] as $k => $event_val) { diff --git a/app/Lib/Export/JsonExport.php b/app/Lib/Export/JsonExport.php index 947ebe6d8..5e731a67b 100644 --- a/app/Lib/Export/JsonExport.php +++ b/app/Lib/Export/JsonExport.php @@ -9,8 +9,10 @@ class JsonExport { if ($options['scope'] === 'Attribute') { return $this->__attributeHandler($data, $options); - } else { + } else if($options['scope'] === 'Event') { return $this->__eventHandler($data, $options); + } else if($options['scope'] === 'Sighting') { + return $this->__sightingsHandler($data, $options); } } @@ -47,6 +49,11 @@ class JsonExport return json_encode($attribute); } + private function __sightingsHandler($sighting, $options = array()) + { + return json_encode($sighting); + } + public function header($options = array()) { if ($options['scope'] === 'Attribute') { diff --git a/app/Model/Sighting.php b/app/Model/Sighting.php index ec0e5612e..1c298db46 100644 --- a/app/Model/Sighting.php +++ b/app/Model/Sighting.php @@ -463,7 +463,7 @@ class Sighting extends AppModel return $sightingsRearranged; } - public function getSightingsForTime($user, $returnFormat, $filters) + public function restSearch($user, $returnFormat, $filters) { if (!isset($this->validFormats[$returnFormat][1])) { throw new NotFoundException('Invalid output format.');