Merge pull request #263 from jkanefendt/revise-group-expansion

Revision of the group member expansion interface
This commit is contained in:
Extra Fu authored and GitHub committed 2020-04-02 09:52:21 -04:00
commit 62823815a7
15 files changed
+323 -595

No files matched your search

+8 -11
View File
@@ -27,7 +27,6 @@
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoDomainDefaults.h>
#import <SOGo/SOGoGroup.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserManager.h>
@@ -120,10 +119,10 @@
- (BOOL) _initRights
{
BOOL response;
NSString *newUID, *domain;
NSString *newUID;
SOGoUserManager *um;
SOGoObject *clientObject;
SOGoGroup *group;
NSDictionary *dict;
response = NO;
@@ -140,9 +139,8 @@
{
if (![newUID hasPrefix: @"@"])
{
domain = [[context activeUser] domain];
group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain];
if (group)
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: newUID];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
newUID = [NSString stringWithFormat: @"@%@", newUID];
}
ASSIGN (uid, newUID);
@@ -158,10 +156,9 @@
- (BOOL) _initRightsForUserID:(NSString *) newUID
{
BOOL response;
NSString *domain;
SOGoUserManager *um;
SOGoObject *clientObject;
SOGoGroup *group;
NSDictionary *dict;
response = NO;
@@ -174,11 +171,11 @@
if ([newUID isEqualToString: defaultUserID] || [newUID isEqualToString: @"anonymous"]
|| [[um getEmailForUID: newUID] length] > 0)
{
#warning Duplicated code from _initRights
if (![newUID hasPrefix: @"@"])
{
domain = [[context activeUser] domain];
group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain];
if (group)
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: newUID];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
newUID = [NSString stringWithFormat: @"@%@", newUID];
}
ASSIGN (uid, newUID);
+6 -12
View File
@@ -31,8 +31,6 @@
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/LDAPSource.h>
#import <SOGo/SOGoGroup.h>
#import <SOGo/SOGoSource.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
@@ -399,7 +397,7 @@
NSString *email;
SOGoObject <SOGoContactObject> *contact;
SOGoObject <SOGoSource> *source;
SOGoUser *user;
NSDictionary *user;
id <WOActionResults> result;
unsigned int i, max;
@@ -411,27 +409,23 @@
if ([[dict objectForKey: @"isGroup"] boolValue])
{
if ([source isKindOfClass: [LDAPSource class]] && [(LDAPSource *) source groupExpansionEnabled])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
SOGoGroup *aGroup;
aGroup = [SOGoGroup groupWithIdentifier: [contact nameInContainer]
inDomain: [[context activeUser] domain]];
allUsers = [aGroup members]; // array of SOGoUser objects
allUsers = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
max = [allUsers count];
allUsersData = [NSMutableArray arrayWithCapacity: max];
for (i = 0; i < max; i++)
{
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];
}