diff --git a/ChangeLog b/ChangeLog index 79deaa84c..d8ebdc223 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-07 Francis Lachapelle + + * UI/Contacts/UIxContactFoldersView.m ([WOActionResults + allContactSearchAction]): new method to search contacts among + all address books. + 2008-07-04 Wolfgang Sourdeau * SoObjects/SOGo/SOGoObject.m ([SOGoObject diff --git a/UI/Contacts/UIxContactFoldersView.h b/UI/Contacts/UIxContactFoldersView.h index 507b522d9..76f92740a 100644 --- a/UI/Contacts/UIxContactFoldersView.h +++ b/UI/Contacts/UIxContactFoldersView.h @@ -24,6 +24,7 @@ #define UIXCONTACTFOLDERSVIEW_H #import +#import @interface UIxContactFoldersView : UIxComponent { diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index f6a2d1393..0b7c42e99 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -179,6 +179,52 @@ return response; } +- (id ) allContactSearchAction +{ + id result; + id folder; + NSString *searchText; + NSArray *folders, *contacts, *descriptors, *sortedContacts; + NSMutableArray *allContacts; + unsigned int i; + NSSortDescriptor *displayNameDescriptor; + + searchText = [self queryParameterForKey: @"search"]; + if ([searchText length] > 0) + { + folders = [[self clientObject] subFolders]; + allContacts = [NSMutableArray new]; + for (i = 0; i < [folders count]; i++) { + folder = [folders objectAtIndex: i]; + //NSLog(@"Address book: %@ (%@)", [folder displayName], [folder class]); + contacts = [folder lookupContactsWithFilter: searchText + sortBy: @"displayName" + ordering: NSOrderedAscending]; + if ([contacts count] > 0) { + [allContacts addObjectsFromArray: contacts]; + } + } + + result = [context response]; + if ([allContacts count] > 0) { + // Sort the contacts by display name + displayNameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"displayName" + ascending:YES] autorelease]; + descriptors = [NSArray arrayWithObjects: displayNameDescriptor, nil]; + sortedContacts = [allContacts sortedArrayUsingDescriptors:descriptors]; + + [(WOResponse*)result appendContentString: [sortedContacts jsonRepresentation]]; + } + else + [(WOResponse*)result setStatus: 404]; + } + else + result = [NSException exceptionWithHTTPStatus: 400 + reason: @"missing 'search' parameter"]; + + return result; +} + - (id ) contactSearchAction { NSString *contact; diff --git a/UI/Contacts/product.plist b/UI/Contacts/product.plist index 2d50fd20b..c47f89180 100644 --- a/UI/Contacts/product.plist +++ b/UI/Contacts/product.plist @@ -22,6 +22,11 @@ pageName = "UIxContactFoldersView"; actionName = "contactSearch"; }; + allContactSearch = { + protectedBy = ""; + pageName = "UIxContactFoldersView"; + actionName = "allContactSearch"; + }; updateAdditionalAddressBooks = { protectedBy = "View"; pageName = "UIxContactFoldersView"; diff --git a/UI/Templates/MailerUI/UIxMailEditor.wox b/UI/Templates/MailerUI/UIxMailEditor.wox index bba37d7fa..61caaedff 100644 --- a/UI/Templates/MailerUI/UIxMailEditor.wox +++ b/UI/Templates/MailerUI/UIxMailEditor.wox @@ -14,7 +14,7 @@ -