New paramter SOGoLDAPGroupExpansionEnabled

Fixes #2506
pull/259/head
Francis Lachapelle 2019-09-05 12:42:25 -04:00
parent 1641235163
commit 25021c192c
8 changed files with 74 additions and 25 deletions

View File

@ -1173,6 +1173,12 @@ for operations is also bounded by the maximum time that the server is
configured to allow. configured to allow.
Defaults to `0` (unlimited). Defaults to `0` (unlimited).
|D |SOGoLDAPGroupExpansionEnabled
|Parameter used to enable group expansion from the Web interface.
Defaults to `NO` when unset.
|======================================================================= |=======================================================================
LDAP Attributes Indexing LDAP Attributes Indexing

View File

@ -67,6 +67,7 @@
NSString *_domain; NSString *_domain;
NSString *_contactInfoAttribute; NSString *_contactInfoAttribute;
BOOL _groupExpansionEnabled;
NSDictionary *_contactMapping; NSDictionary *_contactMapping;
NSArray *_contactObjectClasses; NSArray *_contactObjectClasses;
@ -125,6 +126,8 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField;
- (void) updateBaseDNFromLogin: (NSString *) theLogin; - (void) updateBaseDNFromLogin: (NSString *) theLogin;
- (BOOL) groupExpansionEnabled;
@end @end
#endif /* LDAPSOURCE_H */ #endif /* LDAPSOURCE_H */

View File

@ -165,7 +165,7 @@ static Class NSStringK;
inDomain: (NSString *) sourceDomain inDomain: (NSString *) sourceDomain
{ {
SOGoDomainDefaults *dd; SOGoDomainDefaults *dd;
NSNumber *udQueryLimit, *udQueryTimeout, *dotValue; NSNumber *udQueryLimit, *udQueryTimeout, *udGroupExpansionEnabled, *dotValue;
if ((self = [self init])) if ((self = [self init]))
{ {
@ -238,6 +238,14 @@ static Class NSStringK;
else else
_queryTimeout = [dd ldapQueryTimeout]; _queryTimeout = [dd ldapQueryTimeout];
if ([[udSource allKeys] containsObject: @"SOGoLDAPGroupExpansionEnabled"])
{
udGroupExpansionEnabled = [udSource objectForKey: @"SOGoLDAPGroupExpansionEnabled"];
_groupExpansionEnabled = [udGroupExpansionEnabled boolValue];
}
else
_groupExpansionEnabled = [dd ldapGroupExpansionEnabled];
ASSIGN(_modulesConstraints, [udSource objectForKey: @"ModulesConstraints"]); ASSIGN(_modulesConstraints, [udSource objectForKey: @"ModulesConstraints"]);
ASSIGN(_filter, [udSource objectForKey: @"filter"]); ASSIGN(_filter, [udSource objectForKey: @"filter"]);
ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]); ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]);
@ -1461,6 +1469,11 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
return _groupObjectClasses; return _groupObjectClasses;
} }
- (BOOL) groupExpansionEnabled
{
return _groupExpansionEnabled;
}
static NSArray * static NSArray *
_convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifRecord) _convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifRecord)
{ {

View File

@ -75,6 +75,8 @@
- (NSArray *) freeBusyDefaultInterval; - (NSArray *) freeBusyDefaultInterval;
- (int) davCalendarStartTimeLimit; - (int) davCalendarStartTimeLimit;
- (BOOL) ldapGroupExpansionEnabled;
- (BOOL) iPhoneForceAllDayTransparency; - (BOOL) iPhoneForceAllDayTransparency;
- (NSArray *) additionalJSFiles; - (NSArray *) additionalJSFiles;

View File

@ -314,6 +314,11 @@
return [self stringForKey: @"SOGoLDAPContactInfoAttribute"]; return [self stringForKey: @"SOGoLDAPContactInfoAttribute"];
} }
- (BOOL) ldapGroupExpansionEnabled
{
return [self boolForKey: @"SOGoLDAPGroupExpansionEnabled"];
}
- (NSArray *) freeBusyDefaultInterval - (NSArray *) freeBusyDefaultInterval
{ {
return [self arrayForKey: @"SOGoFreeBusyDefaultInterval"]; return [self arrayForKey: @"SOGoFreeBusyDefaultInterval"];

View File

@ -31,7 +31,9 @@
#import <SOGo/NSArray+Utilities.h> #import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSCalendarDate+SOGo.h> #import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/NSDictionary+Utilities.h> #import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/LDAPSource.h>
#import <SOGo/SOGoGroup.h> #import <SOGo/SOGoGroup.h>
#import <SOGo/SOGoSource.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h> #import <SOGo/SOGoUserDefaults.h>
#import <SOGo/SOGoUserManager.h> #import <SOGo/SOGoUserManager.h>
@ -395,42 +397,58 @@
NSMutableDictionary *userData; NSMutableDictionary *userData;
NSString *email; NSString *email;
SOGoObject <SOGoContactObject> *contact; SOGoObject <SOGoContactObject> *contact;
SOGoObject <SOGoSource> *source;
SOGoUser *user; SOGoUser *user;
id <WOActionResults> result; id <WOActionResults> result;
unsigned int i, max; unsigned int i, max;
result = nil; result = nil;
contact = [self clientObject]; contact = [self clientObject];
source = [[contact container] source];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [contact nameInContainer]]; dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [contact nameInContainer]];
if ([[dict objectForKey: @"isGroup"] boolValue]) if ([[dict objectForKey: @"isGroup"] boolValue])
{ {
SOGoGroup *aGroup; if ([source isKindOfClass: [LDAPSource class]] && [(LDAPSource *) source groupExpansionEnabled])
aGroup = [SOGoGroup groupWithIdentifier: [contact nameInContainer]
inDomain: [[context activeUser] domain]];
allUsers = [aGroup members]; // array of SOGoUser objects
max = [allUsers count];
allUsersData = [NSMutableArray arrayWithCapacity: max];
for (i = 0; i < max; i++)
{ {
user = [allUsers objectAtIndex: i]; SOGoGroup *aGroup;
allUserEmails = [NSMutableArray array];
emails = [[user allEmails] objectEnumerator]; aGroup = [SOGoGroup groupWithIdentifier: [contact nameInContainer]
while ((email = [emails nextObject])) { inDomain: [[context activeUser] domain]];
[allUserEmails addObject: [NSDictionary dictionaryWithObjectsAndKeys: allUsers = [aGroup members]; // array of SOGoUser objects
email, @"value", @"work", @"type", nil]]; max = [allUsers count];
} allUsersData = [NSMutableArray arrayWithCapacity: max];
userData = [NSDictionary dictionaryWithObjectsAndKeys: for (i = 0; i < max; i++)
[user loginInDomain], @"c_uid", {
[user cn], @"c_cn", user = [allUsers objectAtIndex: i];
allUserEmails, @"emails", nil]; allUserEmails = [NSMutableArray array];
[allUsersData addObject: userData]; emails = [[user allEmails] 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",
allUserEmails, @"emails", nil];
[allUsersData addObject: userData];
}
dict = [NSDictionary dictionaryWithObject: allUsersData forKey: @"members"];
result = [self responseWithStatus: 200
andString: [dict jsonRepresentation]];
}
else
{
result = [self responseWithStatus: 403
andString: @"Group is not expandable"];
} }
dict = [NSDictionary dictionaryWithObject: allUsersData forKey: @"members"];
result = [self responseWithStatus: 200
andString: [dict jsonRepresentation]];
} }
else
{
result = [self responseWithStatus: 405
andString: @"Contact is not a group"];
}
return result; return result;
} }

View File

@ -70,7 +70,7 @@
<div class="sg-md-subhead"><div>{{currentAttendee.name}}</div></div> <div class="sg-md-subhead"><div>{{currentAttendee.name}}</div></div>
<div class="sg-md-body"> <div class="sg-md-body">
<div>{{currentAttendee.email}}</div> <div>{{currentAttendee.email}}</div>
<md-button class="sg-tile-thread" md-colors="::{ color: 'accent-600'}" ng-if="currentAttendee.isGroup" ng-click="editor.expandAttendee(currentAttendee)"> <md-button class="sg-tile-thread" md-colors="::{ color: 'accent-600'}" ng-if="currentAttendee.isExpandableGroup" ng-click="editor.expandAttendee(currentAttendee)">
<md-icon class="md-rotate-180-ccw" md-colors="::{ color: 'accent-600'}">add_box</md-icon><span ng-bind="currentAttendee.members.length"></span> <md-icon class="md-rotate-180-ccw" md-colors="::{ color: 'accent-600'}">add_box</md-icon><span ng-bind="currentAttendee.members.length"></span>
</md-button> </md-button>
</div> </div>

View File

@ -171,6 +171,7 @@
domain: card.c_domain, domain: card.c_domain,
isMSExchange: card.ismsexchange, isMSExchange: card.ismsexchange,
isGroup: card.$isList(), isGroup: card.$isList(),
isExpandableGroup: false,
isResource: card.isresource, isResource: card.isresource,
name: card.c_cn, name: card.c_cn,
email: card.$$email, email: card.$$email,
@ -185,6 +186,7 @@
// LDAP list -- preload members // LDAP list -- preload members
card.$members().then(function(members) { card.$members().then(function(members) {
attendee.members = members; attendee.members = members;
attendee.isExpandableGroup = true;
}); });
} }
attendee.image = Attendees.$gravatar(attendee.email, 32); attendee.image = Attendees.$gravatar(attendee.email, 32);