From a180f6ca36d4eefffa47604b4f7ccc9506b3efc2 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Tue, 5 Jun 2007 15:45:31 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1077 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 16 ++++++ SoObjects/Appointments/product.plist | 1 + SoObjects/Mailer/SOGoMailFolder.m | 80 ++++++++++++++++++---------- SoObjects/SOGo/SOGoObject.m | 6 +++ UI/SOGoUI/SOGoACLAdvisory.m | 1 + 5 files changed, 76 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a9ea4df..415c50a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-06-05 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoObject.m ([SOGoObject + -_urlPreferringParticle:expectedoverThisOne:possible]): remove the + first 3 elements of the path array if the url returned by + baseURLInContext: returns a hostname. + + * SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailFolder + -_adjustOwner]): sharedFolderName and otherUsersFolderName may be + nil, in which case a crash happens when calling hasPrefix:. + ([SOGoMailFolder -_sharesACLs]): same as above. + ([SOGoMailFolder -otherUsersPathToFolder]): same as above. If + otherUsersFolderName is nil, we return nil. + ([SOGoMailFolder -httpURLForAdvisoryToUser:uid]): if we receive + nil from [self otherUsersPathToFolder], we return nil too. + 2007-06-01 Wolfgang Sourdeau * SoObjects/SOGo/SOGoObject.m ([SOGoObject diff --git a/SoObjects/Appointments/product.plist b/SoObjects/Appointments/product.plist index 0d2bab48..1fb47e4d 100644 --- a/SoObjects/Appointments/product.plist +++ b/SoObjects/Appointments/product.plist @@ -25,6 +25,7 @@ "ModifyConfidentialRecords" = ( "Owner", "ConfidentialModifier" ); "RespondToConfidentialRecords" = ( "Owner", "ConfidentialModifier", "ConfidentialResponder" ); "Access Contents Information" = ( "Owner", "AuthorizedSubscriber" ); + "Access Object" = ( "Owner", "AuthorizedSubscriber" ); }; }; SOGoGroupAppointmentFolder = { diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index d79cb68d..c257a319 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -65,21 +65,26 @@ static BOOL useAltNamespace = NO; - (void) _adjustOwner { SOGoMailAccount *mailAccount; - NSString *path; + NSString *path, *folder; NSArray *names; mailAccount = [self mailAccountFolder]; path = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; - if ([path hasPrefix: [mailAccount sharedFolderName]]) - owner = @"anyone"; - else if ([path hasPrefix: [mailAccount otherUsersFolderName]]) + folder = [mailAccount sharedFolderName]; + if (folder && [path hasPrefix: folder]) + [self setOwner: @"anyone"]; + else { - names = [path componentsSeparatedByString: @"/"]; - if ([names count] > 1) - owner = [names objectAtIndex: 1]; - else - owner = @"anyone"; + folder = [mailAccount otherUsersFolderName]; + if (folder && [path hasPrefix: folder]) + { + names = [path componentsSeparatedByString: @"/"]; + if ([names count] > 1) + [self setOwner: [names objectAtIndex: 1]]; + else + [self setOwner: @"anyone"]; + } } } @@ -525,23 +530,28 @@ static BOOL useAltNamespace = NO; { NSMutableArray *acls; SOGoMailAccount *mailAccount; - NSString *path; - NSArray *names; - unsigned int count; + NSString *path, *folder; +// NSArray *names; +// unsigned int count; acls = [NSMutableArray array]; mailAccount = [self mailAccountFolder]; path = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; - names = [path componentsSeparatedByString: @"/"]; - count = [names count]; +// names = [path componentsSeparatedByString: @"/"]; +// count = [names count]; - if ([path hasPrefix: [mailAccount sharedFolderName]]) - [acls addObject: SOGoRole_ObjectViewer]; - else if ([path hasPrefix: [mailAccount otherUsersFolderName]]) + folder = [mailAccount sharedFolderName]; + if (folder && [path hasPrefix: folder]) [acls addObject: SOGoRole_ObjectViewer]; else - [acls addObject: SoRole_Owner]; + { + folder = [mailAccount otherUsersFolderName]; + if (folder && [path hasPrefix: folder]) + [acls addObject: SOGoRole_ObjectViewer]; + else + [acls addObject: SoRole_Owner]; + } return acls; } @@ -610,14 +620,22 @@ static BOOL useAltNamespace = NO; sharedFolders = [account sharedFolderName]; selfPath = [[self imap4URL] path]; - if ([selfPath hasPrefix: [NSString stringWithFormat: @"/%@", otherUsers]] - || [selfPath hasPrefix: - [NSString stringWithFormat: @"/%@", sharedFolders]]) + if ((otherUsers + && [selfPath hasPrefix: + [NSString stringWithFormat: @"/%@", otherUsers]]) + || (sharedFolders + && [selfPath hasPrefix: + [NSString stringWithFormat: @"/%@", sharedFolders]])) userPath = selfPath; else - userPath = [NSString stringWithFormat: @"/%@/%@%@", - [otherUsers stringByEscapingURL], - owner, selfPath]; + { + if (otherUsers) + userPath = [NSString stringWithFormat: @"/%@/%@%@", + [otherUsers stringByEscapingURL], + owner, selfPath]; + else + userPath = nil; + } return userPath; } @@ -625,13 +643,19 @@ static BOOL useAltNamespace = NO; - (NSString *) httpURLForAdvisoryToUser: (NSString *) uid; { SOGoUser *user; + NSString *otherUsersPath, *url; user = [SOGoUser userWithLogin: uid roles: nil]; + otherUsersPath = [self otherUsersPathToFolder]; + if (otherUsersPath) + url = [NSString stringWithFormat: @"%@/%@%@", + [self soURLToBaseContainerForUser: uid], + [user primaryIMAP4AccountString], + otherUsersPath]; + else + url = nil; - return [NSString stringWithFormat: @"%@/%@%@", - [self soURLToBaseContainerForUser: uid], - [user primaryIMAP4AccountString], - [self otherUsersPathToFolder]]; + return url; } - (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid; diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 46fffc69..33d66017 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -828,6 +828,12 @@ static BOOL kontactGroupDAV = YES; baseURL = [[self baseURLInContext: context] stringByUnescapingURL]; path = [NSMutableArray arrayWithArray: [baseURL componentsSeparatedByString: @"/"]]; + if ([baseURL hasPrefix: @"http"]) + { + [path removeObjectAtIndex: 2]; + [path removeObjectAtIndex: 1]; + [path removeObjectAtIndex: 0]; + } urlMethod = [path objectAtIndex: 2]; if (![urlMethod isEqualToString: expected]) { diff --git a/UI/SOGoUI/SOGoACLAdvisory.m b/UI/SOGoUI/SOGoACLAdvisory.m index 78a146e5..40cc8d0b 100644 --- a/UI/SOGoUI/SOGoACLAdvisory.m +++ b/UI/SOGoUI/SOGoACLAdvisory.m @@ -86,6 +86,7 @@ { NSMutableString *url; +#warning the url returned by SOGoMail may be empty, we need to handle that url = [NSMutableString stringWithString: [aclObject httpURLForAdvisoryToUser: recipientUID]]; -- 2.39.5