mirror of https://github.com/MISP/MISP
Merge pull request #7456 from righel/fix-mysql-error-index-sightings-by-event-id
Fix mysql error index sightings by eventpull/7468/head
commit
686afcad2e
|
@ -15,9 +15,9 @@ class SightingsController extends AppController
|
|||
}
|
||||
|
||||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user van view/page.
|
||||
'order' => array('Sighting.date_sighting' => 'DESC'),
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user van view/page.
|
||||
'order' => array('Sighting.date_sighting' => 'DESC'),
|
||||
);
|
||||
|
||||
// takes an attribute ID or UUID
|
||||
|
@ -78,9 +78,9 @@ class SightingsController extends AppController
|
|||
if ($this->request->is('ajax')) {
|
||||
if ($error) {
|
||||
$error_message = 'Could not add the Sighting. Reason: ' . $error;
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => $error_message)), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => false, 'errors' => $error_message)), 'status' => 200, 'type' => 'json'));
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => $result . ' ' . $this->Sighting->type[$type] . (($result == 1) ? '' : 's') . ' added.')), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'success' => $result . ' ' . $this->Sighting->type[$type] . (($result == 1) ? '' : 's') . ' added.')), 'status' => 200, 'type' => 'json'));
|
||||
}
|
||||
} else {
|
||||
if ($error) {
|
||||
|
@ -147,7 +147,7 @@ class SightingsController extends AppController
|
|||
$this->render('/Sightings/ajax/advanced');
|
||||
}
|
||||
|
||||
public function quickAdd($id=false, $type=1, $onvalue=false)
|
||||
public function quickAdd($id = false, $type = 1, $onvalue = false)
|
||||
{
|
||||
if (!$this->userRole['perm_modify_org']) {
|
||||
throw new MethodNotAllowedException(__('You are not authorised to remove sightings data as you don\'t have permission to modify your organisation\'s data.'));
|
||||
|
@ -174,7 +174,7 @@ class SightingsController extends AppController
|
|||
}
|
||||
} else {
|
||||
if (!isset($id)) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'errors' => __('Invalid request.'))), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'errors' => __('Invalid request.'))), 'status' => 200, 'type' => 'json'));
|
||||
} else {
|
||||
if ($onvalue) {
|
||||
$result = $this->Sighting->add();
|
||||
|
@ -183,9 +183,9 @@ class SightingsController extends AppController
|
|||
}
|
||||
|
||||
if ($result) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => __('Sighting added.'))), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'success' => __('Sighting added.'))), 'status' => 200, 'type' => 'json'));
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'errors' => __('Sighting could not be added'))), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'errors' => __('Sighting could not be added'))), 'status' => 200, 'type' => 'json'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,20 +204,20 @@ class SightingsController extends AppController
|
|||
$this->render('ajax/quickDeleteConfirmationForm');
|
||||
} else {
|
||||
if (!isset($id)) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'errors' => 'Invalid request.')), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'errors' => 'Invalid request.')), 'status' => 200, 'type' => 'json'));
|
||||
} else {
|
||||
$sighting = $this->Sighting->find('first', array('conditions' => array('Sighting.id' => $id), 'recursive' => -1));
|
||||
if (empty($sighting)) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'errors' => 'Invalid sighting.')), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'errors' => 'Invalid sighting.')), 'status' => 200, 'type' => 'json'));
|
||||
}
|
||||
if (!$this->_isSiteAdmin() && $sighting['Sighting']['org_id'] != $this->Auth->user('org_id')) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'errors' => 'Invalid sighting.')), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'errors' => 'Invalid sighting.')), 'status' => 200, 'type' => 'json'));
|
||||
}
|
||||
$result = $this->Sighting->delete($id);
|
||||
if ($result) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Sighting deleted.')), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'success' => 'Sighting deleted.')), 'status' => 200, 'type' => 'json'));
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'errors' => 'Sighting could not be deleted')), 'status' => 200, 'type' => 'json'));
|
||||
return new CakeResponse(array('body' => json_encode(array('saved' => true, 'errors' => 'Sighting could not be deleted')), 'status' => 200, 'type' => 'json'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ class SightingsController extends AppController
|
|||
$sightingConditions = array('Sighting.event_id' => $eventid);
|
||||
}
|
||||
$sightedEvents = $this->Sighting->find('list', array(
|
||||
'group' => 'Sighting.event_id',
|
||||
'group' => ['Sighting.id', 'Sighting.event_id'],
|
||||
'fields' => array('Sighting.event_id'),
|
||||
'conditions' => $sightingConditions
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue