diff --git a/ChangeLog b/ChangeLog index ec1dfabff..d4cc47751 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2007-05-25 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailFolder + -ownerInContext:localContext]): overriden method because we are an + IMAP4 client and we need a bit more intelligence to deduce the + owner of the current folder. + ([SOGoMailFolder -aclsForUser:uid]): aclForMailboxAtURL might + return an NSException so we need to be careful here to avoid a + crash. + ([SOGoMailFolder -aclUsers]): aclForMailboxAtURL might return an + NSException so we need to be careful here to avoid a crash. + * SoObjects/Mailer/SOGoMailAccounts.m ([SOGoMailAccounts -fetchIdentitiesWithOnlyEmitterAccess:_flag]) there is no longer any concept of Intranet or Internet connection diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 6c7c84cb1..6d9cfa6ef 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -420,24 +420,71 @@ static BOOL useAltNamespace = NO; - (NSArray *) aclUsers { + NSArray *users; NSDictionary *imapAcls; imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; + if ([imapAcls isKindOfClass: [NSDictionary class]]) + users = [imapAcls allKeys]; + else + users = nil; - return [imapAcls allKeys]; + return users; +} + +- (NSMutableArray *) _sharesACLs +{ + NSMutableArray *acls; + SOGoMailAccount *mailAccount; + NSString *path, *sharedPath, *othersPath; + NSArray *names; + unsigned int count; + + acls = [NSMutableArray array]; + + mailAccount = [self mailAccountFolder]; + sharedPath = [NSString stringWithFormat: @"/%@", + [mailAccount sharedFolderName]]; + othersPath = [NSString stringWithFormat: @"/%@", + [mailAccount otherUsersFolderName]]; + path = [[self imap4URL] path]; + names = [path componentsSeparatedByString: @"/"]; + count = [names count]; + + if ([path hasPrefix: sharedPath]) + { + if (count == 2) + [acls addObject: SOGoRole_ObjectViewer]; + } + else if ([path hasPrefix: othersPath]) + { + if (count == 2 || count == 3) + [acls addObject: SOGoRole_ObjectViewer]; + } + else + [acls addObject: SoRole_Owner]; + + return acls; } - (NSArray *) aclsForUser: (NSString *) uid { NSDictionary *imapAcls; + NSMutableArray *acls; NSString *userAcls; + acls = [self _sharesACLs]; imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; - userAcls = [imapAcls objectForKey: uid]; - if (!([userAcls length] || [uid isEqualToString: defaultUserID])) - userAcls = [imapAcls objectForKey: defaultUserID]; + if ([imapAcls isKindOfClass: [NSDictionary class]]) + { + userAcls = [imapAcls objectForKey: uid]; + if (!([userAcls length] || [uid isEqualToString: defaultUserID])) + userAcls = [imapAcls objectForKey: defaultUserID]; + if ([userAcls length]) + [acls addObjectsFromArray: [self _imapAclsToSOGoAcls: userAcls]]; + } - return [self _imapAclsToSOGoAcls: userAcls]; + return acls; } - (void) removeAclsForUsers: (NSArray *) users @@ -474,6 +521,35 @@ static BOOL useAltNamespace = NO; return defaultUserID; } +- (NSString *) ownerInContext: (WOContext *) localContext +{ + SOGoMailAccount *mailAccount; + NSString *path, *sharedPath, *othersPath, *owner; + NSArray *names; + + mailAccount = [self mailAccountFolder]; + sharedPath = [NSString stringWithFormat: @"/%@", + [mailAccount sharedFolderName]]; + othersPath = [NSString stringWithFormat: @"/%@", + [mailAccount otherUsersFolderName]]; + path = [[self imap4URL] path]; + + if (sharedPath && [path hasPrefix: sharedPath]) + owner = @"anyone"; + else if (othersPath && [path hasPrefix: othersPath]) + { + names = [path componentsSeparatedByString: @"/"]; + if ([names count] > 2) + owner = [names objectAtIndex: 2]; + else + owner = @"anyone"; + } + else + owner = [super ownerInContext: localContext]; + + return owner; +} + - (BOOL) hasSupportForDefaultRoles { return YES; diff --git a/SoObjects/Mailer/product.plist b/SoObjects/Mailer/product.plist index a28051643..9e202f3e7 100644 --- a/SoObjects/Mailer/product.plist +++ b/SoObjects/Mailer/product.plist @@ -41,13 +41,13 @@ SOGoMailFolder = { superclass = "SOGoMailBaseObject"; defaultRoles = { - "View" = ( "Owner", "AuthorizedSubscriber" ); - "Access Contents Information" = ( "Owner", "AuthorizedSubscriber" ); + "View" = ( "Owner", "ObjectViewer" ); + "Access Contents Information" = ( "Owner", "ObjectReader" ); "Add Documents, Images, and Files" = ( "Owner", "ObjectCreator" ); "Delete Objects" = ( "Owner", "ObjectEraser" ); - "WebDAV Access" = ( "Owner", "AuthorizedSubscriber" ); - "ReadAcls" = ( "Owner", "AuthorizedSubscriber" ); - "SaveAcls" = ( "Owner" ); + "WebDAV Access" = ( "Owner", "ObjectViewer" ); + "ReadAcls" = ( "Owner", "ObjectViewer" ); + "SaveAcls" = ( "Owner", "MailAdministrator" ); }; }; SOGoSharedInboxFolder = {