Monotone-Parent: ce3c09cbf962262c8c3d04cf4422dbd4ded3a5c9
Monotone-Revision: 76a1bb772c883ebc00f5cdb177c280f729babb70 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-03-29T17:12:44 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
780d474031
commit
c0369494d1
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2007-03-29 Wolfgang Sourdeau <Wolfgang@Contre.COM>
|
||||||
|
|
||||||
|
* UI/Contacts/UIxContactFoldersView.m ([UIxContactFoldersView
|
||||||
|
-checkRightsAction]): removed method.
|
||||||
|
|
||||||
|
* UI/Contacts/UIxContactFoldersView.m ([UIxContactFoldersView
|
||||||
|
-updateAdditionalAddressBooksAction]): removed method.
|
||||||
|
|
||||||
|
* UI/Scheduler/UIxCalMainView.m ([UIxCalMainView
|
||||||
|
-updateCalendarsAction]): removed method.
|
||||||
|
|
||||||
2007-03-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2007-03-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
* UI/Scheduler/UIxCalMainView.m ([UIxCalMainView
|
* UI/Scheduler/UIxCalMainView.m ([UIxCalMainView
|
||||||
|
|
|
@ -27,11 +27,15 @@
|
||||||
#import <NGObjWeb/WOResponse.h>
|
#import <NGObjWeb/WOResponse.h>
|
||||||
#import <NGObjWeb/WOContext.h>
|
#import <NGObjWeb/WOContext.h>
|
||||||
|
|
||||||
|
#import <GDLContentStore/GCSFolder.h>
|
||||||
|
#import <GDLContentStore/GCSFolderManager.h>
|
||||||
|
|
||||||
#import <SoObjects/SOGo/SOGoUser.h>
|
#import <SoObjects/SOGo/SOGoUser.h>
|
||||||
#import <SoObjects/SOGo/NSString+Utilities.h>
|
#import <SoObjects/SOGo/NSString+Utilities.h>
|
||||||
#import <SoObjects/Contacts/SOGoContactFolders.h>
|
#import <SoObjects/Contacts/SOGoContactFolders.h>
|
||||||
#import <SoObjects/Contacts/SOGoContactFolder.h>
|
#import <SoObjects/Contacts/SOGoContactFolder.h>
|
||||||
#import <SoObjects/Contacts/SOGoContactGCSFolder.h>
|
#import <SoObjects/Contacts/SOGoContactGCSFolder.h>
|
||||||
|
#import <SoObjects/Contacts/SOGoContactLDAPFolder.h>
|
||||||
|
|
||||||
#import "common.h"
|
#import "common.h"
|
||||||
|
|
||||||
|
@ -84,32 +88,13 @@
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) selectForSchedulerAction
|
|
||||||
{
|
|
||||||
return [self _selectActionForApplication: @"scheduler-contacts"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) selectForMailerAction
|
|
||||||
{
|
|
||||||
return [self _selectActionForApplication: @"mailer-contacts"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) selectForCalendarsAction
|
|
||||||
{
|
|
||||||
return [self _selectActionForApplication: @"calendars-contacts"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) selectForAddressBooksAction
|
|
||||||
{
|
|
||||||
return [self _selectActionForApplication: @"addressbooks-contacts"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) selectForAclsAction
|
- (id) selectForAclsAction
|
||||||
{
|
{
|
||||||
return [self _selectActionForApplication: @"acls-contacts"];
|
return [self _selectActionForApplication: @"acls-contacts"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) _searchResults: (NSString *) contact
|
- (NSArray *) _searchResults: (NSString *) contact
|
||||||
|
ldapFoldersOnly: (BOOL) ldapFoldersOnly
|
||||||
{
|
{
|
||||||
NSMutableArray *results;
|
NSMutableArray *results;
|
||||||
SOGoContactFolders *topFolder;
|
SOGoContactFolders *topFolder;
|
||||||
|
@ -124,10 +109,12 @@
|
||||||
currentFolder = [sogoContactFolders nextObject];
|
currentFolder = [sogoContactFolders nextObject];
|
||||||
while (currentFolder)
|
while (currentFolder)
|
||||||
{
|
{
|
||||||
[results addObjectsFromArray: [currentFolder
|
if (!ldapFoldersOnly
|
||||||
lookupContactsWithFilter: contact
|
|| [currentFolder isKindOfClass: [SOGoContactLDAPFolder class]])
|
||||||
sortBy: @"cn"
|
[results addObjectsFromArray: [currentFolder
|
||||||
ordering: NSOrderedAscending]];
|
lookupContactsWithFilter: contact
|
||||||
|
sortBy: @"cn"
|
||||||
|
ordering: NSOrderedAscending]];
|
||||||
currentFolder = [sogoContactFolders nextObject];
|
currentFolder = [sogoContactFolders nextObject];
|
||||||
}
|
}
|
||||||
[topFolder release];
|
[topFolder release];
|
||||||
|
@ -202,10 +189,169 @@
|
||||||
{
|
{
|
||||||
NSString *contact;
|
NSString *contact;
|
||||||
id <WOActionResults> result;
|
id <WOActionResults> result;
|
||||||
|
BOOL ldapFoldersOnly;
|
||||||
|
|
||||||
contact = [self queryParameterForKey: @"search"];
|
contact = [self queryParameterForKey: @"search"];
|
||||||
if ([contact length])
|
ldapFoldersOnly = [[self queryParameterForKey: @"ldap-only"] boolValue];
|
||||||
result = [self _responseForResults: [self _searchResults: contact]];
|
if ([contact length] > 0)
|
||||||
|
result
|
||||||
|
= [self _responseForResults: [self _searchResults: contact
|
||||||
|
ldapFoldersOnly: ldapFoldersOnly]];
|
||||||
|
else
|
||||||
|
result = [NSException exceptionWithHTTPStatus: 400
|
||||||
|
reason: @"missing 'search' parameter"];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) _gcsFoldersFromFolder: (SOGoContactFolders *) contactFolders
|
||||||
|
{
|
||||||
|
NSMutableArray *gcsFolders;
|
||||||
|
NSEnumerator *contactSubfolders;
|
||||||
|
SOGoContactGCSFolder *currentContactFolder;
|
||||||
|
NSString *folderName, *displayName;
|
||||||
|
NSMutableDictionary *currentDictionary;
|
||||||
|
|
||||||
|
gcsFolders = [NSMutableArray new];
|
||||||
|
[gcsFolders autorelease];
|
||||||
|
|
||||||
|
contactSubfolders = [[contactFolders contactFolders] objectEnumerator];
|
||||||
|
currentContactFolder = [contactSubfolders nextObject];
|
||||||
|
while (currentContactFolder)
|
||||||
|
{
|
||||||
|
if ([currentContactFolder
|
||||||
|
isKindOfClass: [SOGoContactGCSFolder class]])
|
||||||
|
{
|
||||||
|
folderName = [NSString stringWithFormat: @"/Contacts/%@",
|
||||||
|
[currentContactFolder nameInContainer]];
|
||||||
|
currentDictionary = [NSMutableDictionary new];
|
||||||
|
[currentDictionary autorelease];
|
||||||
|
displayName = [[currentContactFolder ocsFolder] folderName];
|
||||||
|
[currentDictionary setObject: displayName forKey: @"displayName"];
|
||||||
|
[currentDictionary setObject: folderName forKey: @"name"];
|
||||||
|
[currentDictionary setObject: @"contact" forKey: @"type"];
|
||||||
|
[gcsFolders addObject: currentDictionary];
|
||||||
|
}
|
||||||
|
currentContactFolder = [contactSubfolders nextObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
return gcsFolders;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) _foldersForUID: (NSString *) uid
|
||||||
|
ofType: (NSString *) folderType
|
||||||
|
{
|
||||||
|
NSObject *topFolder, *userFolder;
|
||||||
|
SOGoContactFolders *contactFolders;
|
||||||
|
NSMutableArray *folders;
|
||||||
|
NSMutableDictionary *currentDictionary;
|
||||||
|
|
||||||
|
folders = [NSMutableArray new];
|
||||||
|
[folders autorelease];
|
||||||
|
|
||||||
|
topFolder = [[[self clientObject] container] container];
|
||||||
|
userFolder = [topFolder lookupName: uid inContext: context acquire: NO];
|
||||||
|
|
||||||
|
/* FIXME: should be moved in the SOGo* classes. Maybe by having a SOGoFolderManager. */
|
||||||
|
#warning this might need adjustments whenever we permit multiple calendar folders per-user
|
||||||
|
if ([folderType length] == 0 || [folderType isEqualToString: @"calendar"])
|
||||||
|
{
|
||||||
|
currentDictionary = [NSMutableDictionary new];
|
||||||
|
[currentDictionary autorelease];
|
||||||
|
[currentDictionary setObject: [self labelForKey: @"Calendar"]
|
||||||
|
forKey: @"displayName"];
|
||||||
|
[currentDictionary setObject: @"/Calendar" forKey: @"name"];
|
||||||
|
[currentDictionary setObject: @"calendar" forKey: @"type"];
|
||||||
|
[folders addObject: currentDictionary];
|
||||||
|
}
|
||||||
|
if ([folderType length] == 0 || [folderType isEqualToString: @"contact"])
|
||||||
|
{
|
||||||
|
contactFolders = [userFolder lookupName: @"Contacts"
|
||||||
|
inContext: context acquire: NO];
|
||||||
|
[folders
|
||||||
|
addObjectsFromArray: [self _gcsFoldersFromFolder: contactFolders]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return folders;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (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: (NSArray *) results
|
||||||
|
withType: (NSString *) folderType
|
||||||
|
{
|
||||||
|
WOResponse *response;
|
||||||
|
NSString *uid, *foldersString;
|
||||||
|
NSMutableString *responseString;
|
||||||
|
NSDictionary *result;
|
||||||
|
NSEnumerator *resultsEnum;
|
||||||
|
NSArray *folders;
|
||||||
|
|
||||||
|
response = [context response];
|
||||||
|
|
||||||
|
if ([results count])
|
||||||
|
{
|
||||||
|
[response setStatus: 200];
|
||||||
|
[response setHeader: @"text/plain; charset=iso-8859-1"
|
||||||
|
forKey: @"Content-Type"];
|
||||||
|
|
||||||
|
responseString = [NSMutableString new];
|
||||||
|
resultsEnum = [results objectEnumerator];
|
||||||
|
result = [resultsEnum nextObject];
|
||||||
|
while (result)
|
||||||
|
{
|
||||||
|
uid = [result objectForKey: @"c_uid"];
|
||||||
|
folders = [self _foldersForUID: uid ofType: folderType];
|
||||||
|
foldersString
|
||||||
|
= [self _foldersStringForFolders: [folders objectEnumerator]];
|
||||||
|
[responseString appendFormat: @"%@:%@%@\n",
|
||||||
|
uid, [self _emailForResult: result], foldersString];
|
||||||
|
result = [resultsEnum nextObject];
|
||||||
|
}
|
||||||
|
[response appendContentString: responseString];
|
||||||
|
[responseString release];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[response setStatus: 404];
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id <WOActionResults>) foldersSearchAction
|
||||||
|
{
|
||||||
|
NSString *contact, *folderType;
|
||||||
|
id <WOActionResults> result;
|
||||||
|
BOOL ldapOnly;
|
||||||
|
|
||||||
|
contact = [self queryParameterForKey: @"search"];
|
||||||
|
if ([contact length] > 0)
|
||||||
|
{
|
||||||
|
ldapOnly = [[self queryParameterForKey: @"ldap-only"] boolValue];
|
||||||
|
folderType = [self queryParameterForKey: @"type"];
|
||||||
|
result = [self _foldersResponseForResults:
|
||||||
|
[self _searchResults: contact
|
||||||
|
ldapFoldersOnly: ldapOnly]
|
||||||
|
withType: folderType];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
result = [NSException exceptionWithHTTPStatus: 400
|
result = [NSException exceptionWithHTTPStatus: 400
|
||||||
reason: @"missing 'search' parameter"];
|
reason: @"missing 'search' parameter"];
|
||||||
|
@ -213,22 +359,6 @@
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <WOActionResults>) updateAdditionalAddressBooksAction
|
|
||||||
{
|
|
||||||
WOResponse *response;
|
|
||||||
NSUserDefaults *ud;
|
|
||||||
|
|
||||||
ud = [[context activeUser] userDefaults];
|
|
||||||
[ud setObject: [self queryParameterForKey: @"ids"]
|
|
||||||
forKey: @"additionaladdressbooks"];
|
|
||||||
[ud synchronize];
|
|
||||||
response = [context response];
|
|
||||||
[response setStatus: 200];
|
|
||||||
[response setHeader: @"text/html; charset=\"utf-8\"" forKey: @"content-type"];
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (SOGoContactGCSFolder *) contactFolderForUID: (NSString *) uid
|
- (SOGoContactGCSFolder *) contactFolderForUID: (NSString *) uid
|
||||||
{
|
{
|
||||||
SOGoFolder *upperContainer;
|
SOGoFolder *upperContainer;
|
||||||
|
@ -256,40 +386,4 @@
|
||||||
? contactFolder : nil);
|
? contactFolder : nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <WOActionResults>) checkRightsAction
|
|
||||||
{
|
|
||||||
WOResponse *response;
|
|
||||||
NSUserDefaults *ud;
|
|
||||||
NSString *uids;
|
|
||||||
NSMutableString *rights;
|
|
||||||
NSArray *ids;
|
|
||||||
unsigned int count, max;
|
|
||||||
BOOL result;
|
|
||||||
|
|
||||||
ud = [[context activeUser] userDefaults];
|
|
||||||
uids = [ud objectForKey: @"additionaladdressbooks"];
|
|
||||||
|
|
||||||
response = [context response];
|
|
||||||
[response setStatus: 200];
|
|
||||||
[response setHeader: @"text/plain; charset=\"utf-8\""
|
|
||||||
forKey: @"content-type"];
|
|
||||||
rights = [NSMutableString string];
|
|
||||||
if ([uids length] > 0)
|
|
||||||
{
|
|
||||||
ids = [uids componentsSeparatedByString: @","];
|
|
||||||
max = [ids count];
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
{
|
|
||||||
result = ([self contactFolderForUID: [ids objectAtIndex: count]] != nil);
|
|
||||||
if (count == 0)
|
|
||||||
[rights appendFormat: @"%d", result];
|
|
||||||
else
|
|
||||||
[rights appendFormat: @",%d", result];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[response appendContentString: rights];
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -114,20 +114,4 @@ static NSMutableArray *yearMenuItems = nil;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <WOActionResults>) updateCalendarsAction
|
|
||||||
{
|
|
||||||
WOResponse *response;
|
|
||||||
NSUserDefaults *ud;
|
|
||||||
|
|
||||||
ud = [[context activeUser] userDefaults];
|
|
||||||
[ud setObject: [self queryParameterForKey: @"ids"]
|
|
||||||
forKey: @"calendaruids"];
|
|
||||||
[ud synchronize];
|
|
||||||
response = [context response];
|
|
||||||
[response setStatus: 200];
|
|
||||||
[response setHeader: @"text/html; charset=\"utf-8\"" forKey: @"content-type"];
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue