merge of 'a3ff389774d4c793b5970d4691cb8738d9f83e70'
and 'f661875c0ea83ef886f78e3b498bc05b1d105e9a' Monotone-Parent: a3ff389774d4c793b5970d4691cb8738d9f83e70 Monotone-Parent: f661875c0ea83ef886f78e3b498bc05b1d105e9a Monotone-Revision: 6bf607a80d572f2c918d9796375bba09943229cc Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-01-05T22:51:57 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
commit
f46466164c
|
@ -1,3 +1,11 @@
|
|||
2011-01-05 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SQLSource.m - we now honor the "mail" column
|
||||
and we also support "MailFieldNames" in the SQL source - which
|
||||
is essentially and array of column names holding additonnal email
|
||||
addresses of users (beside the "mail" column). Also updated
|
||||
the documentation to reflect this change.
|
||||
|
||||
2011-01-05 Francis Lachapelle <flachapelle@inverse.ca>
|
||||
|
||||
* UI/WebServerResources/SOGoAutoCompletion.js (onKeydown): added
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
/* SQLSource.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2010 Inverse inc.
|
||||
* Copyright (C) 2009-2011 Inverse inc.
|
||||
*
|
||||
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* SQLSource.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2010 Inverse inc.
|
||||
* Copyright (C) 2009-2011 Inverse inc.
|
||||
*
|
||||
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||
*
|
||||
|
@ -220,6 +220,26 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *) _whereClauseFromArray: (NSArray *) theArray
|
||||
value: (NSString *) theValue
|
||||
exact: (BOOL) theBOOL
|
||||
{
|
||||
NSMutableString *s;
|
||||
int i;
|
||||
|
||||
s = [NSMutableString string];
|
||||
|
||||
for (i = 0; i < [theArray count]; i++)
|
||||
{
|
||||
if (theBOOL)
|
||||
[s appendFormat: @" OR LOWER(%@) = '%@'", [theArray objectAtIndex: i], theValue];
|
||||
else
|
||||
[s appendFormat: @" OR LOWER(%@) LIKE '%%%@%%'", [theArray objectAtIndex: i], theValue];
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
- (NSDictionary *) _lookupContactEntry: (NSString *) theID
|
||||
considerEmail: (BOOL) b
|
||||
{
|
||||
|
@ -242,15 +262,24 @@
|
|||
@" WHERE c_uid = '%@'"),
|
||||
[_viewURL gcsTableName], theID];
|
||||
else
|
||||
sql = [NSString stringWithFormat: (@"SELECT *"
|
||||
@" FROM %@"
|
||||
@" WHERE c_uid = '%@' OR"
|
||||
@" LOWER(mail) = '%@'"),
|
||||
[_viewURL gcsTableName], theID, [theID lowercaseString]];
|
||||
|
||||
{
|
||||
sql = [NSString stringWithFormat: (@"SELECT *"
|
||||
@" FROM %@"
|
||||
@" WHERE c_uid = '%@' OR"
|
||||
@" LOWER(mail) = '%@'"),
|
||||
[_viewURL gcsTableName], theID, [theID lowercaseString]];
|
||||
|
||||
if (_mailFields && [_mailFields count] > 0)
|
||||
{
|
||||
sql = [sql stringByAppendingString: [self _whereClauseFromArray: _mailFields value: [theID lowercaseString] exact: YES]];
|
||||
}
|
||||
}
|
||||
|
||||
ex = [channel evaluateExpressionX: sql];
|
||||
if (!ex)
|
||||
{
|
||||
NSMutableArray *emails;
|
||||
|
||||
response = [[channel fetchAttributes: [channel describeResults: NO]
|
||||
withZone: NULL] mutableCopy];
|
||||
[response autorelease];
|
||||
|
@ -260,6 +289,24 @@
|
|||
// constraints right now over a SQL backend.
|
||||
[response setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"];
|
||||
[response setObject: [NSNumber numberWithBool: YES] forKey: @"MailAccess"];
|
||||
|
||||
// We populate all mail fields
|
||||
emails = [NSMutableArray array];
|
||||
|
||||
if ([response objectForKey: @"mail"])
|
||||
[emails addObject: [response objectForKey: @"mail"]];
|
||||
|
||||
if (_mailFields && [_mailFields count] > 0)
|
||||
{
|
||||
NSString *s;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < [_mailFields count]; i++)
|
||||
if ((s = [response objectForKey: [_mailFields objectAtIndex: i]]))
|
||||
[emails addObject: s];
|
||||
}
|
||||
|
||||
[response setObject: emails forKey: @"c_emails"];
|
||||
}
|
||||
else
|
||||
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
|
||||
|
@ -352,6 +399,11 @@
|
|||
[_viewURL gcsTableName],
|
||||
lowerFilter, lowerFilter];
|
||||
|
||||
if (_mailFields && [_mailFields count] > 0)
|
||||
{
|
||||
sql = [sql stringByAppendingString: [self _whereClauseFromArray: _mailFields value: lowerFilter exact: NO]];
|
||||
}
|
||||
|
||||
ex = [channel evaluateExpressionX: sql];
|
||||
if (!ex)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue