From 368360bb95dd66123851cb3d585d8548486d84af Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 11 Jan 2022 16:40:53 -0500 Subject: [PATCH] fix(addressbook): respect visible domains when fetching contact Fixes #4896 --- SoObjects/SOGo/SQLSource.h | 4 +++- SoObjects/SOGo/SQLSource.m | 25 +++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/SoObjects/SOGo/SQLSource.h b/SoObjects/SOGo/SQLSource.h index bcf64eea87..a9e957d8cd 100644 --- a/SoObjects/SOGo/SQLSource.h +++ b/SoObjects/SOGo/SQLSource.h @@ -1,6 +1,6 @@ /* SQLSource.h - this file is part of SOGo * - * Copyright (C) 2009-2020 Inverse inc. + * Copyright (C) 2009-2022 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,6 +55,8 @@ NSDictionary *_modulesConstraints; } +- (EOQualifier *) visibleDomainsQualifierFromDomain: (NSString *) domain; + @end #endif /* SQLSOURCE_H */ diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 8465752d0b..a10e551c76 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -1,6 +1,6 @@ /* SQLSource.h - this file is part of SOGo * - * Copyright (C) 2009-2021 Inverse inc. + * Copyright (C) 2009-2022 Inverse inc. * * This file is part of SOGo. * @@ -487,13 +487,8 @@ - (NSDictionary *) _lookupContactEntry: (NSString *) theID } domainQualifier = nil; - if (_domainField && domain) - { - domainQualifier = [[EOKeyValueQualifier alloc] initWithKey: _domainField - operatorSelector: EOQualifierOperatorEqual - value: domain]; - [domainQualifier autorelease]; - } + if (_domainField && [domain length]) + domainQualifier = [self visibleDomainsQualifierFromDomain: domain]; if (b) { @@ -727,7 +722,7 @@ - (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID * (_domainField = domain OR _domainField = visibleDomain1 [...]) * Should only be called on SQL sources using _domainField name. */ -- (EOQualifier *) _visibleDomainsQualifierFromDomain: (NSString *) domain +- (EOQualifier *) visibleDomainsQualifierFromDomain: (NSString *) domain { int i; EOQualifier *qualifier, *domainQualifier; @@ -745,10 +740,9 @@ - (EOQualifier *) _visibleDomainsQualifierFromDomain: (NSString *) domain visibleDomains = [sd visibleDomainsForDomain: domain]; qualifier = nil; - domainQualifier = - [[EOKeyValueQualifier alloc] initWithKey: _domainField - operatorSelector: EOQualifierOperatorEqual - value: domain]; + domainQualifier = [[EOKeyValueQualifier alloc] initWithKey: _domainField + operatorSelector: EOQualifierOperatorEqual + value: domain]; [domainQualifier autorelease]; if ([visibleDomains count]) @@ -795,8 +789,7 @@ - (NSArray *) allEntryIDsVisibleFromDomain: (NSString *) domain { if ([domain length]) { - domainQualifier = - [self _visibleDomainsQualifierFromDomain: domain]; + domainQualifier = [self visibleDomainsQualifierFromDomain: domain]; if (domainQualifier) { [sql appendString: @" WHERE "]; @@ -905,7 +898,7 @@ - (NSArray *) fetchContactsMatching: (NSString *) filter if ([domain length]) { EOQualifier *domainQualifier; - domainQualifier = [self _visibleDomainsQualifierFromDomain: domain]; + domainQualifier = [self visibleDomainsQualifierFromDomain: domain]; if (domainQualifier) { [sql appendFormat: @" AND ("];