From ee12f0d30e7b89c1a61c406c92ea972470ed970e Mon Sep 17 00:00:00 2001 From: Johannes Kanefendt Date: Mon, 13 Jul 2020 11:22:22 +0200 Subject: [PATCH] Reverted commit b8595d7. Instead of that, turn instances of SOGoUser into contact entry dicts in [LDAPSource membersForGroupWithUID] --- .../Appointments/SOGoAppointmentFolder.m | 21 ++++++++++--------- .../Appointments/SOGoCalendarComponent.m | 6 +++--- SoObjects/SOGo/LDAPSource.m | 10 ++++++--- SoObjects/SOGo/SOGoGCSFolder.m | 21 ++++++++++--------- UI/Contacts/UIxContactView.m | 8 +++---- 5 files changed, 36 insertions(+), 30 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index c4b51f1415..27a773f3dc 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -429,7 +429,6 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier NSString *subscriptionPointer, *domain; NSMutableArray *allUsers; SOGoUserSettings *us; - SOGoUser *sogoUser; NSDictionary *dict; BOOL rc; int i; @@ -453,11 +452,15 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier NSArray *members; members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; - allUsers = [NSMutableArray arrayWithArray: members]; + allUsers = [NSMutableArray array]; + 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]]; + [allUsers removeObject: [[context activeUser] login]]; } else { @@ -467,17 +470,15 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier } else { - sogoUser = [SOGoUser userWithLogin: theIdentifier roles: nil]; - if (sogoUser) - allUsers = [NSArray arrayWithObject: sogoUser]; + if (dict) + allUsers = [NSArray arrayWithObject: [dict objectForKey: @"c_uid"]]; else allUsers = [NSArray array]; } for (i = 0; i < [allUsers count]; i++) { - sogoUser = [allUsers objectAtIndex: i]; - us = [sogoUser userSettings]; + us = [SOGoUserSettings settingsForUser: [allUsers objectAtIndex: i]]; moduleSettings = [us objectForKey: [container nameInContainer]]; if (!(moduleSettings && [moduleSettings isKindOfClass: [NSMutableDictionary class]])) @@ -1519,7 +1520,7 @@ - (NSArray *) fetchFields: (NSArray *) _fields BOOL rememberRecords, canCycle; SOGoUser *ownerUser; - ownerUser = [SOGoUser userWithLogin: self->owner roles: nil]; + ownerUser = [SOGoUser userWithLogin: owner roles: nil]; rememberRecords = [self _checkIfWeCanRememberRecords: _fields]; canCycle = [_component isEqualToString: @"vevent"] || [_component isEqualToString: @"vtodo"]; // if (rememberRecords) @@ -1678,7 +1679,7 @@ - (NSArray *) fetchFields: (NSArray *) _fields } currentLogin = [[context activeUser] login]; - if (![currentLogin isEqualToString: self->owner]) + if (![currentLogin isEqualToString: owner]) { if (!_includeProtectedInformation) diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 18b1a06164..14d627cf0c 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -557,7 +557,7 @@ - (BOOL) expandGroupsInEvent: (iCalEvent *) theEvent { iCalPerson *person; NSArray *members; - SOGoUser *user; + NSDictionary *user; id source; // We did decompose a group... @@ -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 hasEmail: organizerEmail]) + if ([[user objectForKey: @"c_emails"] containsObject: organizerEmail]) continue; - person = [self iCalPersonWithUID: [user login]]; + person = [self iCalPersonWithUID: [user objectForKey: @"c_uid"]]; [person setTag: @"ATTENDEE"]; [person setParticipationStatus: [currentAttendee participationStatus]]; [person setRsvp: [currentAttendee rsvp]]; diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index b2bb15aa6d..254b443534 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -2085,7 +2085,9 @@ - (NSArray *) membersForGroupWithUID: (NSString *) uid if (user) { [logins addObject: login]; - [members addObject: user]; + [members addObject: [NSDictionary dictionaryWithObjectsAndKeys: login, @"c_uid", + [user cn], @"c_cn", + [user allEmails], @"c_emails", nil]]; } [pool release]; } @@ -2099,14 +2101,16 @@ - (NSArray *) membersForGroupWithUID: (NSString *) uid if (user) { [logins addObject: login]; - [members addObject: user]; + [members addObject: [NSDictionary dictionaryWithObjectsAndKeys: login, @"c_uid", + [user cn], @"c_cn", + [user allEmails], @"c_emails", nil]]; } [pool release]; } // We are done fetching members, let's cache the members of the group - // (ie., their UIDs) in memcached to speed up -groupWithUIDHasMemberWithUID. + // (ie., their UIDs) in memcached to speed up -hasMemberWithUID. [[SOGoCache sharedCache] setValue: [logins componentsJoinedByString: @","] forKey: [NSString stringWithFormat: @"%@+%@", uid, _domain]]; } diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 814cb0e1a9..5676babd11 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -926,7 +926,6 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier NSString *subscriptionPointer, *domain; NSMutableArray *allUsers; SOGoUserSettings *us; - SOGoUser *sogoUser; NSDictionary *dict; BOOL rc; int i; @@ -945,11 +944,15 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier NSArray *members; members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; - allUsers = [NSMutableArray arrayWithArray: members]; + allUsers = [NSMutableArray array]; + 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]]; + [allUsers removeObject: [[context activeUser] login]]; } else { @@ -959,9 +962,8 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier } else { - sogoUser = [SOGoUser userWithLogin: theIdentifier roles: nil]; - if (sogoUser) - allUsers = [NSArray arrayWithObject: sogoUser]; + if (dict) + allUsers = [NSArray arrayWithObject: [dict objectForKey: @"c_uid"]]; else allUsers = [NSArray array]; } @@ -974,8 +976,7 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier for (i = 0; i < [allUsers count]; i++) { - sogoUser = [allUsers objectAtIndex: i]; - us = [sogoUser userSettings]; + us = [SOGoUserSettings settingsForUser: [allUsers objectAtIndex: i]]; moduleSettings = [us objectForKey: [container nameInContainer]]; if (!(moduleSettings && [moduleSettings isKindOfClass: [NSMutableDictionary class]])) @@ -1796,8 +1797,8 @@ - (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 @@ -1805,7 +1806,7 @@ - (void) removeAclsForUsers: (NSArray *) users for (j = 0; j < [members count]; j++) { user = [members objectAtIndex: j]; - [groupsMembers addObject: [user login]]; + [groupsMembers addObject: [user objectForKey: @"c_uid"]]; } if (![uid hasPrefix: @"@"]) diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index 21998231ca..1479c0a0d7 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -397,7 +397,7 @@ - (NSArray *) deliveryAddresses NSString *email; SOGoObject *contact; SOGoObject *source; - SOGoUser *user; + NSDictionary *user; id result; unsigned int i, max; @@ -418,14 +418,14 @@ - (NSArray *) deliveryAddresses { user = [allUsers objectAtIndex: i]; allUserEmails = [NSMutableArray array]; - emails = [[user allEmails] objectEnumerator]; + emails = [[user objectForKey: @"c_emails"] objectEnumerator]; while ((email = [emails nextObject])) { [allUserEmails addObject: [NSDictionary dictionaryWithObjectsAndKeys: email, @"value", @"work", @"type", nil]]; } userData = [NSDictionary dictionaryWithObjectsAndKeys: - [user loginInDomain], @"c_uid", - [user cn], @"c_cn", + [user objectForKey: @"c_uid"], @"c_uid", + [user objectForKey: @"c_cn"], @"c_cn", allUserEmails, @"emails", nil]; [allUsersData addObject: userData]; }