Newly subscribed calendars are excluded from FB

Fixes #3354
This commit is contained in:
Francis Lachapelle
2017-05-30 09:26:30 -04:00
parent b3149ee7c2
commit 95d08c0150
3 changed files with 102 additions and 16 deletions
+1
View File
@@ -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)
+96 -2
View File
@@ -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];
}
+5 -14
View File
@@ -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];