Skip to content

Commit

Permalink
fix(calendar): return SOGoUser instances when expanding LDAP groups
Browse files Browse the repository at this point in the history
Fixes #5043
  • Loading branch information
cgx committed Jul 1, 2020
1 parent 62fc80d commit b8595d7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
21 changes: 10 additions & 11 deletions SoObjects/Appointments/SOGoAppointmentFolder.m
Expand Up @@ -429,6 +429,7 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
NSString *subscriptionPointer, *domain;
NSMutableArray *allUsers;
SOGoUserSettings *us;
SOGoUser *sogoUser;
NSDictionary *dict;
BOOL rc;
int i;
Expand All @@ -452,15 +453,11 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
NSArray *members;

members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
allUsers = [NSMutableArray array];
allUsers = [NSMutableArray arrayWithArray: members];

for (i = 0; i < [members count]; i++)
{
[allUsers addObject: [[members objectAtIndex: i] objectForKey: @"c_uid"]];
}
// We remove the active user from the group (if present) in order to
// not subscribe him to their own resource!
[allUsers removeObject: [[context activeUser] login]];
[allUsers removeObject: [context activeUser]];
}
else
{
Expand All @@ -470,15 +467,17 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
}
else
{
if (dict)
allUsers = [NSArray arrayWithObject: [dict objectForKey: @"c_uid"]];
sogoUser = [SOGoUser userWithLogin: theIdentifier roles: nil];
if (sogoUser)
allUsers = [NSArray arrayWithObject: sogoUser];
else
allUsers = [NSArray array];
}

for (i = 0; i < [allUsers count]; i++)
{
us = [SOGoUserSettings settingsForUser: [allUsers objectAtIndex: i]];
sogoUser = [allUsers objectAtIndex: i];
us = [sogoUser userSettings];
moduleSettings = [us objectForKey: [container nameInContainer]];
if (!(moduleSettings
&& [moduleSettings isKindOfClass: [NSMutableDictionary class]]))
Expand Down Expand Up @@ -1520,7 +1519,7 @@ - (NSArray *) fetchFields: (NSArray *) _fields
BOOL rememberRecords, canCycle;
SOGoUser *ownerUser;

ownerUser = [SOGoUser userWithLogin: owner roles: nil];
ownerUser = [SOGoUser userWithLogin: self->owner roles: nil];
rememberRecords = [self _checkIfWeCanRememberRecords: _fields];
canCycle = [_component isEqualToString: @"vevent"] || [_component isEqualToString: @"vtodo"];
// if (rememberRecords)
Expand Down Expand Up @@ -1679,7 +1678,7 @@ - (NSArray *) fetchFields: (NSArray *) _fields
}

currentLogin = [[context activeUser] login];
if (![currentLogin isEqualToString: owner])
if (![currentLogin isEqualToString: self->owner])
{

if (!_includeProtectedInformation)
Expand Down
6 changes: 3 additions & 3 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Expand Up @@ -557,7 +557,7 @@ - (BOOL) expandGroupsInEvent: (iCalEvent *) theEvent
{
iCalPerson *person;
NSArray *members;
NSDictionary *user;
SOGoUser *user;
id <SOGoSource> source;

// We did decompose a group...
Expand All @@ -574,10 +574,10 @@ - (BOOL) expandGroupsInEvent: (iCalEvent *) theEvent

// If the organizer is part of the group, we skip it from
// the addition to the attendees' list
if ([[user objectForKey: @"c_emails"] containsObject: organizerEmail])
if ([user hasEmail: organizerEmail])
continue;

person = [self iCalPersonWithUID: [user objectForKey: @"c_uid"]];
person = [self iCalPersonWithUID: [user login]];
[person setTag: @"ATTENDEE"];
[person setParticipationStatus: [currentAttendee participationStatus]];
[person setRsvp: [currentAttendee rsvp]];
Expand Down
8 changes: 3 additions & 5 deletions SoObjects/SOGo/LDAPSource.m
Expand Up @@ -2085,8 +2085,7 @@ - (NSArray *) membersForGroupWithUID: (NSString *) uid
if (user)
{
[logins addObject: login];
[members addObject: [NSDictionary dictionaryWithObject: login
forKey: @"c_uid"]];
[members addObject: user];
}
[pool release];
}
Expand All @@ -2100,15 +2099,14 @@ - (NSArray *) membersForGroupWithUID: (NSString *) uid
if (user)
{
[logins addObject: login];
[members addObject: [NSDictionary dictionaryWithObject: login
forKey: @"c_uid"]];
[members addObject: user];
}
[pool release];
}


// We are done fetching members, let's cache the members of the group
// (ie., their UIDs) in memcached to speed up -hasMemberWithUID.
// (ie., their UIDs) in memcached to speed up -groupWithUIDHasMemberWithUID.
[[SOGoCache sharedCache] setValue: [logins componentsJoinedByString: @","]
forKey: [NSString stringWithFormat: @"%@+%@", uid, _domain]];
}
Expand Down
21 changes: 10 additions & 11 deletions SoObjects/SOGo/SOGoGCSFolder.m
Expand Up @@ -926,6 +926,7 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
NSString *subscriptionPointer, *domain;
NSMutableArray *allUsers;
SOGoUserSettings *us;
SOGoUser *sogoUser;
NSDictionary *dict;
BOOL rc;
int i;
Expand All @@ -944,15 +945,11 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
NSArray *members;

members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
allUsers = [NSMutableArray array];
allUsers = [NSMutableArray arrayWithArray: members];

for (i = 0; i < [members count]; i++)
{
[allUsers addObject: [[members objectAtIndex: i] objectForKey: @"c_uid"]];
}
// We remove the active user from the group (if present) in order to
// not subscribe him to their own resource!
[allUsers removeObject: [[context activeUser] login]];
[allUsers removeObject: [context activeUser]];
}
else
{
Expand All @@ -962,8 +959,9 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
}
else
{
if (dict)
allUsers = [NSArray arrayWithObject: [dict objectForKey: @"c_uid"]];
sogoUser = [SOGoUser userWithLogin: theIdentifier roles: nil];
if (sogoUser)
allUsers = [NSArray arrayWithObject: sogoUser];
else
allUsers = [NSArray array];
}
Expand All @@ -976,7 +974,8 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier

for (i = 0; i < [allUsers count]; i++)
{
us = [SOGoUserSettings settingsForUser: [allUsers objectAtIndex: i]];
sogoUser = [allUsers objectAtIndex: i];
us = [sogoUser userSettings];
moduleSettings = [us objectForKey: [container nameInContainer]];
if (!(moduleSettings
&& [moduleSettings isKindOfClass: [NSMutableDictionary class]]))
Expand Down Expand Up @@ -1797,16 +1796,16 @@ - (void) removeAclsForUsers: (NSArray *) users
source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]];
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
NSDictionary *user;
NSArray *members;
SOGoUser *user;
unsigned int j;

// Fetch members to remove them from the cache along the group
members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: uid];
for (j = 0; j < [members count]; j++)
{
user = [members objectAtIndex: j];
[groupsMembers addObject: [user objectForKey: @"c_uid"]];
[groupsMembers addObject: [user login]];
}

if (![uid hasPrefix: @"@"])
Expand Down
8 changes: 4 additions & 4 deletions UI/Contacts/UIxContactView.m
Expand Up @@ -397,7 +397,7 @@ - (NSArray *) deliveryAddresses
NSString *email;
SOGoObject <SOGoContactObject> *contact;
SOGoObject <SOGoSource> *source;
NSDictionary *user;
SOGoUser *user;
id <WOActionResults> result;
unsigned int i, max;

Expand All @@ -418,14 +418,14 @@ - (NSArray *) deliveryAddresses
{
user = [allUsers objectAtIndex: i];
allUserEmails = [NSMutableArray array];
emails = [[user objectForKey: @"c_emails"] objectEnumerator];
emails = [[user allEmails] objectEnumerator];
while ((email = [emails nextObject])) {
[allUserEmails addObject: [NSDictionary dictionaryWithObjectsAndKeys:
email, @"value", @"work", @"type", nil]];
}
userData = [NSDictionary dictionaryWithObjectsAndKeys:
[user objectForKey: @"c_uid"], @"c_uid",
[user objectForKey: @"c_cn"], @"c_cn",
[user loginInDomain], @"c_uid",
[user cn], @"c_cn",
allUserEmails, @"emails", nil];
[allUsersData addObject: userData];
}
Expand Down

0 comments on commit b8595d7

Please sign in to comment.