Monotone-Parent: 763cdd65301c2ece5f7e7a480dc165fb25068f9a

Monotone-Revision: c30c440a14fe8daee4210904dd0d7212fd743325

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-11-24T04:12:16
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2008-11-24 04:12:16 +00:00
parent 27f9ea0dcd
commit c2ace24b44
3 changed files with 83 additions and 47 deletions

View File

@ -1,3 +1,13 @@
2008-11-23 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/MainUI/SOGoUserHomePage.m ([SOGoUserHomePage
-usersSearchAction]): new method, derived from the previous
version of foldersSearchAction, but that only returns username and
contact info about matching users.
([SOGoUserHomePage -foldersSearchAction]): new implementation that
returns the folders available for subscription of the only user
passed as parameter.
2008-11-23 Ludovic Marcotte <lmarcotte@inverse.ca>
* UI/Scheduler/UIxComponentEditor.m - _loadAttendees

View File

@ -36,10 +36,12 @@
#import <NGExtensions/NSObject+Logs.h>
#import <Appointments/SOGoFreeBusyObject.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoWebAuthenticator.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoUserFolder.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
#import <SOGoUI/UIxComponent.h>
#define intervalSeconds 900 /* 15 minutes */
@ -288,35 +290,13 @@ static NSString *LDAPContactInfoAttribute = nil;
return response;
}
- (NSString *) _foldersStringForFolders: (NSEnumerator *) folders
{
NSMutableString *foldersString;
NSDictionary *currentFolder;
foldersString = [NSMutableString new];
[foldersString autorelease];
currentFolder = [folders nextObject];
while (currentFolder)
{
[foldersString appendFormat: @";%@:%@:%@",
[currentFolder objectForKey: @"displayName"],
[currentFolder objectForKey: @"name"],
[currentFolder objectForKey: @"type"]];
currentFolder = [folders nextObject];
}
return foldersString;
}
- (WOResponse *) _foldersResponseForResults: (NSDictionary *) results
- (WOResponse *) _usersResponseForResults: (NSEnumerator *) users
{
WOResponse *response;
NSString *uid, *foldersString;
NSString *uid;
NSMutableString *responseString;
NSDictionary *contact;
NSEnumerator *contacts;
NSArray *folders;
NSString *contactInfo;
response = [context response];
[response setStatus: 200];
@ -324,19 +304,21 @@ static NSString *LDAPContactInfoAttribute = nil;
forKey: @"Content-Type"];
responseString = [NSMutableString new];
contacts = [[results allKeys] objectEnumerator];
while ((contact = [contacts nextObject]))
while ((contact = [users nextObject]))
{
uid = [contact objectForKey: @"c_uid"];
folders = [results objectForKey: contact];
foldersString
= [self _foldersStringForFolders: [folders objectEnumerator]];
[responseString appendFormat: @"%@:%@:%@:%@%@\n", uid,
if ([LDAPContactInfoAttribute length])
{
contactInfo = [contact objectForKey: LDAPContactInfoAttribute];
if (!contactInfo)
contactInfo = @"";
}
else
contactInfo = @"";
[responseString appendFormat: @"%@:%@:%@:%@\n", uid,
[contact objectForKey: @"cn"],
[contact objectForKey: @"c_email"],
([LDAPContactInfoAttribute length] > 0 && [contact objectForKey: LDAPContactInfoAttribute] != nil) ?
[contact objectForKey: LDAPContactInfoAttribute] : @"",
foldersString];
contactInfo];
}
[response appendContentString: responseString];
[responseString release];
@ -344,25 +326,19 @@ static NSString *LDAPContactInfoAttribute = nil;
return response;
}
- (id <WOActionResults>) foldersSearchAction
- (id <WOActionResults>) usersSearchAction
{
NSString *contact, *folderType;
NSDictionary *folders;
NSString *contact;
id <WOActionResults> result;
LDAPUserManager *um;
NSEnumerator *users;
um = [LDAPUserManager sharedUserManager];
contact = [self queryParameterForKey: @"search"];
if ([contact length])
{
folderType = [self queryParameterForKey: @"type"];
if ([folderType length])
{
folders = [[self clientObject] foldersOfType: folderType
matchingUID: contact];
result = [self _foldersResponseForResults: folders];
}
else
result = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'type' parameter"];
users = [[um fetchUsersMatching: contact] objectEnumerator];
result = [self _usersResponseForResults: users];
}
else
result = [NSException exceptionWithHTTPStatus: 400
@ -371,4 +347,49 @@ static NSString *LDAPContactInfoAttribute = nil;
return result;
}
- (WOResponse *) _foldersResponseForResults: (NSArray *) folders
{
WOResponse *response;
NSEnumerator *foldersEnum;
NSDictionary *currentFolder;
response = [context response];
[response setStatus: 200];
[response setHeader: @"text/plain; charset=utf-8"
forKey: @"Content-Type"];
foldersEnum = [folders objectEnumerator];
while ((currentFolder = [foldersEnum nextObject]))
[response appendContentString:
[currentFolder keysWithFormat: @";%{displayName}:%{name}:%{type}"]];
return response;
}
- (id <WOActionResults>) foldersSearchAction
{
NSString *contact, *folderType;
NSArray *folders;
id <WOActionResults> result;
contact = [self queryParameterForKey: @"user"];
if ([contact length])
{
folderType = [self queryParameterForKey: @"type"];
if ([folderType length])
{
folders = [[self clientObject] foldersOfType: folderType
forUID: contact];
result = [self _foldersResponseForResults: folders];
}
else
result = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'type' parameter"];
}
else
result = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'user' parameter"];
return result;
}
@end

View File

@ -136,6 +136,11 @@
pageName = "SOGoUserHomePage";
actionName = "logoff";
};
usersSearch = {
protectedBy = "View";
pageName = "SOGoUserHomePage";
actionName = "usersSearch";
};
foldersSearch = {
protectedBy = "View";
pageName = "SOGoUserHomePage";