diff --git a/ChangeLog b/ChangeLog index ee5d08e9a..b16a19438 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2010-10-08 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoAppointmentFolder.m + (-removeFolderSettings:withReference:): new method which removes + the settings for keys "FreeBusyExclusions", "FolderColors", + "FolderShowAlarms", "FolderShowTasks", "InactiveFolders", + "FolderSyncTags" and "FolderSynchronize". Code taken from + -[SOGoGCSFolder subscribeUser:reallyDo:]. + + * SoObjects/SOGo/SOGoGCSFolder.m + (-removeFolderSettings:withReference:): new overridable method + which enables the removal of user settings pertaining to a folder + and its type when deleting the folder or unsubscribing from it. + This implementation removes the folder reference from the + "FolderDisplayNames" key. + (-delete): make use of the new method above. + * UI/WebServerResources/ContactsUI.js: (setEventsOnAddressBook) enable the "dblclick" event on non-owned addressbooks, except the public ones (owned by "nobody") diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 5f65cde0f..aa4d7fb19 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -2247,6 +2247,37 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return rc; } +- (void) removeFolderSettings: (NSMutableDictionary *) moduleSettings + withReference: (NSString *) reference +{ + NSMutableArray *refArray; + NSMutableDictionary *refDict; + + refDict = [moduleSettings objectForKey: @"FreeBusyExclusions"]; + [refDict removeObjectForKey: reference]; + + refDict = [moduleSettings objectForKey: @"FolderColors"]; + [refDict removeObjectForKey: reference]; + + refDict = [moduleSettings objectForKey: @"FolderShowAlarms"]; + [refDict removeObjectForKey: reference]; + + refDict = [moduleSettings objectForKey: @"FolderShowTasks"]; + [refDict removeObjectForKey: reference]; + + refArray = [moduleSettings objectForKey: @"InactiveFolders"]; + [refArray removeObject: nameInContainer]; + + refDict = [moduleSettings objectForKey: @"FolderSyncTags"]; + [refDict removeObjectForKey: reference]; + + refDict = [moduleSettings objectForKey: @"FolderSynchronize"]; + [refDict removeObjectForKey: reference]; + + [super removeFolderSettings: moduleSettings + withReference: reference]; +} + - (id) lookupHomeFolderForUID: (NSString *) _uid inContext: (id)_ctx { diff --git a/SoObjects/SOGo/SOGoGCSFolder.h b/SoObjects/SOGo/SOGoGCSFolder.h index 7079c4991..0456eee0a 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.h +++ b/SoObjects/SOGo/SOGoGCSFolder.h @@ -93,6 +93,9 @@ - (NSException *) delete; - (void) renameTo: (NSString *) newName; +- (void) removeFolderSettings: (NSMutableDictionary *) moduleSettings + withReference: (NSString *) reference; + - (BOOL) subscribeUser: (NSString *) subscribingUser reallyDo: (BOOL) reallyDo; - (BOOL) userIsSubscriber: (NSString *) subscribingUser; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index fc1cf49b5..55063f63b 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -533,6 +533,8 @@ static NSArray *childRecordFields = nil; - (NSException *) delete { NSException *error; + SOGoUserSettings *us; + NSMutableDictionary *moduleSettings; // We just fetch our displayName since our table will use it! [self displayName]; @@ -543,8 +545,17 @@ static NSArray *childRecordFields = nil; else error = [[self folderManager] deleteFolderAtPath: ocsPath]; - if (!error && [[context request] handledByDefaultHandler]) - [self sendFolderAdvisoryTemplate: @"Removal"]; + if (!error) + { + us = [[SOGoUser userWithLogin: owner] userSettings]; + moduleSettings = [us objectForKey: [container nameInContainer]]; + [self removeFolderSettings: moduleSettings + withReference: [self folderReference]]; + [us synchronize]; + + if ([[context request] handledByDefaultHandler]) + [self sendFolderAdvisoryTemplate: @"Removal"]; + } return error; } @@ -839,7 +850,7 @@ static NSArray *childRecordFields = nil; NSDictionary *moduleSettings; NSArray *folderSubscription; - sogoUser = [SOGoUser userWithLogin: subscribingUser roles: nil]; + sogoUser = [SOGoUser userWithLogin: subscribingUser]; moduleSettings = [[sogoUser userSettings] objectForKey: [container nameInContainer]]; folderSubscription = [moduleSettings objectForKey: @"SubscribedFolders"]; @@ -850,10 +861,10 @@ static NSArray *childRecordFields = nil; - (BOOL) subscribeUser: (NSString *) subscribingUser reallyDo: (BOOL) reallyDo { - NSMutableArray *folderSubscription, *tmpA; + NSMutableArray *folderSubscription; NSString *subscriptionPointer; SOGoUserSettings *us; - NSMutableDictionary *moduleSettings, *tmpD; + NSMutableDictionary *moduleSettings; SOGoUser *sogoUser; BOOL rc; @@ -871,43 +882,29 @@ static NSArray *childRecordFields = nil; folderSubscription = [moduleSettings objectForKey: @"SubscribedFolders"]; - if (!(folderSubscription - && [folderSubscription isKindOfClass: [NSMutableArray class]])) - { - folderSubscription = [NSMutableArray array]; - [moduleSettings setObject: folderSubscription - forKey: @"SubscribedFolders"]; - } - subscriptionPointer = [self folderReference]; + if (reallyDo) - [folderSubscription addObjectUniquely: subscriptionPointer]; + { + if (!(folderSubscription + && [folderSubscription isKindOfClass: [NSMutableArray class]])) + { + folderSubscription = [NSMutableArray array]; + [moduleSettings setObject: folderSubscription + forKey: @"SubscribedFolders"]; + } + + [folderSubscription addObjectUniquely: subscriptionPointer]; + } else { - tmpD = [moduleSettings objectForKey: @"FolderColors"]; - if (tmpD) - [tmpD removeObjectForKey: subscriptionPointer]; - - tmpD = [moduleSettings objectForKey: @"FolderShowAlarms"]; - if (tmpD) - [tmpD removeObjectForKey: subscriptionPointer]; - - tmpD = [moduleSettings objectForKey: @"FolderShowTasks"]; - if (tmpD) - [tmpD removeObjectForKey: subscriptionPointer]; - - tmpA = [moduleSettings objectForKey: @"InactiveFolders"]; - if (tmpA) - [tmpA removeObject: nameInContainer]; - - tmpD = [moduleSettings objectForKey: @"FolderSyncTags"]; - if (tmpD) - [tmpD removeObjectForKey: subscriptionPointer]; - + [self removeFolderSettings: moduleSettings + withReference: subscriptionPointer]; [folderSubscription removeObject: subscriptionPointer]; } [us synchronize]; + rc = YES; } else @@ -916,6 +913,15 @@ static NSArray *childRecordFields = nil; return rc; } +- (void) removeFolderSettings: (NSMutableDictionary *) moduleSettings + withReference: (NSString *) reference +{ + NSMutableDictionary *refDict; + + refDict = [moduleSettings objectForKey: @"FolderDisplayNames"]; + [refDict removeObjectForKey: reference]; +} + - (NSArray *) _parseDAVDelegatedUsers { id document;