mirror of https://github.com/MISP/MISP
chg: [galaxyCluster:view] Arrange data before exporting
parent
be7ef90366
commit
79d3a47e5a
|
@ -243,6 +243,9 @@ class GalaxiesController extends AppController
|
||||||
);
|
);
|
||||||
$clusters = $this->Galaxy->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(),$options, $full=true);
|
$clusters = $this->Galaxy->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(),$options, $full=true);
|
||||||
$clusters = $this->Galaxy->GalaxyCluster->unsetFieldsForExport($clusters);
|
$clusters = $this->Galaxy->GalaxyCluster->unsetFieldsForExport($clusters);
|
||||||
|
foreach ($clusters as $k => $cluster) {
|
||||||
|
$clusters[$k] = $this->Galaxy->GalaxyCluster->arrangeDataForExport($cluster);
|
||||||
|
}
|
||||||
$content = json_encode($clusters, JSON_PRETTY_PRINT);
|
$content = json_encode($clusters, JSON_PRETTY_PRINT);
|
||||||
$this->response->body($content);
|
$this->response->body($content);
|
||||||
if ($this->request->data['download'] == 'download') {
|
if ($this->request->data['download'] == 'download') {
|
||||||
|
|
|
@ -206,13 +206,8 @@ class GalaxyClustersController extends AppController
|
||||||
throw new NotFoundException('Cluster not found.');
|
throw new NotFoundException('Cluster not found.');
|
||||||
}
|
}
|
||||||
if ($this->_isRest()) {
|
if ($this->_isRest()) {
|
||||||
$models = array('Galaxy', 'GalaxyElement', 'GalaxyClusterRelation', 'Org', 'Orgc', 'TargettingClusterRelation');
|
$cluster = $this->GalaxyCluster->arrangeDataForExport($cluster);
|
||||||
foreach ($models as $model) {
|
|
||||||
$cluster['GalaxyCluster'][$model] = $cluster[$model];
|
|
||||||
unset($cluster[$model]);
|
|
||||||
}
|
|
||||||
return $this->RestResponse->viewData($cluster, $this->response->type());
|
return $this->RestResponse->viewData($cluster, $this->response->type());
|
||||||
// return $this->RestResponse->viewData(array('GalaxyCluster' => $cluster['GalaxyCluster']), $this->response->type());
|
|
||||||
} else {
|
} else {
|
||||||
$cluster = $this->GalaxyCluster->attachExtendByInfo($this->Auth->user(), $cluster);
|
$cluster = $this->GalaxyCluster->attachExtendByInfo($this->Auth->user(), $cluster);
|
||||||
$cluster = $this->GalaxyCluster->attachExtendFromInfo($this->Auth->user(), $cluster);
|
$cluster = $this->GalaxyCluster->attachExtendFromInfo($this->Auth->user(), $cluster);
|
||||||
|
|
|
@ -156,6 +156,16 @@ class GalaxyCluster extends AppModel
|
||||||
$this->GalaxyClusterRelation->deleteAll(array('GalaxyClusterRelation.galaxy_cluster_uuid' => $this->uuid));
|
$this->GalaxyClusterRelation->deleteAll(array('GalaxyClusterRelation.galaxy_cluster_uuid' => $this->uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function arrangeDataForExport($cluster)
|
||||||
|
{
|
||||||
|
$models = array('Galaxy', 'GalaxyElement', 'GalaxyClusterRelation', 'Org', 'Orgc', 'TargettingClusterRelation');
|
||||||
|
foreach ($models as $model) {
|
||||||
|
$cluster['GalaxyCluster'][$model] = $cluster[$model];
|
||||||
|
unset($cluster[$model]);
|
||||||
|
}
|
||||||
|
return $cluster;
|
||||||
|
}
|
||||||
|
|
||||||
// Respecting ACL, save a cluster, its elements and set correct fields
|
// Respecting ACL, save a cluster, its elements and set correct fields
|
||||||
public function saveCluster($user, $cluster, $allowEdit=false)
|
public function saveCluster($user, $cluster, $allowEdit=false)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue