mirror of https://github.com/MISP/MISP
fix: [galaxyCluster] Recursive conditions on grandparent model
parent
7d3748f403
commit
780957518d
|
@ -206,7 +206,7 @@ class GalaxyClustersController extends AppController
|
|||
$this->loadModel('Attribute');
|
||||
$distributionLevels = $this->Attribute->distributionLevels;
|
||||
$this->set('distributionLevels', $distributionLevels);
|
||||
if (!$cluster['GalaxyCluster']['default'] && !$cluster['GalaxyCluster']['published']) {
|
||||
if (!$cluster['GalaxyCluster']['default'] && !$cluster['GalaxyCluster']['published'] && $cluster['GalaxyCluster']['orgc_id'] == $this->Auth->user()['org_id']) {
|
||||
$this->Flash->warning(__('This cluster is not published. Users will not be able to use it'));
|
||||
}
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ class GalaxyClustersController extends AppController
|
|||
'conditions' => array(
|
||||
'GalaxyClusterRelation.galaxy_cluster_uuid' => $cluster['GalaxyCluster']['uuid']
|
||||
),
|
||||
'contain' => array('SharingGroup', 'TargetCluster', 'GalaxyClusterRelationTag' => array('Tag'))
|
||||
'contain' => array('SharingGroup', 'SourceCluster', 'TargetCluster', 'GalaxyClusterRelationTag' => array('Tag'))
|
||||
));
|
||||
$this->set('relations', $relations);
|
||||
$this->set('tree', $tree);
|
||||
|
|
|
@ -930,14 +930,9 @@ class GalaxyCluster extends AppModel
|
|||
'Galaxy',
|
||||
'GalaxyElement',
|
||||
'GalaxyClusterRelation' => array(
|
||||
'conditions' => $this->GalaxyClusterRelation->buildConditions($user),
|
||||
'conditions' => $this->GalaxyClusterRelation->buildConditions($user, false),
|
||||
'GalaxyClusterRelationTag' => array('Tag'),
|
||||
'SharingGroup'
|
||||
),
|
||||
'TargetingClusterRelation' => array(
|
||||
'conditions' => $this->TargetingClusterRelation->buildConditions($user),
|
||||
'GalaxyClusterRelationTag' => array('Tag'),
|
||||
'SharingGroup'
|
||||
'SharingGroup',
|
||||
),
|
||||
'Orgc',
|
||||
'Org',
|
||||
|
@ -987,6 +982,28 @@ class GalaxyCluster extends AppModel
|
|||
}
|
||||
}
|
||||
}
|
||||
if (isset($cluster['GalaxyCluster'])) {
|
||||
$targetingClusterRelations = $this->TargetingClusterRelation->fetchRelations($user, array(
|
||||
'contain' => array(
|
||||
'GalaxyClusterRelationTag' => array('Tag'),
|
||||
'SharingGroup',
|
||||
'SourceCluster',
|
||||
),
|
||||
'conditions' => array(
|
||||
'TargetingClusterRelation.referenced_galaxy_cluster_id' => $cluster['GalaxyCluster']['id']
|
||||
)
|
||||
));
|
||||
foreach ($targetingClusterRelations as $k => $targetingClusterRelation) {
|
||||
if (!empty($targetingClusterRelation['GalaxyClusterRelationTag'])) {
|
||||
$targetingClusterRelation['TargetingClusterRelation']['Tag'] = Hash::extract($targetingClusterRelation['GalaxyClusterRelationTag'], '{n}.Tag');
|
||||
}
|
||||
if (!empty($targetingClusterRelation['SharingGroup']['id'])) {
|
||||
$targetingClusterRelation['TargetingClusterRelation']['SharingGroup'] = $TargetingClusterRelation['SharingGroup'];
|
||||
}
|
||||
$targetingClusterRelations[$k] = $targetingClusterRelation['TargetingClusterRelation'];
|
||||
}
|
||||
$clusters[$i]['TargetingClusterRelation'] = $targetingClusterRelations;
|
||||
}
|
||||
$clusters[$i] = $this->arrangeData($clusters[$i]);
|
||||
$clusters[$i] = $this->GalaxyClusterRelation->massageRelationTag($clusters[$i]);
|
||||
$clusters[$i] = $this->TargetingClusterRelation->massageRelationTag($clusters[$i]);
|
||||
|
|
|
@ -74,7 +74,7 @@ class GalaxyClusterRelation extends AppModel
|
|||
return $results;
|
||||
}
|
||||
|
||||
public function buildConditions($user)
|
||||
public function buildConditions($user, $clusterConditions = true)
|
||||
{
|
||||
$this->Event = ClassRegistry::init('Event');
|
||||
$conditions = [];
|
||||
|
@ -95,7 +95,7 @@ class GalaxyClusterRelation extends AppModel
|
|||
]
|
||||
]
|
||||
];
|
||||
$conditionsSourceCluster = $this->SourceCluster->buildConditions($user);
|
||||
$conditionsSourceCluster = $clusterConditions ? $this->SourceCluster->buildConditions($user) : [];
|
||||
$conditions = [
|
||||
'AND' => [
|
||||
$conditionsRelations,
|
||||
|
|
Loading…
Reference in New Issue