fix: [GalaxyCluster:fetchGalaxyCluster] Correctly attach all sharinggroup

information
pull/6120/head
mokaddem 2020-07-02 15:14:02 +02:00
parent 543dcca00a
commit 191dcea4bb
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 20 additions and 3 deletions

View File

@ -5700,7 +5700,7 @@ class Event extends AppModel
}
}
private function __cacheSharingGroupData($user, $useCache = false)
public function __cacheSharingGroupData($user, $useCache = false)
{
if ($useCache && isset($this->__assetCache['sharingGroupData'])) {
return $this->__assetCache['sharingGroupData'];

View File

@ -481,9 +481,12 @@ class GalaxyCluster extends AppModel
$syncTool = new SyncTool();
$HttpSocket = $syncTool->setupHttpSocket($server);
$fakeSyncUser = array(
'id' => 0,
'email' => 'fakeSyncUser@user.test',
'org_id' => $server['Server']['remote_org_id'],
'Organisation' => array(
'id' => $server['Server']['remote_org_id']
'id' => $server['Server']['remote_org_id'],
'name' => 'fakeSyncOrg',
),
'Role' => array(
'perm_site_admin' => 0
@ -845,7 +848,19 @@ class GalaxyCluster extends AppModel
} else {
$clusters = $this->find('all', $params);
}
$this->Event = ClassRegistry::init('Event');
$sharingGroupData = $this->Event->__cacheSharingGroupData($user, true);
foreach ($clusters as $i => $cluster) {
if (!empty($cluster['GalaxyCluster']['sharing_group_id']) && isset($sharingGroupData[$cluster['GalaxyCluster']['sharing_group_id']])) {
$clusters[$i]['SharingGroup'] = $sharingGroupData[$cluster['GalaxyCluster']['sharing_group_id']]['SharingGroup'];
}
if (isset($cluster['GalaxyClusterRelation'])) {
foreach ($cluster['GalaxyClusterRelation'] as $j => $relation) {
if (!empty($relation['sharing_group_id']) && isset($sharingGroupData[$relation['sharing_group_id']])) {
$clusters[$i]['GalaxyClusterRelation'][$j]['SharingGroup'] = $sharingGroupData[$relation['sharing_group_id']]['SharingGroup'];
}
}
}
$clusters[$i] = $this->arrangeData($clusters[$i]);
$clusters[$i] = $this->GalaxyClusterRelation->massageRelationTag($clusters[$i]);
$clusters[$i] = $this->TargetingClusterRelation->massageRelationTag($clusters[$i]);
@ -1478,9 +1493,10 @@ class GalaxyCluster extends AppModel
$relation['distribution'] = 1;
}
$this->Event = ClassRegistry::init('Event');
// If the attribute has a sharing group attached, make sure it can be transferred
if ($relation['distribution'] == 4) {
if (!$server['Server']['internal'] && $this->checkDistributionForPush(array('GalaxyClusterRelation' => $relation), $server, 'GalaxyClusterRelation') === false) {
if (!$server['Server']['internal'] && $this->Event->checkDistributionForPush(array('GalaxyClusterRelation' => $relation), $server, 'GalaxyClusterRelation') === false) {
return false;
}
// Add the local server to the list of instances in the SG

View File

@ -496,6 +496,7 @@ class SharingGroup extends AppModel
public function captureSG($sg, $user, $syncLocal=false)
{
$this->Log = ClassRegistry::init('Log');
$existingSG = !isset($sg['uuid']) ? null : $this->find('first', array(
'recursive' => -1,
'conditions' => array('SharingGroup.uuid' => $sg['uuid']),