fix: [sharing groups] Fix the behaviour of roaming mode sharing groups, fixes #4983

- creating sharing groups without roaming mode and without any sharing group servers should automatically add the own server
- adapt the new roaming mode behaviour from a few months ago on push: No explicit roaming mode set means no push, even if no servers are added
pull/4986/head
iglocska 2019-08-13 13:25:01 +02:00
parent 6b58b51bd3
commit ecfe1ee596
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 12 additions and 2 deletions

View File

@ -51,12 +51,20 @@ class SharingGroupsController extends AppController
if ($this->request->is('post')) {
if ($this->_isRest()) {
$sg = $this->request->data;
if (isset($this->request->data['SharingGroup'])) {
$this->request->data = $this->request->data['SharingGroup'];
}
$sg = $this->request->data;
$id = $this->SharingGroup->captureSG($this->request->data, $this->Auth->user());
if ($id) {
if (empty($sg['roaming']) && empty($sg['SharingGroupServer'])) {
$this->SharingGroup->SharingGroupServer->create();
$this->SharingGroup->SharingGroupServer->save(array(
'sharing_group_id' => $this->SharingGroup->id,
'server_id' => 0,
'all_orgs' => 0
));
}
$sg = $this->SharingGroup->fetchAllAuthorised($this->Auth->user(), 'simplified', false, $id);
if (!empty($sg)) {
$sg = empty($sg) ? array() : $sg[0];
@ -93,7 +101,7 @@ class SharingGroupsController extends AppController
));
}
}
if (!$sg['roaming'] && !empty($sg['Server'])) {
if (empty($sg['roaming']) && !empty($sg['Server'])) {
foreach ($sg['Server'] as $server) {
$this->SharingGroup->SharingGroupServer->create();
$this->SharingGroup->SharingGroupServer->save(array(

View File

@ -1111,6 +1111,8 @@ class Event extends AppModel
if (!$found) {
return 403;
}
} else if (empty($event['SharingGroup']['roaming'])) {
return 403;
}
}
$serverModel = ClassRegistry::init('Server');