diff --git a/ChangeLog b/ChangeLog index b5d16ea76..ea9e8b302 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-11-24 Ludovic Marcotte + + * We now sort the results in the subsription window + 2008-11-24 Wolfgang Sourdeau * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder diff --git a/SoObjects/SOGo/NSDictionary+Utilities.m b/SoObjects/SOGo/NSDictionary+Utilities.m index 8b8b35cf3..c4228826e 100644 --- a/SoObjects/SOGo/NSDictionary+Utilities.m +++ b/SoObjects/SOGo/NSDictionary+Utilities.m @@ -103,6 +103,11 @@ return keysWithFormat; } +- (NSComparisonResult) caseInsensitiveDisplayNameCompare: (NSDictionary *) theDictionary +{ + return [[self objectForKey: @"cn"] caseInsensitiveCompare: [theDictionary objectForKey: @"cn"]]; +} + @end @implementation NSMutableDictionary (SOGoDictionaryUtilities) diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index deee89879..971dde279 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -293,18 +293,26 @@ static NSString *LDAPContactInfoAttribute = nil; - (NSString *) _davFetchUsersMatching: (NSString *) user { LDAPUserManager *um; - NSEnumerator *users; NSMutableString *fetch; NSDictionary *currentUser; NSString *field; + NSArray *users; + int i; #warning the attributes returned here should match the one requested in the query fetch = [NSMutableString string]; um = [LDAPUserManager sharedUserManager]; - users = [[um fetchUsersMatching: user] objectEnumerator]; - while ((currentUser = [users nextObject])) + + // We sort our array - this is pretty useful for the + // SOGo Integrator extension, among other things. + users = [[[[um fetchUsersMatching: user] objectEnumerator] allObjects] + sortedArrayUsingSelector: @selector(caseInsensitiveDisplayNameCompare:)]; + + for (i = 0; i < [users count]; i++) { + currentUser = [users objectAtIndex: i]; + [fetch appendString: @""]; field = [currentUser objectForKey: @"c_uid"]; [fetch appendFormat: @"%@", diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index c646a5cc5..ea6e8e0be 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -297,6 +297,8 @@ static NSString *LDAPContactInfoAttribute = nil; NSMutableString *responseString; NSDictionary *contact; NSString *contactInfo; + NSArray *allUsers; + int i; response = [context response]; [response setStatus: 200]; @@ -304,8 +306,15 @@ static NSString *LDAPContactInfoAttribute = nil; forKey: @"Content-Type"]; responseString = [NSMutableString new]; - while ((contact = [users nextObject])) + + // We sort our array - this is pretty useful for the Web + // interface of SOGo. + allUsers = [[users allObjects] + sortedArrayUsingSelector: @selector(caseInsensitiveDisplayNameCompare:)]; + + for (i = 0; i < [allUsers count]; i++) { + contact = [allUsers objectAtIndex: i]; uid = [contact objectForKey: @"c_uid"]; if ([LDAPContactInfoAttribute length]) {