2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-06-18 17:39:59 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
2008-07-04 18:06:09 +02:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
2007-06-18 17:39:59 +02:00
|
|
|
#import <Foundation/NSString.h>
|
2007-12-05 00:28:52 +01:00
|
|
|
#import <Foundation/NSURL.h>
|
2007-06-14 23:23:14 +02:00
|
|
|
|
2007-06-18 17:39:59 +02:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2007-09-07 00:12:42 +02:00
|
|
|
#import <NGObjWeb/SoClassSecurityInfo.h>
|
2007-12-05 00:28:52 +01:00
|
|
|
#import <NGObjWeb/SoSecurityManager.h>
|
2008-08-26 19:40:02 +02:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
2007-11-26 21:41:59 +01:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2008-07-29 18:34:10 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
2007-12-05 00:28:52 +01:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2007-11-26 21:41:59 +01:00
|
|
|
|
2007-06-18 17:39:59 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2007-12-05 00:28:52 +01:00
|
|
|
#import <NGExtensions/NSString+misc.h>
|
|
|
|
#import <DOM/DOMDocument.h>
|
|
|
|
#import <DOM/DOMNode.h>
|
|
|
|
#import <DOM/DOMProtocols.h>
|
|
|
|
#import <SaxObjC/SaxObjC.h>
|
|
|
|
#import <SaxObjC/XMLNamespaces.h>
|
2007-06-18 17:39:59 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
#import <Appointments/SOGoAppointmentFolders.h>
|
2007-06-18 17:39:59 +02:00
|
|
|
#import <Appointments/SOGoFreeBusyObject.h>
|
|
|
|
#import <Contacts/SOGoContactFolders.h>
|
|
|
|
#import <Mailer/SOGoMailAccounts.h>
|
2006-08-05 01:02:13 +02:00
|
|
|
|
2008-08-26 23:01:41 +02:00
|
|
|
#import <UI/SOGoUI/UIxComponent.h>
|
2008-08-26 19:40:02 +02:00
|
|
|
|
2008-02-22 22:25:24 +01:00
|
|
|
#import "NSArray+Utilities.h"
|
2007-12-05 00:28:52 +01:00
|
|
|
#import "NSDictionary+Utilities.h"
|
|
|
|
#import "LDAPUserManager.h"
|
2006-12-15 23:22:32 +01:00
|
|
|
#import "SOGoPermissions.h"
|
2007-06-18 17:39:59 +02:00
|
|
|
#import "SOGoUser.h"
|
2006-12-14 22:20:13 +01:00
|
|
|
|
|
|
|
#import "SOGoUserFolder.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
@implementation SOGoUserFolder
|
|
|
|
|
|
|
|
/* hierarchy */
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (NSArray *) toManyRelationshipKeys
|
|
|
|
{
|
2007-11-26 21:41:59 +01:00
|
|
|
NSMutableArray *children;
|
|
|
|
SOGoUser *currentUser;
|
|
|
|
|
|
|
|
children = [NSMutableArray arrayWithCapacity: 4];
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-11-26 21:41:59 +01:00
|
|
|
currentUser = [context activeUser];
|
|
|
|
if ([currentUser canAccessModule: @"Calendar"])
|
|
|
|
[children addObject: @"Calendar"];
|
|
|
|
[children addObject: @"Contacts"];
|
|
|
|
if ([currentUser canAccessModule: @"Mail"])
|
|
|
|
[children addObject: @"Mail"];
|
|
|
|
[children addObject: @"Preferences"];
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return children;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ownership */
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (NSString *) ownerInContext: (WOContext *) _ctx
|
|
|
|
{
|
2008-02-07 21:24:22 +01:00
|
|
|
SOGoUser *ownerUser;
|
|
|
|
|
|
|
|
if (!owner)
|
|
|
|
{
|
|
|
|
ownerUser = [SOGoUser userWithLogin: nameInContainer roles: nil];
|
|
|
|
owner = [ownerUser login];
|
|
|
|
}
|
|
|
|
|
|
|
|
return owner;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* looking up shared objects */
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (SOGoUserFolder *) lookupUserFolder
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
2007-12-05 00:28:52 +01:00
|
|
|
|
|
|
|
- (NSDictionary *) _parseCollectionFilters: (id <DOMDocument>) parentNode
|
|
|
|
{
|
|
|
|
NSEnumerator *children;
|
|
|
|
NGDOMNode *node;
|
|
|
|
NSMutableDictionary *filter;
|
|
|
|
NSString *componentName;
|
2008-02-22 22:25:24 +01:00
|
|
|
|
2007-12-05 00:28:52 +01:00
|
|
|
filter = [NSMutableDictionary dictionaryWithCapacity: 2];
|
|
|
|
children = [[parentNode getElementsByTagName: @"prop-match"]
|
|
|
|
objectEnumerator];
|
|
|
|
while ((node = [children nextObject]))
|
|
|
|
{
|
|
|
|
componentName = [[node attribute: @"name"] lowercaseString];
|
|
|
|
[filter setObject: [node textValue] forKey: componentName];
|
|
|
|
}
|
|
|
|
|
|
|
|
return filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _subFoldersFromFolder: (SOGoParentFolder *) parentFolder
|
|
|
|
{
|
|
|
|
NSMutableArray *folders;
|
|
|
|
NSEnumerator *subfolders;
|
|
|
|
SOGoFolder *currentFolder;
|
2007-12-05 22:05:04 +01:00
|
|
|
NSString *folderName, *folderOwner;
|
2007-12-05 00:28:52 +01:00
|
|
|
NSMutableDictionary *currentDictionary;
|
|
|
|
SoSecurityManager *securityManager;
|
|
|
|
|
2007-12-05 22:05:04 +01:00
|
|
|
folderOwner = [parentFolder ownerInContext: context];
|
2007-12-05 00:28:52 +01:00
|
|
|
securityManager = [SoSecurityManager sharedSecurityManager];
|
2007-12-05 22:05:04 +01:00
|
|
|
|
2007-12-05 00:28:52 +01:00
|
|
|
folders = [NSMutableArray array];
|
|
|
|
|
|
|
|
subfolders = [[parentFolder subFolders] objectEnumerator];
|
|
|
|
while ((currentFolder = [subfolders nextObject]))
|
|
|
|
{
|
|
|
|
if (![securityManager validatePermission: SOGoPerm_AccessObject
|
2007-12-05 22:05:04 +01:00
|
|
|
onObject: currentFolder inContext: context]
|
|
|
|
&& [[currentFolder ownerInContext: context]
|
|
|
|
isEqualToString: folderOwner])
|
2007-12-05 00:28:52 +01:00
|
|
|
{
|
|
|
|
folderName = [NSString stringWithFormat: @"/%@/%@",
|
|
|
|
[parentFolder nameInContainer],
|
|
|
|
[currentFolder nameInContainer]];
|
|
|
|
currentDictionary
|
|
|
|
= [NSMutableDictionary dictionaryWithCapacity: 3];
|
|
|
|
[currentDictionary setObject: [currentFolder displayName]
|
|
|
|
forKey: @"displayName"];
|
|
|
|
[currentDictionary setObject: folderName forKey: @"name"];
|
|
|
|
[currentDictionary setObject: [currentFolder folderType]
|
|
|
|
forKey: @"type"];
|
|
|
|
[folders addObject: currentDictionary];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) foldersOfType: (NSString *) folderType
|
|
|
|
forUID: (NSString *) uid
|
|
|
|
{
|
|
|
|
NSObject *userFolder;
|
|
|
|
SOGoParentFolder *parentFolder;
|
|
|
|
NSMutableArray *folders;
|
|
|
|
|
|
|
|
folders = [NSMutableArray array];
|
|
|
|
|
|
|
|
userFolder = [container lookupName: uid inContext: context acquire: NO];
|
|
|
|
|
|
|
|
/* FIXME: should be moved in the SOGo* classes. Maybe by having a SOGoFolderManager. */
|
|
|
|
if ([folderType length] == 0 || [folderType isEqualToString: @"calendar"])
|
|
|
|
{
|
|
|
|
parentFolder = [userFolder lookupName: @"Calendar"
|
|
|
|
inContext: context acquire: NO];
|
|
|
|
[folders
|
|
|
|
addObjectsFromArray: [self _subFoldersFromFolder: parentFolder]];
|
|
|
|
}
|
|
|
|
if ([folderType length] == 0 || [folderType isEqualToString: @"contact"])
|
|
|
|
{
|
|
|
|
parentFolder = [userFolder lookupName: @"Contacts"
|
|
|
|
inContext: context acquire: NO];
|
|
|
|
[folders
|
|
|
|
addObjectsFromArray: [self _subFoldersFromFolder: parentFolder]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) foldersOfType: (NSString *) type
|
|
|
|
matchingUID: (NSString *) uid
|
|
|
|
{
|
|
|
|
NSArray *contacts, *folders;
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
NSDictionary *contact;
|
|
|
|
NSMutableDictionary *results;
|
|
|
|
|
|
|
|
results = [NSMutableDictionary dictionary];
|
|
|
|
|
|
|
|
contacts
|
2008-07-28 22:29:24 +02:00
|
|
|
= [[LDAPUserManager sharedUserManager] fetchUsersMatching: uid];
|
2007-12-05 00:28:52 +01:00
|
|
|
enumerator = [contacts objectEnumerator];
|
|
|
|
while ((contact = [enumerator nextObject]))
|
|
|
|
{
|
|
|
|
uid = [contact objectForKey: @"c_uid"];
|
|
|
|
folders = [self foldersOfType: type
|
|
|
|
forUID: [contact objectForKey: @"c_uid"]];
|
|
|
|
[results setObject: folders forKey: contact];
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
2008-04-24 03:08:34 +02:00
|
|
|
- (NSArray *) davResourceType
|
|
|
|
{
|
|
|
|
NSMutableArray *rType;
|
|
|
|
|
|
|
|
rType = [NSMutableArray arrayWithArray: [super davResourceType]];
|
|
|
|
[rType addObject: @"principal"];
|
|
|
|
|
|
|
|
return rType;
|
|
|
|
}
|
|
|
|
|
2007-12-05 00:28:52 +01:00
|
|
|
- (NSString *) _baseDAVURLWithSuffix: (NSString *) suffix
|
|
|
|
{
|
|
|
|
NSURL *prefixURL;
|
|
|
|
|
|
|
|
prefixURL = [NSURL URLWithString: [NSString stringWithFormat: @"../%@", suffix]
|
|
|
|
relativeToURL: [self davURL]];
|
|
|
|
|
|
|
|
return [[prefixURL standardizedURL] absoluteString];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _appendFolders: (NSDictionary *) users
|
|
|
|
toResponse: (WOResponse *) r
|
|
|
|
{
|
|
|
|
NSDictionary *currentContact, *currentFolder;
|
|
|
|
NSEnumerator *keys, *folders;
|
|
|
|
NSString *baseHREF, *data;
|
|
|
|
|
|
|
|
baseHREF = [self _baseDAVURLWithSuffix: @"./"];
|
|
|
|
|
|
|
|
keys = [[users allKeys] objectEnumerator];
|
|
|
|
while ((currentContact = [keys nextObject]))
|
|
|
|
{
|
|
|
|
folders = [[users objectForKey: currentContact] objectEnumerator];
|
|
|
|
while ((currentFolder = [folders nextObject]))
|
|
|
|
{
|
|
|
|
[r appendContentString: @"<D:response><D:href>"];
|
2008-05-22 23:47:31 +02:00
|
|
|
data = [NSString stringWithFormat: @"%@%@%@/", baseHREF,
|
2007-12-05 00:28:52 +01:00
|
|
|
[currentContact objectForKey: @"c_uid"],
|
|
|
|
[currentFolder objectForKey: @"name"]];
|
|
|
|
[r appendContentString: data];
|
|
|
|
[r appendContentString: @"</D:href><D:propstat>"];
|
|
|
|
[r appendContentString: @"<D:status>HTTP/1.1 200 OK</D:status>"];
|
|
|
|
[r appendContentString: @"</D:propstat><D:owner>"];
|
2008-05-22 23:47:31 +02:00
|
|
|
data = [NSString stringWithFormat: @"%@%@", baseHREF,
|
2007-12-05 00:28:52 +01:00
|
|
|
[currentContact objectForKey: @"c_uid"]];
|
|
|
|
[r appendContentString: data];
|
|
|
|
[r appendContentString: @"</D:owner><ownerdisplayname>"];
|
|
|
|
data = [currentContact keysWithFormat: @"%{cn} <%{c_email}>"];
|
|
|
|
[r appendContentString: [data stringByEscapingXMLString]];
|
|
|
|
[r appendContentString: @"</ownerdisplayname><D:displayname>"];
|
|
|
|
data = [currentFolder objectForKey: @"displayName"];
|
|
|
|
[r appendContentString: [data stringByEscapingXMLString]];
|
|
|
|
[r appendContentString: @"</D:displayname></D:response>\r\n"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _appendCollectionsMatchingFilter: (NSDictionary *) filter
|
|
|
|
toResponse: (WOResponse *) r
|
|
|
|
{
|
|
|
|
NSString *prefix, *queryOwner, *uid;
|
|
|
|
NSDictionary *folders;
|
|
|
|
|
|
|
|
prefix = [self _baseDAVURLWithSuffix: @"users/"];
|
|
|
|
queryOwner = [filter objectForKey: @"owner"];
|
|
|
|
if ([queryOwner hasPrefix: prefix])
|
|
|
|
{
|
|
|
|
uid = [queryOwner substringFromIndex: [prefix length]];
|
|
|
|
folders = [self foldersOfType: [filter objectForKey: @"resource-type"]
|
|
|
|
matchingUID: uid];
|
|
|
|
[self _appendFolders: folders toResponse: r];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-22 22:25:24 +01:00
|
|
|
- (id) davCollectionQuery: (WOContext *) queryContext
|
2007-12-05 00:28:52 +01:00
|
|
|
{
|
|
|
|
WOResponse *r;
|
|
|
|
NSDictionary *filter;
|
|
|
|
id <DOMDocument> document;
|
|
|
|
|
|
|
|
r = [context response];
|
|
|
|
[r setStatus: 207];
|
|
|
|
[r setContentEncoding: NSUTF8StringEncoding];
|
|
|
|
[r setHeader: @"text/xml; charset=\"utf-8\"" forKey: @"content-type"];
|
|
|
|
[r setHeader: @"no-cache" forKey: @"pragma"];
|
|
|
|
[r setHeader: @"no-cache" forKey: @"cache-control"];
|
|
|
|
[r appendContentString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"];
|
|
|
|
[r appendContentString: @"<D:multistatus xmlns:D=\"DAV:\""
|
|
|
|
@" xmlns=\"urn:ietf:params:xml:ns:inverse-dav\">\r\n"];
|
|
|
|
|
|
|
|
document = [[context request] contentAsDOMDocument];
|
|
|
|
filter = [self _parseCollectionFilters: document];
|
|
|
|
[self _appendCollectionsMatchingFilter: filter toResponse: r];
|
|
|
|
|
|
|
|
[r appendContentString:@"</D:multistatus>\r\n"];
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2006-08-05 01:02:13 +02:00
|
|
|
|
2008-02-22 22:25:24 +01:00
|
|
|
- (NSString *) _davFetchUsersMatching: (NSString *) user
|
|
|
|
{
|
|
|
|
LDAPUserManager *um;
|
|
|
|
NSEnumerator *users;
|
|
|
|
NSMutableString *fetch;
|
|
|
|
NSDictionary *currentUser;
|
|
|
|
NSString *field;
|
|
|
|
|
|
|
|
fetch = [NSMutableString string];
|
2008-07-29 18:34:10 +02:00
|
|
|
|
2008-02-22 22:25:24 +01:00
|
|
|
um = [LDAPUserManager sharedUserManager];
|
2008-07-29 18:34:10 +02:00
|
|
|
users = [[um fetchUsersMatching: user] objectEnumerator];
|
2008-02-22 22:25:24 +01:00
|
|
|
while ((currentUser = [users nextObject]))
|
|
|
|
{
|
|
|
|
[fetch appendString: @"<user>"];
|
|
|
|
field = [currentUser objectForKey: @"c_uid"];
|
|
|
|
[fetch appendFormat: @"<id>%@</id>",
|
|
|
|
[field stringByEscapingXMLString]];
|
|
|
|
field = [currentUser objectForKey: @"cn"];
|
|
|
|
[fetch appendFormat: @"<displayName>%@</displayName>",
|
|
|
|
[field stringByEscapingXMLString]];
|
|
|
|
field = [currentUser objectForKey: @"c_email"];
|
|
|
|
[fetch appendFormat: @"<email>%@</email>",
|
|
|
|
[field stringByEscapingXMLString]];
|
|
|
|
[fetch appendString: @"</user>"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return fetch;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) _davUsersFromQuery: (id <DOMDocument>) document
|
|
|
|
{
|
|
|
|
id <DOMNode> node, userAttr;
|
|
|
|
id <DOMNamedNodeMap> attrs;
|
|
|
|
NSString *nodeName, *result, *response, *user;
|
|
|
|
|
|
|
|
node = [[document documentElement] firstChild];
|
|
|
|
nodeName = [node nodeName];
|
|
|
|
if ([nodeName isEqualToString: @"users"])
|
|
|
|
{
|
|
|
|
attrs = [node attributes];
|
|
|
|
userAttr = [attrs namedItem: @"match-name"];
|
|
|
|
user = [userAttr nodeValue];
|
|
|
|
if ([user length])
|
|
|
|
result = [self _davFetchUsersMatching: user];
|
|
|
|
else
|
|
|
|
result = nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = nil;
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
if ([result length])
|
|
|
|
response = [NSString stringWithFormat: @"<%@>%@</%@>",
|
|
|
|
nodeName, result, nodeName];
|
|
|
|
else
|
|
|
|
response = @"";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response = nil;
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) davUserQuery: (WOContext *) queryContext
|
|
|
|
{
|
|
|
|
WOResponse *r;
|
|
|
|
id <DOMDocument> document;
|
|
|
|
NSString *content;
|
|
|
|
|
|
|
|
r = [queryContext response];
|
|
|
|
[r setContentEncoding: NSUTF8StringEncoding];
|
|
|
|
[r setHeader: @"text/xml; charset=\"utf-8\"" forKey: @"content-type"];
|
|
|
|
[r setHeader: @"no-cache" forKey: @"pragma"];
|
|
|
|
[r setHeader: @"no-cache" forKey: @"cache-control"];
|
|
|
|
|
|
|
|
document = [[context request] contentAsDOMDocument];
|
|
|
|
content = [self _davUsersFromQuery: document];
|
|
|
|
if (content)
|
|
|
|
{
|
|
|
|
[r setStatus: 207];
|
|
|
|
if ([content length])
|
|
|
|
{
|
|
|
|
[r appendContentString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"];
|
|
|
|
[r appendContentString: content];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[r setStatus: 400];
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-02-07 21:24:22 +01:00
|
|
|
- (SOGoAppointmentFolders *) privateCalendars: (NSString *) key
|
|
|
|
inContext: (WOContext *) localContext
|
2006-12-14 22:20:13 +01:00
|
|
|
{
|
2007-09-15 00:01:02 +02:00
|
|
|
SOGoAppointmentFolders *calendars;
|
2008-02-07 21:24:22 +01:00
|
|
|
NSString *baseOCSPath;
|
|
|
|
|
|
|
|
calendars = [$(@"SOGoAppointmentFolders") objectWithName: key
|
|
|
|
inContainer: self];
|
|
|
|
baseOCSPath = [NSString stringWithFormat: @"/Users/%@/Calendar",
|
|
|
|
[self ownerInContext: nil]];
|
|
|
|
[calendars setBaseOCSPath: baseOCSPath];
|
2006-08-31 01:11:12 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
return calendars;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (SOGoContactFolders *) privateContacts: (NSString *) _key
|
|
|
|
inContext: (WOContext *) _ctx
|
2006-08-05 01:02:13 +02:00
|
|
|
{
|
|
|
|
SOGoContactFolders *contacts;
|
2008-02-07 21:24:22 +01:00
|
|
|
NSString *baseOCSPath;
|
2006-08-05 01:02:13 +02:00
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
contacts = [$(@"SOGoContactFolders") objectWithName:_key inContainer: self];
|
2008-02-07 21:24:22 +01:00
|
|
|
baseOCSPath = [NSString stringWithFormat: @"/Users/%@/Contacts",
|
|
|
|
[self ownerInContext: nil]];
|
|
|
|
[contacts setBaseOCSPath: baseOCSPath];
|
2006-08-05 01:02:13 +02:00
|
|
|
|
|
|
|
return contacts;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (id) mailAccountsFolder: (NSString *) _key
|
|
|
|
inContext: (WOContext *) _ctx
|
|
|
|
{
|
|
|
|
return [$(@"SOGoMailAccounts") objectWithName: _key inContainer: self];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (id) freeBusyObject: (NSString *) _key
|
|
|
|
inContext: (WOContext *) _ctx
|
|
|
|
{
|
|
|
|
return [$(@"SOGoFreeBusyObject") objectWithName: _key inContainer: self];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-08-26 19:40:02 +02:00
|
|
|
- (WOResponse *) _moduleAccessDeniedPage
|
|
|
|
{
|
|
|
|
WOResponse *response;
|
|
|
|
UIxComponent *page;
|
|
|
|
NSString *content;
|
|
|
|
|
|
|
|
response = [context response];
|
|
|
|
[response setStatus: 403];
|
|
|
|
[response setHeader: @"text/html; charset=utf8"
|
|
|
|
forKey: @"content-type"];
|
|
|
|
page = [[WOApplication application] pageWithName: @"UIxModuleAccessDenied"
|
|
|
|
inContext: context];
|
|
|
|
// [page appendToResponse: response
|
|
|
|
// inContext: context];
|
|
|
|
content = [[page generateResponse] contentAsString];
|
|
|
|
[response appendContentString: content];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (id) lookupName: (NSString *) _key
|
|
|
|
inContext: (WOContext *) _ctx
|
|
|
|
acquire: (BOOL) _flag
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
id obj;
|
2007-11-26 21:41:59 +01:00
|
|
|
SOGoUser *currentUser;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/* first check attributes directly bound to the application */
|
2006-12-14 22:20:13 +01:00
|
|
|
obj = [super lookupName: _key inContext: _ctx acquire: NO];
|
|
|
|
if (!obj)
|
|
|
|
{
|
2007-11-26 21:41:59 +01:00
|
|
|
currentUser = [_ctx activeUser];
|
2008-08-26 19:40:02 +02:00
|
|
|
if ([_key isEqualToString: @"Calendar"])
|
|
|
|
{
|
|
|
|
if ([currentUser canAccessModule: _key])
|
|
|
|
obj = [self privateCalendars: @"Calendar" inContext: _ctx];
|
|
|
|
else
|
|
|
|
obj = [self _moduleAccessDeniedPage];
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
else if ([_key isEqualToString: @"Contacts"])
|
|
|
|
obj = [self privateContacts: _key inContext: _ctx];
|
2008-08-26 19:40:02 +02:00
|
|
|
else if ([_key isEqualToString: @"Mail"])
|
|
|
|
{
|
|
|
|
if ([currentUser canAccessModule: _key])
|
|
|
|
obj = [self mailAccountsFolder: _key inContext: _ctx];
|
|
|
|
else
|
|
|
|
obj = [self _moduleAccessDeniedPage];
|
|
|
|
}
|
2007-11-07 16:58:43 +01:00
|
|
|
else if ([_key isEqualToString: @"Preferences"])
|
|
|
|
obj = [$(@"SOGoPreferencesFolder") objectWithName: _key
|
|
|
|
inContainer: self];
|
2006-12-14 22:20:13 +01:00
|
|
|
else if ([_key isEqualToString: @"freebusy.ifb"])
|
2007-04-11 21:08:58 +02:00
|
|
|
obj = [self freeBusyObject:_key inContext: _ctx];
|
2006-12-14 22:20:13 +01:00
|
|
|
else
|
|
|
|
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
return obj;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* WebDAV */
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (NSArray *) fetchContentObjectNames
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
static NSArray *cos = nil;
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
if (!cos)
|
|
|
|
cos = [[NSArray alloc] initWithObjects: @"freebusy.ifb", nil];
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return cos;
|
|
|
|
}
|
|
|
|
|
2008-05-03 01:13:40 +02:00
|
|
|
- (NSString *) davDisplayName
|
|
|
|
{
|
|
|
|
return [[LDAPUserManager sharedUserManager]
|
|
|
|
getCNForUID: nameInContainer];
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (BOOL) davIsCollection
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end /* SOGoUserFolder */
|