Skip to content

Commit

Permalink
fix(addressbook): Removed SOGoGlobalAddressBookFirstEntries (use list…
Browse files Browse the repository at this point in the history
…RequiresDot instead) and move SOGoGlobalAddressBookFirstEntriesCount to globalAddressBookFirstEntriesCount in source scope. This fixed the broken listRequiresDot in 5.10
  • Loading branch information
WoodySlum committed Feb 26, 2024
1 parent 776a798 commit 4dba56f
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 64 deletions.
9 changes: 3 additions & 6 deletions Documentation/SOGoInstallationGuide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,6 @@ specified as an array of dictionaries.
|S |SOGoURLEncryptionPassphrase
|Passphrase for `SOGoURLEncryptionEnabled`. The string must be 128 bits (16 characters). If this settings change, the cache server must be restarted, and the DAV url will change. Default value is `SOGoSuperSecret0`.
|S |SOGoGlobalAddressBookFirstEntries
|Display first entries in Global Address Book. Default value is `NO`. If source is LDAP, the LDAP overlay `sssvlv` must be enabled on the system for server side sorting.
|S |SOGoGlobalAddressBookFirstEntriesCount
|Number of entries displayed when `SOGoGlobalAddressBookFirstEntries` is enabled. Default value is `100`.
|=======================================================================
Expand Down Expand Up @@ -1273,6 +1267,9 @@ repository
|If set to `YES`, listing of this LDAP source is only possible when performing a search (respecting the SOGoSearchMinimumWordLength parameter) or when explicitly typing a single dot.
Defaults to `YES` when unset.
|globalAddressBookFirstEntriesCount (optional)
|Number of entries displayed when `listRequiresDot` is enabled. Default value is `-1` (all records). If source is LDAP, the LDAP overlay sssvlv must be enabled on the system for server side sorting.
|ModulesConstraints (optional)
|Limits the access of any module through a constraint based on an LDAP
attribute; must be a dictionary with keys `Mail`, and/or `Calendar`,
Expand Down
65 changes: 29 additions & 36 deletions SoObjects/Contacts/SOGoContactSourceFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ - (BOOL) listRequiresDot
return [source listRequiresDot];
}

- (BOOL) globalAddressBookFirstEntriesCount
{
return [source globalAddressBookFirstEntriesCount];
}

- (NSString *) groupDavResourceType
{
return @"vcard-collection";
Expand Down Expand Up @@ -433,45 +438,33 @@ - (NSArray *) lookupContactsWithFilter: (NSString *) filter
{
NSArray *records, *result;
EOSortOrdering *ordering;
BOOL processed;

result = nil;
processed = NO;

[source setListRequiresDot: NO];
if ( ![source listRequiresDot])
{
if ([filter length] > 0) {
records = [source fetchContactsMatching: filter
withCriteria: criteria
inDomain: domain];
processed = YES;
} else if ([[SOGoSystemDefaults sharedSystemDefaults] globalAddressBookFirstEntriesEnabled]) {
records = [source fetchContactsMatching: filter
withCriteria: criteria
inDomain: domain
limit: [[SOGoSystemDefaults sharedSystemDefaults] globalAddressBookFirstEntriesCount]];
processed = YES;
}

if (processed) {
[childRecords setObjects: records
forKeys: [records objectsForKey: @"c_name"
notFoundMarker: nil]];
records = [self _flattenedRecords: records];
ordering
= [EOSortOrdering sortOrderingWithKey: sortKey
selector: ((sortOrdering == NSOrderedDescending)
? EOCompareCaseInsensitiveDescending
: EOCompareCaseInsensitiveAscending)];
result
= [records sortedArrayUsingKeyOrderArray:
[NSArray arrayWithObject: ordering]];
}


}

if (![source listRequiresDot]) {
records = [source fetchContactsMatching: filter
withCriteria: criteria
inDomain: domain
limit: [source globalAddressBookFirstEntriesCount]];
} else {
records = [source fetchContactsMatching: filter
withCriteria: criteria
inDomain: domain];

}

[childRecords setObjects: records
forKeys: [records objectsForKey: @"c_name"
notFoundMarker: nil]];
records = [self _flattenedRecords: records];
ordering
= [EOSortOrdering sortOrderingWithKey: sortKey
selector: ((sortOrdering == NSOrderedDescending)
? EOCompareCaseInsensitiveDescending
: EOCompareCaseInsensitiveAscending)];
result
= [records sortedArrayUsingKeyOrderArray:
[NSArray arrayWithObject: ordering]];
return result;
}

Expand Down
1 change: 1 addition & 0 deletions SoObjects/SOGo/LDAPSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
NSArray *_bindFields;

BOOL _listRequiresDot;
int _globalAddressBookFirstEntriesCount;

NSString *_domain;
NSString *_contactInfoAttribute;
Expand Down
18 changes: 17 additions & 1 deletion SoObjects/SOGo/LDAPSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ - (id) init
_filter = nil;
_userPasswordAlgorithm = nil;
_listRequiresDot = YES;
_globalAddressBookFirstEntriesCount = -1;

_passwordPolicy = NO;
_updateSambaNTLMPasswords = NO;
Expand Down Expand Up @@ -200,10 +201,15 @@ - (id) initFromUDSource: (NSDictionary *) udSource
andMultipleBookingsField: [udSource objectForKey: @"MultipleBookingsFieldName"]];

dotValue = [udSource objectForKey: @"listRequiresDot"];
if (dotValue)
if (dotValue) {
[self setListRequiresDot: [dotValue boolValue]];
if ([udSource objectForKey: @"globalAddressBookFirstEntriesCount"])
[self setGlobalAddressBookFirstEntriesCount: [[udSource objectForKey: @"globalAddressBookFirstEntriesCount"] intValue]];
}

[self setContactMapping: [udSource objectForKey: @"mapping"]
andObjectClasses: [udSource objectForKey: @"objectClasses"]];


[self setModifiers: [udSource objectForKey: @"modifiers"]];
ASSIGN(_abOU, [udSource objectForKey: @"abOU"]);
Expand Down Expand Up @@ -400,6 +406,16 @@ - (BOOL) listRequiresDot
return _listRequiresDot;
}

- (void) setGlobalAddressBookFirstEntriesCount: (int)value
{
_globalAddressBookFirstEntriesCount = value;
}

- (int) globalAddressBookFirstEntriesCount
{
return _globalAddressBookFirstEntriesCount;
}

- (NSArray *) searchFields
{
return _searchFields;
Expand Down
2 changes: 2 additions & 0 deletions SoObjects/SOGo/SOGoSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
/* requires a "." to obtain the full list of contacts */
- (void) setListRequiresDot: (BOOL) aBool;
- (BOOL) listRequiresDot;
- (void) setGlobalAddressBookFirstEntriesCount: (int)value;
- (int) globalAddressBookFirstEntriesCount;

- (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd
Expand Down
3 changes: 0 additions & 3 deletions SoObjects/SOGo/SOGoSystemDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ NSComparisonResult languageSort(id el1, id el2, void *context);
- (NSArray *) disableSharingAnyAuthUser;
- (NSArray *) disableExport;

- (BOOL) enableGlobalAddressBookFirstEntries;
- (int) globalAddressBookFirstEntriesCount;

- (BOOL)isURLEncryptionEnabled;
- (NSString *)urlEncryptionPassphrase;

Expand Down
17 changes: 0 additions & 17 deletions SoObjects/SOGo/SOGoSystemDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -917,21 +917,4 @@ - (NSArray *) disableExport
return disableExport;
}

- (BOOL) globalAddressBookFirstEntriesEnabled
{
return [self boolForKey: @"SOGoGlobalAddressBookFirstEntries"];
}

- (int) globalAddressBookFirstEntriesCount
{
int v;

v = [self integerForKey: @"SOGoGlobalAddressBookFirstEntriesCount"];

if (!v)
v = 100;

return v;
}

@end
1 change: 1 addition & 0 deletions SoObjects/SOGo/SQLSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
NSString *_multipleBookingsField;

BOOL _listRequiresDot;
int _globalAddressBookFirstEntriesCount;

NSDictionary *_modulesConstraints;
}
Expand Down
17 changes: 16 additions & 1 deletion SoObjects/SOGo/SQLSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ - (id) init
_imapHostField = nil;
_sieveHostField = nil;
_listRequiresDot = YES;
_globalAddressBookFirstEntriesCount = -1;
_modulesConstraints = nil;
}

Expand Down Expand Up @@ -170,8 +171,12 @@ - (id) initFromUDSource: (NSDictionary *) udSource
_viewURL = [[NSURL alloc] initWithString: [udSource objectForKey: @"viewURL"]];

dotValue = [udSource objectForKey: @"listRequiresDot"];
if (dotValue)
if (dotValue) {
[self setListRequiresDot: [dotValue boolValue]];
if ([udSource objectForKey: @"globalAddressBookFirstEntriesCount"])
[self setGlobalAddressBookFirstEntriesCount: [[udSource objectForKey: @"globalAddressBookFirstEntriesCount"] intValue]];
}


#warning this domain code has no effect yet
if ([sourceDomain length])
Expand Down Expand Up @@ -1156,6 +1161,16 @@ - (BOOL) listRequiresDot
return _listRequiresDot;
}

- (void) setGlobalAddressBookFirstEntriesCount: (int)value
{
_globalAddressBookFirstEntriesCount = value;
}

- (int) globalAddressBookFirstEntriesCount
{
return _globalAddressBookFirstEntriesCount;
}

/* card editing */
- (void) setModifiers: (NSArray *) newModifiers
{
Expand Down

0 comments on commit 4dba56f

Please sign in to comment.