fix: [API] sightings/listSightings should also support JSON parameters, fixes #4875

pull/4939/head
iglocska 2019-07-29 16:46:02 +02:00
parent 30e7b49632
commit e60f0beff9
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 8 additions and 2 deletions

View File

@ -310,11 +310,17 @@ class SightingsController extends AppController
return $this->RestResponse->viewData($sightings, $responseType, false, true);
}
public function listSightings($id, $context = 'attribute', $org_id = false)
public function listSightings($id = false, $context = 'attribute', $org_id = false)
{
$this->loadModel('Event');
$parameters = array('id', 'context', 'org_id');
foreach ($parameters as $parameter) {
if ($this->request->is('post') && isset($this->request->data[$parameter])) {
${$parameter} = $this->request->data[$parameter];
}
}
$rawId = $id;
$id = $this->Sighting->explodeIdList($id);
$id = is_array($id) ? $id : $this->Sighting->explodeIdList($id);
if ($context === 'attribute') {
$object = $this->Event->Attribute->fetchAttributes($this->Auth->user(), array('conditions' => array('Attribute.id' => $id, 'Attribute.deleted' => 0), 'flatten' => 1));
} else {