Skip to content

Commit

Permalink
fix(calendar): use the calendar owner when generating freebusy inform…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
cgx committed Apr 3, 2020
1 parent a78f06e commit 6af0058
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
27 changes: 20 additions & 7 deletions SoObjects/Appointments/SOGoAppointmentFolder.m
Expand Up @@ -1476,8 +1476,7 @@ - (void) _fixupProtectedInformation: (NSEnumerator *) ma
#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)
{
Expand Down Expand Up @@ -1506,13 +1505,17 @@ - (NSArray *) fetchFields: (NSArray *) _fields
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)
Expand Down Expand Up @@ -1670,11 +1673,21 @@ - (NSArray *) fetchFields: (NSArray *) _fields
}

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];
Expand Down
7 changes: 6 additions & 1 deletion UI/MainUI/SOGoUserHomePage.m
Expand Up @@ -157,6 +157,7 @@ - (NSDictionary *) _freeBusyFromStartDate: (NSCalendarDate *) startDate
for (recordCount = 0; recordCount < recordMax; recordCount++)
{
record = [records objectAtIndex: recordCount];
user = [record objectForKey: @"owner"];
if ([[record objectForKey: @"c_isopaque"] boolValue])
{
type = 0;
Expand All @@ -181,9 +182,13 @@ - (NSDictionary *) _freeBusyFromStartDate: (NSCalendarDate *) startDate
// 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;
Expand Down

0 comments on commit 6af0058

Please sign in to comment.