diff --git a/SoObjects/Contacts/French.lproj/Localizable.strings b/SoObjects/Contacts/French.lproj/Localizable.strings index af4d87c3a..8a5848a76 100644 --- a/SoObjects/Contacts/French.lproj/Localizable.strings +++ b/SoObjects/Contacts/French.lproj/Localizable.strings @@ -1 +1,2 @@ "Personal Address Book" = "Carnet d'adresses personnel"; +"Collected Address Book" = "Carnet d'adresses recueilli"; diff --git a/SoObjects/Contacts/SOGoContactFolders.h b/SoObjects/Contacts/SOGoContactFolders.h index 79f12e217..bb984f0b6 100644 --- a/SoObjects/Contacts/SOGoContactFolders.h +++ b/SoObjects/Contacts/SOGoContactFolders.h @@ -26,6 +26,7 @@ @interface SOGoContactFolders : SOGoParentFolder - (NSString *) defaultFolderName; +- (NSString *) collectedFolderName; - (NSException *) renameLDAPAddressBook: (NSString *) sourceID withDisplayName: (NSString *) newDisplayName; diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m index dfb91f45c..b0428f7f4 100644 --- a/SoObjects/Contacts/SOGoContactFolders.m +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -268,7 +268,7 @@ Class SOGoContactSourceFolderK; SOGoUser *currentUser; id source; - if ([sourceID isEqualToString: @"personal"] || [sourceID isEqualToString: @"collected"]) + if ([sourceID isEqualToString: @"personal"]) result = [NSException exceptionWithHTTPStatus: 403 reason: (@"folder '%@' cannot be deleted", sourceID)]; else @@ -295,6 +295,11 @@ Class SOGoContactSourceFolderK; return [self labelForKey: @"Personal Address Book"]; } +- (NSString *) collectedFolderName +{ + return [self labelForKey: @"Collected Address Book"]; +} + - (NSArray *) toManyRelationshipKeys { NSMutableArray *keys; diff --git a/SoObjects/SOGo/SOGoParentFolder.h b/SoObjects/SOGo/SOGoParentFolder.h index ce7504428..323e71d61 100644 --- a/SoObjects/SOGo/SOGoParentFolder.h +++ b/SoObjects/SOGo/SOGoParentFolder.h @@ -40,6 +40,7 @@ + (Class) subFolderClass; - (NSString *) defaultFolderName; +- (NSString *) collectedFolderName; - (NSException *) appendPersonalSources; - (void) removeSubFolder: (NSString *) subfolderName; diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 2d900396b..8d55adbb0 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -38,7 +38,7 @@ #import #import #import - +#import #import #import "NSObject+DAV.h" @@ -175,18 +175,18 @@ static SoSecurityManager *sm = nil; if ([roles containsObject: SoRole_Owner] || (folderOwner && [folderOwner isResource])) { - folder = [subFolderClass objectWithName: folderName inContainer: self]; - if (folderType == 0) + if (folderType == SOGoPersonalFolder) { folderName = @"personal"; + folder = [subFolderClass objectWithName: folderName inContainer: self]; [folder setDisplayName: [self defaultFolderName]]; } - else if (folderType == 1) + else if (folderType == SOGoCollectedFolder) { - folderName = @"Collected Address Book"; + folderName = @"collected"; + folder = [subFolderClass objectWithName: folderName inContainer: self]; [folder setDisplayName: [self collectedFolderName]]; } - [folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, folderName]]; if ([folder create]) @@ -203,6 +203,8 @@ static SoSecurityManager *sm = nil; SOGoGCSFolder *folder; NSString *key; NSException *error; + SOGoUserDefaults *ud; + ud = [[context activeUser] userDefaults]; if (!subFolderClass) subFolderClass = [[self class] subFolderClass]; @@ -221,15 +223,16 @@ static SoSecurityManager *sm = nil; [subFolders setObject: folder forKey: key]; } } - if (folderType == 0) + if (folderType == SOGoPersonalFolder) { if (![subFolders objectForKey: @"personal"]) [self createSpecialFolder: SOGoPersonalFolder]; } - else if (folderType == 1) + else if (folderType == SOGoCollectedFolder) { if (![subFolders objectForKey: @"collected"]) - [self createSpecialFolder: SOGoCollectedFolder]; + if ([[ud selectedAddressBook] isEqualToString:@"collected"]) + [self createSpecialFolder: SOGoCollectedFolder]; } } return error; diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index 1bac4a169..1f6649d26 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -97,8 +97,7 @@ "Show time as busy outside working hours" = "Show time as busy outside working hours"; "First week of year :" = "First week of year:"; "Enable reminders for Calendar items" = "Enable reminders for Calendar items"; -"Play a sound when a reminder comes due" -= "Play a sound when a reminder comes due"; +"Play a sound when a reminder comes due" = "Play a sound when a reminder comes due"; "Default reminder :" = "Default reminder:"; "firstWeekOfYear_January1" = "Starts on january 1"; @@ -139,8 +138,6 @@ "messagecheck_every_20_minutes" = "Every 20 minutes"; "messagecheck_every_30_minutes" = "Every 30 minutes"; "messagecheck_once_per_hour" = "Once per hour"; -"personal" = "Personal addressbook"; -"collected" = "Collected addresses"; "Forward messages:" = "Forward messages:"; "messageforward_inline" = "Inline"; @@ -159,6 +156,10 @@ "displayremoteinlineimages_never" = "Never"; "displayremoteinlineimages_always" = "Always"; +/* Contact */ +"Personal Address Book" = "Personal Address Book"; +"Collected Address Book" = "Collected Address Book"; + /* IMAP Accounts */ "New Mail Account" = "New Mail Account"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index b3d49aab2..b65a727f1 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -157,6 +157,10 @@ "displayremoteinlineimages_never" = "Jamais"; "displayremoteinlineimages_always" = "Toujours"; +/* Contact */ +"Personal Address Book" = "Carnet d'adresses personnel"; +"Collected Address Book" = "Carnet d'adresses recueilli"; + /* IMAP Accounts */ "New Mail Account" = "Nouveau compte"; diff --git a/UI/PreferencesUI/UIxPreferences.h b/UI/PreferencesUI/UIxPreferences.h index 3040e67ae..9c8a3483f 100644 --- a/UI/PreferencesUI/UIxPreferences.h +++ b/UI/PreferencesUI/UIxPreferences.h @@ -33,6 +33,9 @@ id item; SOGoUser *user; + // Addressbook + NSMutableDictionary *addressBooksIDWithDisplayName; + // Calendar categories NSString *category; NSArray *calendarCategories; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index a066fd1f5..9e9adb1e2 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -116,6 +116,7 @@ static NSArray *reminderValues = nil; if ((self = [super init])) { item = nil; + addressBooksIDWithDisplayName = nil; #warning user should be the owner rather than the activeUser ASSIGN (user, [context activeUser]); ASSIGN (today, [NSCalendarDate date]); @@ -691,8 +692,9 @@ static NSArray *reminderValues = nil; - (NSArray *) addressBookList { /* We want all the SourceIDS */ - NSMutableArray *folders, *contactFolders, *availableAddressBooks; + NSMutableArray *folders, *contactFolders, *availableAddressBooksID, *availableAddressBooksName; int i, count; + BOOL collectedAlreadyExist; contactFolders = [[[context activeUser] homeFolderInContext: context] lookupName: @"Contacts" @@ -702,49 +704,40 @@ static NSArray *reminderValues = nil; count = [folders count]-1; // Inside this loop we remove all the public or shared addressbooks - for (count; count >= 0; count--) + for(count; count>=0; count--) { if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]]) [folders removeObjectAtIndex: count]; } // Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface - availableAddressBooks = [[NSMutableArray alloc] initWithCapacity: [folders count]]; + availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]]; + availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]]; count = [folders count]-1; - for (i=0; i <= count ; i++) { - [availableAddressBooks addObject:[[folders objectAtIndex:i] realNameInContainer]]; - } + collectedAlreadyExist = false; - return availableAddressBooks; + 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 = true; + } + // Create the dictionary for the next function : itemAddressBookText. + if (!addressBooksIDWithDisplayName) + addressBooksIDWithDisplayName = [NSMutableDictionary dictionaryWithObjects:availableAddressBooksName + forKeys:availableAddressBooksID]; + if (!collectedAlreadyExist) + { + [availableAddressBooksID addObject: @"collected"]; + [addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"]; + } + + return availableAddressBooksID; } - (NSString *) itemAddressBookText { - NSString *displayNameAddressBookItem, *test; - NSMutableArray *folders, *contactFolders; - int count, i; - - if ([item isEqualToString: @"personal"] || [item isEqualToString: @"collected"]) - displayNameAddressBookItem = [self labelForKey:[NSString stringWithFormat: item]]; - - else - { - contactFolders = [[[context activeUser] homeFolderInContext: context] - lookupName: @"Contacts" - inContext: context - acquire: NO]; - folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]]; - count = [folders count]-1; - for (i=0; i <= count ; i++) - { - if ([item isEqualToString:[[folders objectAtIndex:i] realNameInContainer]]) - { - displayNameAddressBookItem = [[folders objectAtIndex:i] displayName]; - break; - }; - } - } - - return displayNameAddressBookItem; + return [addressBooksIDWithDisplayName objectForKey: item]; } - (NSString *) userAddressBook