mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-16 18:58:50 +00:00
Improve sort validation in Contacts module
This commit is contained in:
@@ -76,15 +76,49 @@
|
||||
{
|
||||
NSString *s;
|
||||
WORequest *rq;
|
||||
|
||||
static NSArray *sortKeys = nil;
|
||||
|
||||
if (!sortKeys)
|
||||
{
|
||||
sortKeys = [NSArray arrayWithObjects: @"c_cn", @"c_sn", @"c_givenname", @"c_mail",
|
||||
@"c_screenname", @"c_o", @"c_telephonenumber", nil];
|
||||
[sortKeys retain];
|
||||
}
|
||||
|
||||
rq = [context request];
|
||||
s = [rq formValueForKey: @"sort"];
|
||||
if (![s length])
|
||||
if (![s length] || ![sortKeys containsObject: s])
|
||||
s = [self defaultSortKey];
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
- (void) saveSortValue
|
||||
{
|
||||
NSMutableDictionary *contactSettings;
|
||||
NSString *ascending, *sort;
|
||||
SOGoUserSettings *us;
|
||||
|
||||
sort = [[context request] formValueForKey: @"sort"];
|
||||
ascending = [[context request] formValueForKey: @"asc"];
|
||||
|
||||
if ([sort length])
|
||||
{
|
||||
sort = [self sortKey];
|
||||
us = [[context activeUser] userSettings];
|
||||
contactSettings = [us objectForKey: @"Contact"];
|
||||
// Must create if it doesn't exist
|
||||
if (!contactSettings)
|
||||
{
|
||||
contactSettings = [NSMutableDictionary dictionary];
|
||||
[us setObject: contactSettings forKey: @"Contact"];
|
||||
}
|
||||
[contactSettings setObject: [NSArray arrayWithObjects: [sort lowercaseString], [NSString stringWithFormat: @"%d", [ascending intValue]], nil]
|
||||
forKey: @"SortingState"];
|
||||
[us synchronize];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *) contactInfos
|
||||
{
|
||||
id <SOGoContactFolder> folder;
|
||||
|
||||
Reference in New Issue
Block a user