2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import "WOContext+Agenor.h"
26 #import "Appointments/SOGoAppointmentFolder.h"
27 #import "Appointments/SOGoFreeBusyObject.h"
28 #import "Contacts/SOGoContactFolders.h"
29 #import "Mailer/SOGoMailAccounts.h"
30 #import "SOGoPermissions.h"
32 #import "SOGoUserFolder.h"
34 @implementation SOGoUserFolder
40 return nameInContainer;
45 - (NSArray *) toManyRelationshipKeys
47 static NSArray *children = nil;
50 children = [[NSArray alloc] initWithObjects:
51 @"Calendar", @"Contacts", @"Mail", nil];
58 - (NSString *) ownerInContext: (WOContext *) _ctx
60 return nameInContainer;
63 /* looking up shared objects */
65 - (SOGoUserFolder *) lookupUserFolder
70 - (SOGoGroupsFolder *) lookupGroupsFolder
72 return [self lookupName: @"Groups" inContext: nil acquire: NO];
77 - (void) setOCSPath: (NSString *) _path
80 @"rejected attempt to reset user-folder path: '%@'", _path];
83 - (NSString *) ocsPath
85 return [@"/Users/" stringByAppendingString: [self login]];
88 - (NSString *) ocsUserPath
90 return [self ocsPath];
93 - (NSString *) ocsPrivateCalendarPath
95 return [[self ocsUserPath] stringByAppendingString:@"/Calendar"];
98 - (NSString *) ocsPrivateContactsPath
100 return [[self ocsUserPath] stringByAppendingString:@"/Contacts"];
105 // - (NSString *) permissionForKey: (NSString *) key
107 // return ([key isEqualToString: @"freebusy.ifb"]
108 // ? SoPerm_WebDAVAccess
109 // : [super permissionForKey: key]);
112 - (SOGoAppointmentFolder *) privateCalendar: (NSString *) _key
113 inContext: (WOContext *) _ctx
115 SOGoAppointmentFolder *calendar;
117 calendar = [$(@"SOGoAppointmentFolder") objectWithName: _key inContainer: self];
118 [calendar setOCSPath: [self ocsPrivateCalendarPath]];
123 - (SOGoContactFolders *) privateContacts: (NSString *) _key
124 inContext: (WOContext *) _ctx
126 SOGoContactFolders *contacts;
128 contacts = [$(@"SOGoContactFolders") objectWithName:_key inContainer: self];
129 [contacts setBaseOCSPath: [self ocsPrivateContactsPath]];
134 - (id) groupsFolder: (NSString *) _key
135 inContext: (WOContext *) _ctx
137 return [$(@"SOGoGroupsFolder") objectWithName: _key inContainer: self];
140 - (id) mailAccountsFolder: (NSString *) _key
141 inContext: (WOContext *) _ctx
143 return [$(@"SOGoMailAccounts") objectWithName: _key inContainer: self];
146 - (id) freeBusyObject: (NSString *) _key
147 inContext: (WOContext *) _ctx
149 return [$(@"SOGoFreeBusyObject") objectWithName: _key inContainer: self];
152 - (id) lookupName: (NSString *) _key
153 inContext: (WOContext *) _ctx
154 acquire: (BOOL) _flag
158 /* first check attributes directly bound to the application */
159 obj = [super lookupName: _key inContext: _ctx acquire: NO];
162 if ([_key hasPrefix: @"Calendar"])
164 obj = [self privateCalendar: @"Calendar" inContext: _ctx];
165 if (![_key isEqualToString: @"Calendar"])
166 obj = [obj lookupName: [_key pathExtension]
167 inContext: _ctx acquire: NO];
169 else if ([_key isEqualToString: @"Contacts"])
170 obj = [self privateContacts: _key inContext: _ctx];
171 else if ([_key isEqualToString: @"Groups"])
172 obj = [self groupsFolder: _key inContext: _ctx];
173 else if ([_key isEqualToString: @"Mail"])
174 obj = [self mailAccountsFolder: _key inContext: _ctx];
175 else if ([_key isEqualToString: @"freebusy.ifb"])
176 obj = [self freeBusyObject:_key inContext:_ctx];
178 obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
184 - (NSString *) roleOfUser: (NSString *) uid
185 inContext: (WOContext *) context
187 NSArray *roles, *traversalPath;
188 NSString *objectName, *role;
191 traversalPath = [context objectForKey: @"SoRequestTraversalPath"];
192 if ([traversalPath count] > 1)
194 objectName = [traversalPath objectAtIndex: 1];
195 if ([objectName isEqualToString: @"Calendar"]
196 || [objectName isEqualToString: @"Contacts"])
198 roles = [[context activeUser]
199 rolesForObject: [self lookupName: objectName
203 if ([roles containsObject: SOGoRole_Assistant]
204 || [roles containsObject: SOGoRole_Delegate])
205 role = SOGoRole_Assistant;
214 - (NSArray *) fetchContentObjectNames
216 static NSArray *cos = nil;
219 cos = [[NSArray alloc] initWithObjects: @"freebusy.ifb", nil];
224 - (BOOL) davIsCollection
229 @end /* SOGoUserFolder */