diff --git a/NEWS b/NEWS index 85f64f0d12..4d1b07c801 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ Bug fixes - [web] respect SOGoLanguage and SOGoSupportedLanguages (#4169) - [web] fixed adding list members with multiple email addresses - [web] fixed responsive condition of login page (960px to 1023px) + - [core] newly subscribed calendars are excluded from freebusy (#3354) 3.2.9 (2017-05-09) ------------------ diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 0d3f9b0308..54697cb1de 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -420,6 +420,93 @@ - (void) setShowCalendarTasks: (BOOL) new 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. // @@ -447,9 +534,16 @@ - (BOOL) includeInFreeBusy = [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 d82e9da0a1..debbdfe34b 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -958,8 +958,12 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier 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) { @@ -971,30 +975,17 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier 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];