Skip to content

Commit

Permalink
New paramter SOGoLDAPGroupExpansionEnabled
Browse files Browse the repository at this point in the history
Fixes #2506
  • Loading branch information
cgx committed Sep 5, 2019
1 parent 1641235 commit 25021c1
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 25 deletions.
6 changes: 6 additions & 0 deletions Documentation/SOGoInstallationGuide.asciidoc
Expand Up @@ -1173,6 +1173,12 @@ for operations is also bounded by the maximum time that the server is
configured to allow.
Defaults to `0` (unlimited).
|D |SOGoLDAPGroupExpansionEnabled
|Parameter used to enable group expansion from the Web interface.
Defaults to `NO` when unset.
|=======================================================================
LDAP Attributes Indexing
Expand Down
3 changes: 3 additions & 0 deletions SoObjects/SOGo/LDAPSource.h
Expand Up @@ -67,6 +67,7 @@

NSString *_domain;
NSString *_contactInfoAttribute;
BOOL _groupExpansionEnabled;

NSDictionary *_contactMapping;
NSArray *_contactObjectClasses;
Expand Down Expand Up @@ -125,6 +126,8 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField;

- (void) updateBaseDNFromLogin: (NSString *) theLogin;

- (BOOL) groupExpansionEnabled;

@end

#endif /* LDAPSOURCE_H */
15 changes: 14 additions & 1 deletion SoObjects/SOGo/LDAPSource.m
Expand Up @@ -165,7 +165,7 @@ - (id) initFromUDSource: (NSDictionary *) udSource
inDomain: (NSString *) sourceDomain
{
SOGoDomainDefaults *dd;
NSNumber *udQueryLimit, *udQueryTimeout, *dotValue;
NSNumber *udQueryLimit, *udQueryTimeout, *udGroupExpansionEnabled, *dotValue;

if ((self = [self init]))
{
Expand Down Expand Up @@ -238,6 +238,14 @@ - (id) initFromUDSource: (NSDictionary *) udSource
else
_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(_filter, [udSource objectForKey: @"filter"]);
ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]);
Expand Down Expand Up @@ -1461,6 +1469,11 @@ - (NSArray *) groupObjectClasses
return _groupObjectClasses;
}

- (BOOL) groupExpansionEnabled
{
return _groupExpansionEnabled;
}

static NSArray *
_convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifRecord)
{
Expand Down
2 changes: 2 additions & 0 deletions SoObjects/SOGo/SOGoDomainDefaults.h
Expand Up @@ -75,6 +75,8 @@
- (NSArray *) freeBusyDefaultInterval;
- (int) davCalendarStartTimeLimit;

- (BOOL) ldapGroupExpansionEnabled;

- (BOOL) iPhoneForceAllDayTransparency;

- (NSArray *) additionalJSFiles;
Expand Down
5 changes: 5 additions & 0 deletions SoObjects/SOGo/SOGoDomainDefaults.m
Expand Up @@ -314,6 +314,11 @@ - (NSString *) ldapContactInfoAttribute
return [self stringForKey: @"SOGoLDAPContactInfoAttribute"];
}

- (BOOL) ldapGroupExpansionEnabled
{
return [self boolForKey: @"SOGoLDAPGroupExpansionEnabled"];
}

- (NSArray *) freeBusyDefaultInterval
{
return [self arrayForKey: @"SOGoFreeBusyDefaultInterval"];
Expand Down
64 changes: 41 additions & 23 deletions UI/Contacts/UIxContactView.m
Expand Up @@ -31,7 +31,9 @@
#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>
#import <SOGo/SOGoUserManager.h>
Expand Down Expand Up @@ -395,42 +397,58 @@ - (NSArray *) deliveryAddresses
NSMutableDictionary *userData;
NSString *email;
SOGoObject <SOGoContactObject> *contact;
SOGoObject <SOGoSource> *source;
SOGoUser *user;
id <WOActionResults> result;
unsigned int i, max;

result = nil;
contact = [self clientObject];
source = [[contact container] source];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [contact nameInContainer]];

if ([[dict objectForKey: @"isGroup"] boolValue])
{
SOGoGroup *aGroup;

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++)
if ([source isKindOfClass: [LDAPSource class]] && [(LDAPSource *) source groupExpansionEnabled])
{
user = [allUsers objectAtIndex: i];
allUserEmails = [NSMutableArray array];
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];
SOGoGroup *aGroup;

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];
allUserEmails = [NSMutableArray array];
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]];
}
dict = [NSDictionary dictionaryWithObject: allUsersData forKey: @"members"];
result = [self responseWithStatus: 200
andString: [dict jsonRepresentation]];
else
{
result = [self responseWithStatus: 403
andString: @"Group is not expandable"];
}
}
else
{
result = [self responseWithStatus: 405
andString: @"Contact is not a group"];
}

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion UI/Templates/SchedulerUI/UIxAttendeesEditor.wox
Expand Up @@ -70,7 +70,7 @@
<div class="sg-md-subhead"><div>{{currentAttendee.name}}</div></div>
<div class="sg-md-body">
<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-button>
</div>
Expand Down
2 changes: 2 additions & 0 deletions UI/WebServerResources/js/Scheduler/Attendees.service.js
Expand Up @@ -171,6 +171,7 @@
domain: card.c_domain,
isMSExchange: card.ismsexchange,
isGroup: card.$isList(),
isExpandableGroup: false,
isResource: card.isresource,
name: card.c_cn,
email: card.$$email,
Expand All @@ -185,6 +186,7 @@
// LDAP list -- preload members
card.$members().then(function(members) {
attendee.members = members;
attendee.isExpandableGroup = true;
});
}
attendee.image = Attendees.$gravatar(attendee.email, 32);
Expand Down

0 comments on commit 25021c1

Please sign in to comment.