fix(calendar): use the calendar owner when generating freebusy information

pull/274/head
Francis Lachapelle 2020-04-03 12:18:16 -04:00
parent a78f06e909
commit 6af0058657
2 changed files with 26 additions and 8 deletions

View File

@ -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];

View File

@ -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;