From 64a0aa3d9cafc88b883432f8c6c72b198f89e792 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 2 Jun 2010 16:39:33 +0000 Subject: [PATCH] Monotone-Parent: 3c3b185ac78cbde20c55f90c27b4f32909f9fdbf Monotone-Revision: 0c6806493b569c14269ce32c78f49e2d8d0bd053 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-06-02T16:39:33 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++++ SoObjects/SOGo/SOGoGCSFolder.m | 26 +++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dd7a7f0e..5d0336e8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-06-02 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoGCSFolder.m (-aclsForUser:forObjectAtPath:): + extracted db code into a new "_realAclsForUser:forObjectAtPath:" + private method. When the "None" special role is returned, we + remove it from the list. Finally, we don't allow fetching default + roles when the specified uid is "anonymous". + * SoObjects/Contacts/SOGoContactFolders.m (-appendSystemSources): we now add public sources to the list of folders if and only if the active user is the owner of the current parent folder. diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index a196041ec..9e8039802 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -1384,13 +1384,12 @@ static NSArray *childRecordFields = nil; [aclsForObject removeObjectForKey: uid]; } -- (NSArray *) aclsForUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray +- (NSArray *) _realAclsForUser: (NSString *) uid + forObjectAtPath: (NSArray *) objectPathArray { NSArray *acls; - NSString *objectPath, *module; + NSString *objectPath; NSDictionary *aclsForObject; - SOGoDomainDefaults *dd; objectPath = [objectPathArray componentsJoinedByString: @"/"]; aclsForObject = [aclCache objectForKey: objectPath]; @@ -1401,13 +1400,26 @@ static NSArray *childRecordFields = nil; if (!acls) { acls = [self _fetchAclsForUser: uid forObjectAtPath: objectPath]; - if (!acls) + if (!acls + || ([acls count] == 1 && [acls containsObject: SOGoRole_None])) acls = [NSArray array]; [self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath]; } - if (!([acls count] || [uid isEqualToString: defaultUserID])) - acls = [self aclsForUser: defaultUserID forObjectAtPath: objectPathArray]; + return acls; +} + +- (NSArray *) aclsForUser: (NSString *) uid + forObjectAtPath: (NSArray *) objectPathArray +{ + NSArray *acls; + NSString *module; + SOGoDomainDefaults *dd; + + acls = [self _realAclsForUser: uid forObjectAtPath: objectPathArray]; + if (!([acls count] || [uid isEqualToString: @"anonymous"])) + acls = [self _realAclsForUser: defaultUserID + forObjectAtPath: objectPathArray]; // If we still don't have ACLs defined for this particular resource, // let's go get the domain defaults, if any.