From 6af0058657cb8e5ba96c4023bb673be5b6179c27 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 3 Apr 2020 12:18:16 -0400 Subject: [PATCH] fix(calendar): use the calendar owner when generating freebusy information --- .../Appointments/SOGoAppointmentFolder.m | 27 ++++++++++++++----- UI/MainUI/SOGoUserHomePage.m | 7 ++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 1cd2240df..b1eabcdef 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1476,8 +1476,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir #warning we do not take the participation status into account while ((currentRecord = [ma nextObject])) { - accessClass - = [[currentRecord objectForKey: @"c_classification"] intValue]; + accessClass = [[currentRecord objectForKey: @"c_classification"] intValue]; role = roles[accessClass]; if (!role) { @@ -1506,13 +1505,17 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir EOQualifier *qualifier; GCSFolder *folder; NSMutableArray *fields, *ma; + NSMutableDictionary *currentRecord; NSArray *records; + NSEnumerator *matchingRecords; NSMutableArray *baseWhere; NSString *where, *dateSqlString, *privacySQLString, *currentLogin; NSCalendarDate *endDate; NGCalendarDateRange *r; BOOL rememberRecords, canCycle; + SOGoUser *ownerUser; + ownerUser = [SOGoUser userWithLogin: owner roles: nil]; rememberRecords = [self _checkIfWeCanRememberRecords: _fields]; canCycle = [_component isEqualToString: @"vevent"] || [_component isEqualToString: @"vtodo"]; // if (rememberRecords) @@ -1670,11 +1673,21 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir } currentLogin = [[context activeUser] login]; - if (![currentLogin isEqualToString: owner] - && !_includeProtectedInformation) - [self _fixupProtectedInformation: [ma objectEnumerator] - inFields: _fields - forUser: currentLogin]; + if (![currentLogin isEqualToString: owner]) + { + + if (!_includeProtectedInformation) + [self _fixupProtectedInformation: [ma objectEnumerator] + inFields: _fields + forUser: currentLogin]; + } + + // Add owner to each record. It will be used when generating freebusy. + matchingRecords = [ma objectEnumerator]; + while ((currentRecord = [matchingRecords nextObject])) + { + [currentRecord setObject: ownerUser forKey: @"owner"]; + } if (rememberRecords) [self _rememberRecords: ma]; diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 1f341fec9..6acd81f9f 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -157,6 +157,7 @@ for (recordCount = 0; recordCount < recordMax; recordCount++) { record = [records objectAtIndex: recordCount]; + user = [record objectForKey: @"owner"]; if ([[record objectForKey: @"c_isopaque"] boolValue]) { type = 0; @@ -181,9 +182,13 @@ // We now fetch the c_partstates array and get the participation // status of the user for the event partstates = [[record objectForKey: @"c_partstates"] componentsSeparatedByString: @"\n"]; - if (i < [partstates count]) { + // 0: needs action (considered busy) + // 1: accepted (busy) + // 2: declined (free) + // 3: tentative (free) + // 4: delegated (free) type = ([[partstates objectAtIndex: i] intValue] < 2 ? 1 : 0); } break;