mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-04 12:58:50 +00:00
See ChangeLog.
Monotone-Parent: d4394b4b92fdfda720d67698c9fbadc75787ad18 Monotone-Revision: e8c7d8a4465a1b9357c1d9f201dec2b93c5f3507 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-02-11T07:08:02 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
25
ChangeLog
25
ChangeLog
@@ -5,9 +5,34 @@
|
||||
|
||||
2012-02-22 Francis Lachapelle <flachapelle@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoUserManager.m
|
||||
(-authenticationSourceIDsInDomain:): when looking for a specific
|
||||
domain, also return sources that are not associated to a domain.
|
||||
|
||||
* SoObjects/SOGo/SOGoSource.h
|
||||
(-lookupContactEntryWithUIDorEmail:inDomain:): changed this method
|
||||
of the protocol to specify a domain.
|
||||
(-fetchContactsMatching:inDomain:): idem.
|
||||
|
||||
* SoObjects/Contacts/SOGoContactFolder.h
|
||||
(-lookupContactsWithFilter:onCriteria:sortBy:ordering:inDomain:):
|
||||
changed this method of the protocol to specify a domain.
|
||||
|
||||
* UI/WebServerResources/UIxAclEditor.js (addUser): fixed case when
|
||||
both canSubscribeUsers and isPublicAccessEnabled are disabled.
|
||||
|
||||
* SoObjects/SOGo/SQLSource.m
|
||||
(-_lookupContactEntry:considerEmail:inDomain:): if the configuration
|
||||
parameter DomainFieldName is defined for the source, set the user
|
||||
domain to the value of this field.
|
||||
(-fetchContactsMatching:inDomain:): when the configuration parameter
|
||||
DomainField is defined, limit the results to the entries matching
|
||||
the specified domain.
|
||||
|
||||
* SoObjects/SOGo/SOGoUserManager.m (-sourceIDsInDomain): if the
|
||||
source is not associated to a domain, set it to the requested
|
||||
domain. It will be used by sources with dynamic domain assignation.
|
||||
|
||||
2012-02-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SQLSource.m (_lookupContactEntry:considerEmail:):
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
- (NSArray *) lookupContactsWithFilter: (NSString *) filter
|
||||
onCriteria: (NSString *) criteria
|
||||
sortBy: (NSString *) sortKey
|
||||
ordering: (NSComparisonResult) sortOrdering;
|
||||
ordering: (NSComparisonResult) sortOrdering
|
||||
inDomain: (NSString *) domain;
|
||||
- (NSDictionary *) lookupContactWithName: (NSString *) aName;
|
||||
|
||||
@end
|
||||
|
||||
@@ -285,10 +285,15 @@ static NSArray *folderListingFields = nil;
|
||||
return record;
|
||||
}
|
||||
|
||||
/*
|
||||
* GCS folder are personal folders and are not associated to a domain.
|
||||
* The domain is therefore ignored.
|
||||
*/
|
||||
- (NSArray *) lookupContactsWithFilter: (NSString *) filter
|
||||
onCriteria: (NSString *) criteria
|
||||
sortBy: (NSString *) sortKey
|
||||
ordering: (NSComparisonResult) sortOrdering
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NSArray *dbRecords, *records;
|
||||
EOQualifier *qualifier;
|
||||
|
||||
@@ -314,6 +314,7 @@
|
||||
onCriteria: (NSString *) criteria
|
||||
sortBy: (NSString *) sortKey
|
||||
ordering: (NSComparisonResult) sortOrdering
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NSArray *records, *result;
|
||||
EOSortOrdering *ordering;
|
||||
@@ -323,7 +324,8 @@
|
||||
if (([filter length] > 0 && [criteria isEqualToString: @"name_or_address"])
|
||||
|| ![source listRequiresDot])
|
||||
{
|
||||
records = [source fetchContactsMatching: filter];
|
||||
records = [source fetchContactsMatching: filter
|
||||
inDomain: domain];
|
||||
[childRecords setObjects: records
|
||||
forKeys: [records objectsForKey: @"c_name"
|
||||
notFoundMarker: nil]];
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
@@ -34,6 +35,7 @@
|
||||
#import <SaxObjC/SaxObjC.h>
|
||||
#import <SaxObjC/XMLNamespaces.h>
|
||||
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/WOResponse+SOGo.h>
|
||||
|
||||
#import "SOGoContactFolder.h"
|
||||
@@ -92,9 +94,10 @@
|
||||
unsigned int count, max;
|
||||
NSDictionary *currentFilter, *contact;
|
||||
NSEnumerator *contacts;
|
||||
NSString *baseURL;
|
||||
NSString *baseURL, *domain;
|
||||
|
||||
baseURL = [self baseURLInContext: localContext];
|
||||
domain = [[localContext activeUser] domain];
|
||||
|
||||
max = [filters count];
|
||||
for (count = 0; count < max; count++)
|
||||
@@ -103,7 +106,8 @@
|
||||
contacts = [[(id<SOGoContactFolder>)self lookupContactsWithFilter: [[currentFilter allValues] lastObject]
|
||||
onCriteria: @"name_or_address"
|
||||
sortBy: @"c_givenname"
|
||||
ordering: NSOrderedDescending]
|
||||
ordering: NSOrderedDescending
|
||||
inDomain: domain]
|
||||
objectEnumerator];
|
||||
|
||||
while ((contact = [contacts nextObject]))
|
||||
|
||||
@@ -499,9 +499,6 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||
return ldapConnection;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
- (NSString *) domain
|
||||
{
|
||||
return domain;
|
||||
@@ -1131,6 +1128,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||
}
|
||||
|
||||
- (NSArray *) fetchContactsMatching: (NSString *) match
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NGLdapConnection *ldapConnection;
|
||||
NGLdapEntry *currentEntry;
|
||||
@@ -1217,6 +1215,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||
}
|
||||
|
||||
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) uid
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NGLdapEntry *ldapEntry;
|
||||
EOQualifier *qualifier;
|
||||
|
||||
@@ -57,10 +57,12 @@
|
||||
perr: (SOGoPasswordPolicyError *) perr;
|
||||
|
||||
- (NSDictionary *) lookupContactEntry: (NSString *) theID;
|
||||
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID;
|
||||
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID
|
||||
inDomain: (NSString *) domain;
|
||||
|
||||
- (NSArray *) allEntryIDs;
|
||||
- (NSArray *) fetchContactsMatching: (NSString *) filter;
|
||||
- (NSArray *) fetchContactsMatching: (NSString *) filter
|
||||
inDomain: (NSString *) domain;
|
||||
|
||||
- (void) setSourceID: (NSString *) newSourceID;
|
||||
- (NSString *) sourceID;
|
||||
|
||||
@@ -400,7 +400,7 @@
|
||||
_domainDefaults = [SOGoDomainDefaults defaultsForDomain: domain];
|
||||
if (!_domainDefaults)
|
||||
{
|
||||
[self errorWithFormat: @"domain '%@' does not exist!", domain];
|
||||
//[self errorWithFormat: @"domain '%@' does not exist!", domain];
|
||||
_domainDefaults = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@
|
||||
while ((currentID = [allIDs nextObject]))
|
||||
{
|
||||
sourceDomain = [[_sources objectForKey: currentID] domain];
|
||||
if (![domain length] || [domain isEqualToString: sourceDomain])
|
||||
if (![domain length] || ![sourceDomain length] || [domain isEqualToString: sourceDomain])
|
||||
{
|
||||
metadata = [_sourcesMetadata objectForKey: currentID];
|
||||
if ([[metadata objectForKey: @"canAuthenticate"] boolValue])
|
||||
@@ -609,7 +609,8 @@
|
||||
while (!userEntry && (sourceID = [sogoSources nextObject]))
|
||||
{
|
||||
currentSource = [_sources objectForKey: sourceID];
|
||||
userEntry = [currentSource lookupContactEntryWithUIDorEmail: uid];
|
||||
userEntry = [currentSource lookupContactEntryWithUIDorEmail: uid
|
||||
inDomain: domain];
|
||||
if (userEntry)
|
||||
{
|
||||
[currentUser setObject: sourceID forKey: @"SOGoSource"];
|
||||
@@ -876,6 +877,7 @@
|
||||
|
||||
- (NSArray *) _fetchEntriesInSources: (NSArray *) sourcesList
|
||||
matching: (NSString *) filter
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NSMutableArray *contacts;
|
||||
NSEnumerator *sources;
|
||||
@@ -888,7 +890,8 @@
|
||||
{
|
||||
currentSource = [_sources objectForKey: sourceID];
|
||||
[contacts addObjectsFromArray:
|
||||
[currentSource fetchContactsMatching: filter]];
|
||||
[currentSource fetchContactsMatching: filter
|
||||
inDomain: domain]];
|
||||
}
|
||||
|
||||
return [self _compactAndCompleteContacts: [contacts objectEnumerator]];
|
||||
@@ -899,15 +902,17 @@
|
||||
{
|
||||
return [self
|
||||
_fetchEntriesInSources: [self addressBookSourceIDsInDomain: domain]
|
||||
matching: filter];
|
||||
matching: filter
|
||||
inDomain: domain];
|
||||
}
|
||||
|
||||
- (NSArray *) fetchUsersMatching: (NSString *) filter
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
return [self _fetchEntriesInSources:
|
||||
[self authenticationSourceIDsInDomain: domain]
|
||||
matching: filter];
|
||||
return [self
|
||||
_fetchEntriesInSources: [self authenticationSourceIDsInDomain: domain]
|
||||
matching: filter
|
||||
inDomain: domain];
|
||||
}
|
||||
|
||||
- (NSString *) getLoginForDN: (NSString *) theDN
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
{
|
||||
NSString *_sourceID;
|
||||
NSString *_domain;
|
||||
NSString *_domainField;
|
||||
NSString *_authenticationFilter;
|
||||
NSArray *_loginFields;
|
||||
NSArray *_mailFields;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* SQLSource.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2011 Inverse inc.
|
||||
* Copyright (C) 2009-2012 Inverse inc.
|
||||
*
|
||||
* Authors: Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||
* Francis Lachapelle <flachapelle@inverse.ca>
|
||||
@@ -59,7 +59,7 @@
|
||||
* {
|
||||
* id = zot;
|
||||
* type = sql;
|
||||
* viewURL = "http://sogo:sogo@127.0.0.1:5432/sogo/sogo_view";
|
||||
* viewURL = "mysql://sogo:sogo@127.0.0.1:5432/sogo/sogo_view";
|
||||
* canAuthenticate = YES;
|
||||
* isAddressBook = YES;
|
||||
* userPasswordAlgorithm = md5;
|
||||
@@ -81,6 +81,7 @@
|
||||
if ((self = [super init]))
|
||||
{
|
||||
_sourceID = nil;
|
||||
_domainField = nil;
|
||||
_authenticationFilter = nil;
|
||||
_loginFields = nil;
|
||||
_mailFields = nil;
|
||||
@@ -104,6 +105,7 @@
|
||||
[_viewURL release];
|
||||
[_kindField release];
|
||||
[_multipleBookingsField release];
|
||||
[_domainField release];
|
||||
[_imapHostField release];
|
||||
|
||||
[super dealloc];
|
||||
@@ -123,6 +125,7 @@
|
||||
ASSIGN(_imapHostField, [udSource objectForKey: @"IMAPHostFieldName"]);
|
||||
ASSIGN(_kindField, [udSource objectForKey: @"KindFieldName"]);
|
||||
ASSIGN(_multipleBookingsField, [udSource objectForKey: @"MultipleBookingsFieldName"]);
|
||||
ASSIGN(_domainField, [udSource objectForKey: @"DomainFieldName"]);
|
||||
|
||||
if (!_userPasswordAlgorithm)
|
||||
_userPasswordAlgorithm = @"none";
|
||||
@@ -380,12 +383,13 @@
|
||||
|
||||
- (NSDictionary *) _lookupContactEntry: (NSString *) theID
|
||||
considerEmail: (BOOL) b
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NSMutableDictionary *response;
|
||||
NSMutableArray *qualifiers;
|
||||
NSArray *fieldNames;
|
||||
EOAdaptorChannel *channel;
|
||||
EOQualifier *loginQualifier, *qualifier;
|
||||
EOQualifier *loginQualifier, *domainQualifier, *qualifier;
|
||||
GCSChannelManager *cm;
|
||||
NSMutableString *sql;
|
||||
NSString *value, *field;
|
||||
@@ -424,6 +428,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
domainQualifier = nil;
|
||||
if (_domainField && domain)
|
||||
{
|
||||
domainQualifier = [[EOKeyValueQualifier alloc] initWithKey: _domainField
|
||||
operatorSelector: EOQualifierOperatorEqual
|
||||
value: domain];
|
||||
[domainQualifier autorelease];
|
||||
}
|
||||
|
||||
if (b)
|
||||
{
|
||||
// Always compare againts the mail field
|
||||
@@ -456,6 +469,8 @@
|
||||
@" WHERE ",
|
||||
[_viewURL gcsTableName]];
|
||||
qualifier = [[EOOrQualifier alloc] initWithQualifierArray: qualifiers];
|
||||
if (domainQualifier)
|
||||
qualifier = [[EOAndQualifier alloc] initWithQualifiers: domainQualifier, qualifier, nil];
|
||||
[qualifier _gcsAppendToString: sql];
|
||||
|
||||
ex = [channel evaluateExpressionX: sql];
|
||||
@@ -484,9 +499,12 @@
|
||||
[response setObject: [NSNumber numberWithBool: YES] forKey: @"MailAccess"];
|
||||
|
||||
// We set the domain, if any
|
||||
value = nil;
|
||||
if (_domain)
|
||||
value = _domain;
|
||||
else
|
||||
else if (_domainField)
|
||||
value = [response objectForKey: _domainField];
|
||||
if (![value isNotNull])
|
||||
value = @"";
|
||||
[response setObject: value forKey: @"c_domain"];
|
||||
|
||||
@@ -598,12 +616,13 @@
|
||||
|
||||
- (NSDictionary *) lookupContactEntry: (NSString *) theID
|
||||
{
|
||||
return [self _lookupContactEntry: theID considerEmail: NO];
|
||||
return [self _lookupContactEntry: theID considerEmail: NO inDomain: nil];
|
||||
}
|
||||
|
||||
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
return [self _lookupContactEntry: entryID considerEmail: YES];
|
||||
return [self _lookupContactEntry: entryID considerEmail: YES inDomain: domain];
|
||||
}
|
||||
|
||||
- (NSArray *) allEntryIDs
|
||||
@@ -652,12 +671,14 @@
|
||||
}
|
||||
|
||||
- (NSArray *) fetchContactsMatching: (NSString *) filter
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
EOAdaptorChannel *channel;
|
||||
NSMutableArray *results;
|
||||
GCSChannelManager *cm;
|
||||
NSException *ex;
|
||||
NSString *sql, *lowerFilter;
|
||||
NSMutableString *sql;
|
||||
NSString *lowerFilter;
|
||||
|
||||
results = [NSMutableArray array];
|
||||
|
||||
@@ -668,18 +689,29 @@
|
||||
lowerFilter = [filter lowercaseString];
|
||||
lowerFilter = [lowerFilter stringByReplacingString: @"'" withString: @"''"];
|
||||
|
||||
sql = [NSString stringWithFormat: (@"SELECT *"
|
||||
sql = [NSMutableString stringWithFormat: (@"SELECT *"
|
||||
@" FROM %@"
|
||||
@" WHERE LOWER(c_cn) LIKE '%%%@%%'"
|
||||
@" OR LOWER(mail) LIKE '%%%@%%'"),
|
||||
@" WHERE"
|
||||
@" (LOWER(c_cn) LIKE '%%%@%%'"
|
||||
@" OR LOWER(mail) LIKE '%%%@%%'"),
|
||||
[_viewURL gcsTableName],
|
||||
lowerFilter, lowerFilter];
|
||||
|
||||
|
||||
if (_mailFields && [_mailFields count] > 0)
|
||||
{
|
||||
sql = [sql stringByAppendingString: [self _whereClauseFromArray: _mailFields value: lowerFilter exact: NO]];
|
||||
[sql appendString: [self _whereClauseFromArray: _mailFields value: lowerFilter exact: NO]];
|
||||
}
|
||||
|
||||
[sql appendString: @")"];
|
||||
|
||||
if (_domainField)
|
||||
{
|
||||
if ([domain length])
|
||||
[sql appendFormat: @" AND %@ = '%@'", _domainField, domain];
|
||||
else
|
||||
[sql appendFormat: @" AND %@ IS NULL", _domainField];
|
||||
}
|
||||
|
||||
ex = [channel evaluateExpressionX: sql];
|
||||
if (!ex)
|
||||
{
|
||||
|
||||
@@ -275,7 +275,8 @@ Class SOGoContactSourceFolderKlass = Nil;
|
||||
= [folder lookupContactsWithFilter: filter
|
||||
onCriteria: @"name_or_address"
|
||||
sortBy: @"c_cn"
|
||||
ordering: NSOrderedAscending];
|
||||
ordering: NSOrderedAscending
|
||||
inDomain: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#import <NGObjWeb/SoObject.h>
|
||||
#import <NGObjWeb/SoSecurityManager.h>
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
|
||||
@@ -122,7 +123,8 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||
contactInfos = [folder lookupContactsWithFilter: nil
|
||||
onCriteria: nil
|
||||
sortBy: @"c_cn"
|
||||
ordering: NSOrderedAscending];
|
||||
ordering: NSOrderedAscending
|
||||
inDomain: nil];
|
||||
else
|
||||
contactInfos = nil;
|
||||
|
||||
@@ -159,7 +161,7 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||
{
|
||||
id <WOActionResults> result;
|
||||
SOGoFolder <SOGoContactFolder> *folder;
|
||||
NSString *searchText, *mail;
|
||||
NSString *searchText, *mail, *domain;
|
||||
NSDictionary *data;
|
||||
NSArray *folders, *contacts, *descriptors, *sortedContacts;
|
||||
NSMutableArray *sortedFolders;
|
||||
@@ -174,6 +176,7 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||
// NSLog(@"Search all contacts: %@", searchText);
|
||||
excludeGroups = [[self queryParameterForKey: @"excludeGroups"] boolValue];
|
||||
excludeLists = [[self queryParameterForKey: @"excludeLists"] boolValue];
|
||||
domain = [[context activeUser] domain];
|
||||
folders = nil;
|
||||
NS_DURING
|
||||
folders = [[self clientObject] subFolders];
|
||||
@@ -205,7 +208,8 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||
contacts = [folder lookupContactsWithFilter: searchText
|
||||
onCriteria: @"name_or_address"
|
||||
sortBy: @"c_cn"
|
||||
ordering: NSOrderedAscending];
|
||||
ordering: NSOrderedAscending
|
||||
inDomain: domain];
|
||||
for (j = 0; j < [contacts count]; j++)
|
||||
{
|
||||
contact = [contacts objectAtIndex: j];
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGExtensions/NSString+misc.h>
|
||||
@@ -110,7 +111,8 @@
|
||||
contactInfos = [folder lookupContactsWithFilter: valueText
|
||||
onCriteria: searchText
|
||||
sortBy: [self sortKey]
|
||||
ordering: ordering];
|
||||
ordering: ordering
|
||||
inDomain: [[context activeUser] domain]];
|
||||
[contactInfos retain];
|
||||
}
|
||||
|
||||
@@ -138,7 +140,7 @@
|
||||
{
|
||||
id <WOActionResults> result;
|
||||
id <SOGoContactFolder> folder;
|
||||
NSString *searchText, *mail;
|
||||
NSString *searchText, *mail, *domain;
|
||||
NSDictionary *contact, *data;
|
||||
NSArray *contacts, *descriptors, *sortedContacts;
|
||||
NSMutableDictionary *uniqueContacts;
|
||||
@@ -158,12 +160,14 @@
|
||||
else
|
||||
[localException raise];
|
||||
NS_ENDHANDLER
|
||||
|
||||
|
||||
domain = [[context activeUser] domain];
|
||||
uniqueContacts = [NSMutableDictionary dictionary];
|
||||
contacts = [folder lookupContactsWithFilter: searchText
|
||||
onCriteria: @"name_or_address"
|
||||
sortBy: @"c_cn"
|
||||
ordering: NSOrderedAscending];
|
||||
ordering: NSOrderedAscending
|
||||
inDomain: domain];
|
||||
for (i = 0; i < [contacts count]; i++)
|
||||
{
|
||||
contact = [contacts objectAtIndex: i];
|
||||
|
||||
@@ -417,7 +417,8 @@ static NSArray *infoKeys = nil;
|
||||
contactInfos = [folder lookupContactsWithFilter: nil
|
||||
onCriteria: nil
|
||||
sortBy: @"c_cn"
|
||||
ordering: NSOrderedAscending];
|
||||
ordering: NSOrderedAscending
|
||||
inDomain: nil];
|
||||
|
||||
return contactInfos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user