Skip to content

Commit

Permalink
fix(addressbook): respect visible domains when fetching contact
Browse files Browse the repository at this point in the history
Fixes #4896
  • Loading branch information
cgx committed Jan 11, 2022
1 parent cf34182 commit 368360b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
4 changes: 3 additions & 1 deletion SoObjects/SOGo/SQLSource.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -55,6 +55,8 @@
NSDictionary *_modulesConstraints;
}

- (EOQualifier *) visibleDomainsQualifierFromDomain: (NSString *) domain;

@end

#endif /* SQLSOURCE_H */
25 changes: 9 additions & 16 deletions SoObjects/SOGo/SQLSource.m
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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])
Expand Down Expand Up @@ -795,8 +789,7 @@ - (NSArray *) allEntryIDsVisibleFromDomain: (NSString *) domain
{
if ([domain length])
{
domainQualifier =
[self _visibleDomainsQualifierFromDomain: domain];
domainQualifier = [self visibleDomainsQualifierFromDomain: domain];
if (domainQualifier)
{
[sql appendString: @" WHERE "];
Expand Down Expand Up @@ -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 ("];
Expand Down

0 comments on commit 368360b

Please sign in to comment.