Skip to content

Commit

Permalink
(sogo-tool) Fix ACLs restore in single store mode
Browse files Browse the repository at this point in the history
Fixes #4256
Fixes #4385
Fixes #4390
  • Loading branch information
cgx committed Apr 27, 2018
1 parent b8958b9 commit f318920
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -7,6 +7,7 @@ Enhancements
Bug fixes
- [core] properly update the last-modified attribute (#4313)
- [core] fixed default data value for c_hascertificate (#4442)
- [core] fixed ACLs restoration with sogo-tool in single store mode (#4385)
- [web] prevent deletion of special folders using del key
- [web] fixed SAML2 session timeout handling during XHR requests
- [web] fixed renaming a folder under iOS
Expand Down
4 changes: 3 additions & 1 deletion SOPE/GDLContentStore/GCSFolder.m
Expand Up @@ -1650,11 +1650,13 @@ - (void) deleteAclWithSpecification: (EOFetchSpecification *) _fs
sql = [NSMutableString stringWithCapacity:256];
[sql appendString:@"DELETE FROM "];
[sql appendString:[self aclTableName]];
if ([GCSFolderManager singleStoreMode])
[sql appendFormat:@" WHERE c_folder_id = %@", folderId];
qSql = [self _sqlForQualifier: [_fs qualifier]];
if (qSql)
{
if ([GCSFolderManager singleStoreMode])
[sql appendFormat:@" WHERE c_folder_id = %@ AND (%@)", folderId, qSql];
[sql appendFormat:@" AND (%@)", qSql];
else
[sql appendFormat:@" WHERE %@", qSql];
}
Expand Down
17 changes: 12 additions & 5 deletions Tools/SOGoToolRestore.m
Expand Up @@ -348,11 +348,18 @@ - (BOOL) restoreACL: (NSDictionary *) acl
userRoles = [[acl objectForKey: currentUser] objectEnumerator];
while ((currentRole = [userRoles nextObject]))
{
SQL = [NSString stringWithFormat: @"INSERT INTO %@"
@" (c_object, c_uid, c_role)"
@" VALUES ('%@', '%@', '%@')",
aclTableName,
folderPath, currentUser, currentRole];
if ([GCSFolderManager singleStoreMode])
SQL = [NSString stringWithFormat: @"INSERT INTO %@"
@" (c_object, c_uid, c_role, c_folder_id)"
@" VALUES ('%@', '%@', '%@', %@)",
aclTableName,
folderPath, currentUser, currentRole, [gcsFolder folderId]];
else
SQL = [NSString stringWithFormat: @"INSERT INTO %@"
@" (c_object, c_uid, c_role)"
@" VALUES ('%@', '%@', '%@')",
aclTableName,
folderPath, currentUser, currentRole];
[channel evaluateExpressionX: SQL];
}
}
Expand Down

0 comments on commit f318920

Please sign in to comment.