From 302e40a1c3c1f13578499d82e40c75e50beff79e Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Thu, 26 Jun 2014 16:08:47 -0400 Subject: [PATCH] bugFix#2823 --- SoObjects/Mailer/SOGoDraftObject.m | 20 ++++----- SoObjects/SOGo/SOGoParentFolder.m | 41 ++++++++++++------- UI/PreferencesUI/UIxPreferences.m | 30 +++++++------- UI/Templates/PreferencesUI/UIxPreferences.wox | 3 +- UI/WebServerResources/UIxPreferences.js | 12 +++++- 5 files changed, 64 insertions(+), 42 deletions(-) diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 7fd1a4c35..4d0f9aa38 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -1761,26 +1761,26 @@ static NSString *userAgent = nil; { SOGoUserDefaults *ud; ud = [[context activeUser] userDefaults]; - + if ([ud mailAddOutgoingAddresses]) { + Class contactGCSEntry; SOGoContactFolders *contactFolders; - NGMailAddressParser *parser; - id parsedRecipient; SOGoContactFolder *folder; SOGoContactGCSEntry *newContact; NGVCard *card; - Class contactGCSEntry; + NGMailAddressParser *parser; + NSArray *matchingContacts; NSMutableArray *recipients; NSString *recipient, *emailAddress, *addressBook, *uid; - NSArray *matchingContacts; + id parsedRecipient; int i; - + // Get all the addressbooks contactFolders = [[[context activeUser] homeFolderInContext: context] - lookupName: @"Contacts" - inContext: context - acquire: NO]; + lookupName: @"Contacts" + inContext: context + acquire: NO]; // Get all the recipients from the current email recipients = [self allRecipients]; for (i = 0; i < [recipients count]; i++) @@ -1790,7 +1790,7 @@ static NSString *userAgent = nil; parser = [NGMailAddressParser mailAddressParserWithString: recipient]; parsedRecipient = [parser parse]; emailAddress = [parsedRecipient address]; - + matchingContacts = [contactFolders allContactsFromFilter: emailAddress excludeGroups: YES excludeLists: YES]; diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 4c7c7c31a..164296b83 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -164,34 +164,45 @@ static SoSecurityManager *sm = nil; NSString *folderName; SOGoGCSFolder *folder; SOGoUser *folderOwner; - + SOGoUserDefaults *ud; + roles = [[context activeUser] rolesForObject: self inContext: context]; folderOwner = [SOGoUser userWithLogin: [self ownerInContext: context]]; - + + // We autocreate the calendars if the user is the owner, a superuser or // if it's a resource as we won't necessarily want to login as a resource // in order to create its database tables. // FolderType is an enum where 0 = Personal and 1 = collected if ([roles containsObject: SoRole_Owner] || (folderOwner && [folderOwner isResource])) + { + if (folderType == SOGoPersonalFolder) { - if (folderType == SOGoPersonalFolder) - { - folderName = @"personal"; - folder = [subFolderClass objectWithName: folderName inContainer: self]; - [folder setDisplayName: [self defaultFolderName]]; - } - else if (folderType == SOGoCollectedFolder) - { - folderName = @"collected"; - folder = [subFolderClass objectWithName: folderName inContainer: self]; - [folder setDisplayName: [self collectedFolderName]]; - } + folderName = @"personal"; + folder = [subFolderClass objectWithName: folderName inContainer: self]; + [folder setDisplayName: [self defaultFolderName]]; [folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, folderName]]; if ([folder create]) - [subFolders setObject: folder forKey: folderName]; + [subFolders setObject: folder forKey: folderName]; } + else if (folderType == SOGoCollectedFolder) + { + ud = [[context activeUser] userDefaults]; + if ([ud mailAddOutgoingAddresses]) { + folderName = @"collected"; + folder = [subFolderClass objectWithName: folderName inContainer: self]; + [folder setDisplayName: [self collectedFolderName]]; + [folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, folderName]]; + + if ([folder create]) + [subFolders setObject: folder forKey: folderName]; + + [ud setSelectedAddressBook:folderName]; + } + } + } } - (NSException *) fetchSpecialFolders: (NSString *) sql diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 54c0df6b8..c9c42f88a 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -699,47 +699,49 @@ static NSArray *reminderValues = nil; /* We want all the SourceIDS */ NSMutableArray *folders, *availableAddressBooksID, *availableAddressBooksName; SOGoParentFolder *contactFolders; - + int i, count; BOOL collectedAlreadyExist; - + contactFolders = [[[context activeUser] homeFolderInContext: context] lookupName: @"Contacts" inContext: context acquire: NO]; folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]]; count = [folders count]-1; - + // Inside this loop we remove all the public or shared addressbooks for (; count >= 0; count--) { if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]]) - [folders removeObjectAtIndex: count]; + [folders removeObjectAtIndex: count]; } - + // Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]]; availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]]; count = [folders count]-1; collectedAlreadyExist = NO; - + for (i = 0; i <= count ; i++) { [availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]]; [availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]]; - + if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"]) - collectedAlreadyExist = YES; + collectedAlreadyExist = YES; } // Create the dictionary for the next function : itemAddressBookText. if (!addressBooksIDWithDisplayName) + { addressBooksIDWithDisplayName = [[NSMutableDictionary alloc] initWithObjects:availableAddressBooksName forKeys:availableAddressBooksID]; - if (!collectedAlreadyExist) - { - [availableAddressBooksID addObject: @"collected"]; - [addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"]; - } - + } + if (!collectedAlreadyExist) + { + [availableAddressBooksID addObject: @"collected"]; + [addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"]; + } + return availableAddressBooksID; } - (NSString *) itemAddressBookText diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index fbfc0b30a..9cc6675a2 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -299,7 +299,8 @@
+ var:checked="addOutgoingAddresses" + onChange = "onAddOutgoingAddressesCheck(this);"/>