diff --git a/ChangeLog b/ChangeLog index 2410c0ceb..8e747787f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-05-17 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder + -setRoles:rolesforUser:uidforObjectAtPath:objectPathArray]): + ignore the "AuthorizedSubscriber" role and add the "None" role + when no other role is found. + * UI/Common/UIxAclEditor.m: added a button for the new default user roles feature. diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index 43bc8e1c1..a55c3dad2 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -31,8 +31,6 @@ #import #import -static NSString *defaultUser = @""; - @implementation SOGoFolder + (int) version @@ -341,8 +339,9 @@ static NSString *defaultUser = @""; [self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath]; } - if (!([acls count] || [uid isEqualToString: defaultUser])) - acls = [self aclsForUser: defaultUser forObjectAtPath: objectPathArray]; + if (!([acls count] || [uid isEqualToString: SOGoDefaultUserID])) + acls = [self aclsForUser: SOGoDefaultUserID + forObjectAtPath: objectPathArray]; return acls; } @@ -369,19 +368,14 @@ static NSString *defaultUser = @""; } } -- (void) setRoles: (NSArray *) roles - forUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray +- (void) _commitRoles: (NSArray *) roles + forUID: (NSString *) uid + forObject: (NSString *) objectPath { EOAdaptorChannel *channel; GCSFolder *folder; NSEnumerator *userRoles; - NSString *SQL, *currentRole, *objectPath; - - [self removeAclsForUsers: [NSArray arrayWithObject: uid] - forObjectAtPath: objectPathArray]; - objectPath = [objectPathArray componentsJoinedByString: @"/"]; - [self _cacheRoles: roles forUser: uid forObjectAtPath: objectPath]; + NSString *SQL, *currentRole; folder = [self ocsFolder]; channel = [folder acquireAclChannel]; @@ -389,21 +383,40 @@ static NSString *defaultUser = @""; currentRole = [userRoles nextObject]; while (currentRole) { - if (![currentRole isEqualToString: SOGoRole_AuthorizedSubscriber]) - { - SQL = [NSString stringWithFormat: @"INSERT INTO %@" - @" (c_object, c_uid, c_role)" - @" VALUES ('/%@', '%@', '%@')", - [folder aclTableName], - objectPath, uid, currentRole]; - [channel evaluateExpressionX: SQL]; - } + SQL = [NSString stringWithFormat: @"INSERT INTO %@" + @" (c_object, c_uid, c_role)" + @" VALUES ('/%@', '%@', '%@')", + [folder aclTableName], + objectPath, uid, currentRole]; + [channel evaluateExpressionX: SQL]; currentRole = [userRoles nextObject]; } [folder releaseChannel: channel]; } +- (void) setRoles: (NSArray *) roles + forUser: (NSString *) uid + forObjectAtPath: (NSArray *) objectPathArray +{ + NSString *objectPath; + NSMutableArray *newRoles; + + [self removeAclsForUsers: [NSArray arrayWithObject: uid] + forObjectAtPath: objectPathArray]; + + newRoles = [NSMutableArray arrayWithArray: roles]; + [newRoles removeObject: SOGoRole_AuthorizedSubscriber]; + [newRoles removeObject: SOGoRole_None]; + objectPath = [objectPathArray componentsJoinedByString: @"/"]; + [self _cacheRoles: newRoles forUser: uid + forObjectAtPath: objectPath]; + if (![newRoles count]) + [newRoles addObject: SOGoRole_None]; + + [self _commitRoles: newRoles forUID: uid forObject: objectPath]; +} + /* acls */ - (NSArray *) defaultAclRoles {