diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 712d6c74e..511a60c0e 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -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`. - |======================================================================= @@ -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`, diff --git a/SoObjects/Contacts/SOGoContactSourceFolder.m b/SoObjects/Contacts/SOGoContactSourceFolder.m index 5f89f2c2d..c11bb1991 100644 --- a/SoObjects/Contacts/SOGoContactSourceFolder.m +++ b/SoObjects/Contacts/SOGoContactSourceFolder.m @@ -127,6 +127,11 @@ return [source listRequiresDot]; } +- (BOOL) globalAddressBookFirstEntriesCount +{ + return [source globalAddressBookFirstEntriesCount]; +} + - (NSString *) groupDavResourceType { return @"vcard-collection"; @@ -433,45 +438,33 @@ { 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 (![source listRequiresDot]) { + records = [source fetchContactsMatching: filter + withCriteria: criteria + inDomain: domain + limit: [source globalAddressBookFirstEntriesCount]]; + } else { + records = [source fetchContactsMatching: filter + withCriteria: criteria + inDomain: domain]; - 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]]; - } - - - } + } + [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; } diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index d2446dd96..8c2b858b4 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -64,6 +64,7 @@ NSArray *_bindFields; BOOL _listRequiresDot; + int _globalAddressBookFirstEntriesCount; NSString *_domain; NSString *_contactInfoAttribute; diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 3eb820943..bf6b95496 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -106,6 +106,7 @@ static Class NSStringK; _filter = nil; _userPasswordAlgorithm = nil; _listRequiresDot = YES; + _globalAddressBookFirstEntriesCount = -1; _passwordPolicy = NO; _updateSambaNTLMPasswords = NO; @@ -200,10 +201,15 @@ static Class NSStringK; 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"]); @@ -400,6 +406,16 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses return _listRequiresDot; } +- (void) setGlobalAddressBookFirstEntriesCount: (int)value +{ + _globalAddressBookFirstEntriesCount = value; +} + +- (int) globalAddressBookFirstEntriesCount +{ + return _globalAddressBookFirstEntriesCount; +} + - (NSArray *) searchFields { return _searchFields; diff --git a/SoObjects/SOGo/SOGoSource.h b/SoObjects/SOGo/SOGoSource.h index a9510956c..fb9d4b31f 100644 --- a/SoObjects/SOGo/SOGoSource.h +++ b/SoObjects/SOGo/SOGoSource.h @@ -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 diff --git a/SoObjects/SOGo/SOGoSystemDefaults.h b/SoObjects/SOGo/SOGoSystemDefaults.h index 5f38ead9a..a0f617d11 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.h +++ b/SoObjects/SOGo/SOGoSystemDefaults.h @@ -135,9 +135,6 @@ NSComparisonResult languageSort(id el1, id el2, void *context); - (NSArray *) disableSharingAnyAuthUser; - (NSArray *) disableExport; -- (BOOL) enableGlobalAddressBookFirstEntries; -- (int) globalAddressBookFirstEntriesCount; - - (BOOL)isURLEncryptionEnabled; - (NSString *)urlEncryptionPassphrase; diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index 160a14dda..40e590eca 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -917,21 +917,4 @@ NSComparisonResult languageSort(id el1, id el2, void *context) return disableExport; } -- (BOOL) globalAddressBookFirstEntriesEnabled -{ - return [self boolForKey: @"SOGoGlobalAddressBookFirstEntries"]; -} - -- (int) globalAddressBookFirstEntriesCount -{ - int v; - - v = [self integerForKey: @"SOGoGlobalAddressBookFirstEntriesCount"]; - - if (!v) - v = 100; - - return v; -} - @end diff --git a/SoObjects/SOGo/SQLSource.h b/SoObjects/SOGo/SQLSource.h index d44df1386..b3bc9d05a 100644 --- a/SoObjects/SOGo/SQLSource.h +++ b/SoObjects/SOGo/SQLSource.h @@ -52,6 +52,7 @@ NSString *_multipleBookingsField; BOOL _listRequiresDot; + int _globalAddressBookFirstEntriesCount; NSDictionary *_modulesConstraints; } diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index a03c6bc01..9bda6788f 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -108,6 +108,7 @@ _imapHostField = nil; _sieveHostField = nil; _listRequiresDot = YES; + _globalAddressBookFirstEntriesCount = -1; _modulesConstraints = nil; } @@ -170,8 +171,12 @@ _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]) @@ -1156,6 +1161,16 @@ return _listRequiresDot; } +- (void) setGlobalAddressBookFirstEntriesCount: (int)value +{ + _globalAddressBookFirstEntriesCount = value; +} + +- (int) globalAddressBookFirstEntriesCount +{ + return _globalAddressBookFirstEntriesCount; +} + /* card editing */ - (void) setModifiers: (NSArray *) newModifiers {