diff --git a/NEWS b/NEWS index 68ca94130..ed85d7afb 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Bug fixes - [core] handle properly mails using windows-1255 charset (#4124) - [core] properly honor the "include in freebusy" setting (#3354) - [core] make sure to use crypt scheme when encoding md5/sha256/sha512 (#4137) + - [core] newly subscribed calendars are excluded from freebusy (#3354) - [web] fixed mail delegation of pristine user accounts (#4160) - [eas] fixed opacity in EAS freebusy (#4033) - [eas] set reply/forwarded flags when ReplaceMime is set (#4133) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 582de41c0..78855cc49 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -434,6 +434,93 @@ static Class iCalEventK = nil; inCategory: @"FolderShowTasks"]; } +- (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier + reallyDo: (BOOL) reallyDo + response: (WOResponse *) theResponse +{ + NSMutableDictionary *moduleSettings, *folderShowAlarms, *freeBusyExclusions; + NSString *subscriptionPointer; + NSMutableArray *allUsers; + SOGoUserSettings *us; + NSDictionary *dict; + SOGoUser *sogoUser; + BOOL rc; + int i; + + rc = [super subscribeUserOrGroup: theIdentifier reallyDo: reallyDo response: theResponse]; + + if (rc) + { + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier]; + + if ([[dict objectForKey: @"isGroup"] boolValue]) + { + SOGoGroup *aGroup; + + aGroup = [SOGoGroup groupWithIdentifier: theIdentifier + inDomain: [[context activeUser] domain]]; + allUsers = [NSMutableArray arrayWithArray: [aGroup members]]; + + // We remove the active user from the group (if present) in order to + // not subscribe him to their own resource! + [allUsers removeObject: [context activeUser]]; + } + else + { + sogoUser = [SOGoUser userWithLogin: theIdentifier roles: nil]; + + if (sogoUser) + allUsers = [NSArray arrayWithObject: sogoUser]; + else + allUsers = [NSArray array]; + } + + for (i = 0; i < [allUsers count]; i++) + { + sogoUser = [allUsers objectAtIndex: i]; + us = [sogoUser userSettings]; + moduleSettings = [us objectForKey: [container nameInContainer]]; + if (!(moduleSettings + && [moduleSettings isKindOfClass: [NSMutableDictionary class]])) + { + moduleSettings = [NSMutableDictionary dictionary]; + [us setObject: moduleSettings forKey: [container nameInContainer]]; + } + + subscriptionPointer = [self folderReference]; + + folderShowAlarms = [moduleSettings objectForKey: @"FolderShowAlarms"]; + freeBusyExclusions = [moduleSettings objectForKey: @"FreeBusyExclusions"]; + + if (reallyDo) + { + if (!(folderShowAlarms + && [folderShowAlarms isKindOfClass: [NSMutableDictionary class]])) + { + folderShowAlarms = [NSMutableDictionary dictionary]; + [moduleSettings setObject: folderShowAlarms + forKey: @"FolderShowAlarms"]; + } + + // By default, we disable alarms on subscribed calendars + [folderShowAlarms setObject: [NSNumber numberWithBool: NO] + forKey: subscriptionPointer]; + } + else + { + [folderShowAlarms removeObjectForKey: subscriptionPointer]; + [freeBusyExclusions removeObjectForKey: subscriptionPointer]; + } + + [us synchronize]; + + rc = YES; + } + } + + return rc; +} + // // If the user is the owner of the calendar, by default we include the freebusy information. // @@ -461,9 +548,16 @@ static Class iCalEventK = nil; = [self folderPropertyValueInCategory: @"FreeBusyExclusions" forUser: [SOGoUser userWithLogin: ownerInContext]]; - // We haven't included/excluded freebusy info, let's INCLUDE it. + // User has not setting for freebusy inclusion/exclusion, + // * include it if it's a personal folder; + // * exclude it if it's a subscription. if (!excludeFromFreeBusy) - return YES; + { + if ([self isSubscription]) + return NO; + else + return YES; + } return ![excludeFromFreeBusy boolValue]; } diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 2cb172ecd..48cea27be 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -970,8 +970,12 @@ static NSArray *childRecordFields = nil; folderSubscription = [moduleSettings objectForKey: @"SubscribedFolders"]; subscriptionPointer = [self folderReference]; - + + // We used to set "show alarms" for any type of folder, so we remove it + // here and let the subclass handle it (SOGoAppointmentFolder). folderShowAlarms = [moduleSettings objectForKey: @"FolderShowAlarms"]; + if (folderShowAlarms) + [folderShowAlarms removeObjectForKey: subscriptionPointer]; if (reallyDo) { @@ -983,30 +987,17 @@ static NSArray *childRecordFields = nil; forKey: @"SubscribedFolders"]; } - if (!(folderShowAlarms - && [folderShowAlarms isKindOfClass: [NSMutableDictionary class]])) - { - folderShowAlarms = [NSMutableDictionary dictionary]; - [moduleSettings setObject: folderShowAlarms - forKey: @"FolderShowAlarms"]; - } - [self setFolderPropertyValue: [self _displayNameFromSubscriber] inCategory: @"FolderDisplayNames" settings: us]; [folderSubscription addObjectUniquely: subscriptionPointer]; - - // By default, we disable alarms on subscribed calendars - [folderShowAlarms setObject: [NSNumber numberWithBool: NO] - forKey: subscriptionPointer]; } else { [self removeFolderSettings: moduleSettings withReference: subscriptionPointer]; [folderSubscription removeObject: subscriptionPointer]; - [folderShowAlarms removeObjectForKey: subscriptionPointer]; } [us synchronize];