fix: [sharing groups] fixed regression with updating local sharing groups

pull/7071/merge
iglocska 2021-03-02 23:42:54 +01:00
parent 71e2ac514c
commit f83fc6ca24
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 6 additions and 4 deletions

View File

@ -649,10 +649,12 @@ class SharingGroup extends AppModel
return false;
}
if (empty($sg['modified']) || $sg['modified'] > $existingSG['SharingGroup']['modified']) {
$isLocalSync = $user['Role']['perm_sync'] && !empty($existingSG['SharingGroup']['local']);
// consider the local field being set to be equivalent to an event's locked == 0 state
$isUpdatableBySync = $user['Role']['perm_sync'] && empty($existingSG['SharingGroup']['local']);
// TODO: reconsider this, org admins will be blocked from legitimate edits if they have sync permissions.
// We need a mechanism to check whether we're in sync context.
$isSGOwner = !$user['Role']['perm_sync'] && $existingSG['org_id'] == $user['org_id'];
if ($isLocalSync || $isSGOwner || $user['Role']['perm_site_admin']) {
$sg_id = (int)$existingSG['SharingGroup']['id'];
if ($isUpdatableBySync || $isSGOwner || $user['Role']['perm_site_admin']) {
$editedSG = $existingSG['SharingGroup'];
$attributes = ['name', 'releasability', 'description', 'created', 'modified', 'active', 'roaming'];
foreach ($attributes as $a) {
@ -679,7 +681,7 @@ class SharingGroup extends AppModel
* @return int || false
*/
public function captureSGNew($user, $sg, $syncLocal)
{
{
// check if current user is contained in the SG and we are in a local sync setup
if (!empty($sg['uuid'])) {
if (isset($this->__sgAuthorisationCache['save'][boolval($syncLocal)][$sg['uuid']])) {