02111-1307, USA.
*/
-#import "WOContext+Agenor.h"
-#import "common.h"
-#import "SOGoUser.h"
+#import <Foundation/NSArray.h>
+#import <Foundation/NSString.h>
+
+#import <NGObjWeb/NSException+HTTP.h>
+#import <NGObjWeb/SoClassSecurityInfo.h>
+#import <NGExtensions/NSObject+Logs.h>
+
+#import <Appointments/SOGoAppointmentFolders.h>
+#import <Appointments/SOGoFreeBusyObject.h>
+#import <Contacts/SOGoContactFolders.h>
+#import <Mailer/SOGoMailAccounts.h>
-#import "Appointments/SOGoAppointmentFolder.h"
-#import "Appointments/SOGoFreeBusyObject.h"
-#import "Contacts/SOGoContactFolders.h"
-#import "Mailer/SOGoMailAccounts.h"
#import "SOGoPermissions.h"
+#import "SOGoUser.h"
#import "SOGoUserFolder.h"
@implementation SOGoUserFolder
++ (void) initialize
+{
+ SoClassSecurityInfo *sInfo;
+ NSArray *basicRoles;
+
+ sInfo = [self soClassSecurityInfo];
+ [sInfo declareObjectProtected: SoPerm_View];
+
+ basicRoles = [NSArray arrayWithObject: SoRole_Authenticated];
+
+ /* require Authenticated role for View and WebDAV */
+ [sInfo declareRoles: basicRoles asDefaultForPermission: SoPerm_View];
+ [sInfo declareRoles: basicRoles asDefaultForPermission: SoPerm_WebDAVAccess];
+}
+
/* accessors */
- (NSString *) login
return self;
}
-- (SOGoGroupsFolder *) lookupGroupsFolder
-{
- return [self lookupName: @"Groups" inContext: nil acquire: NO];
-}
+// - (SOGoGroupsFolder *) lookupGroupsFolder
+// {
+// return [self lookupName: @"Groups" inContext: nil acquire: NO];
+// }
/* pathes */
- (NSString *) ocsPath
{
- return [@"/Users/" stringByAppendingString: [self login]];
+ return [NSString stringWithFormat: @"/Users/%@", nameInContainer];
}
- (NSString *) ocsUserPath
return [self ocsPath];
}
+- (BOOL) folderIsMandatory
+{
+ return NO;
+}
+
- (NSString *) ocsPrivateCalendarPath
{
return [[self ocsUserPath] stringByAppendingString:@"/Calendar"];
// : [super permissionForKey: key]);
// }
-- (SOGoAppointmentFolder *) privateCalendar: (NSString *) _key
- inContext: (WOContext *) _ctx
+- (SOGoAppointmentFolders *) privateCalendars: (NSString *) _key
+ inContext: (WOContext *) _ctx
{
- SOGoAppointmentFolder *calendar;
+ SOGoAppointmentFolders *calendars;
- calendar = [$(@"SOGoAppointmentFolder") objectWithName: _key inContainer: self];
- [calendar setOCSPath: [self ocsPrivateCalendarPath]];
+ calendars = [$(@"SOGoAppointmentFolders") objectWithName: _key inContainer: self];
+ [calendars setBaseOCSPath: [self ocsPrivateCalendarPath]];
- return calendar;
+ return calendars;
}
- (SOGoContactFolders *) privateContacts: (NSString *) _key
return contacts;
}
-- (id) groupsFolder: (NSString *) _key
- inContext: (WOContext *) _ctx
-{
- return [$(@"SOGoGroupsFolder") objectWithName: _key inContainer: self];
-}
+// - (id) groupsFolder: (NSString *) _key
+// inContext: (WOContext *) _ctx
+// {
+// return [$(@"SOGoGroupsFolder") objectWithName: _key inContainer: self];
+// }
- (id) mailAccountsFolder: (NSString *) _key
inContext: (WOContext *) _ctx
obj = [super lookupName: _key inContext: _ctx acquire: NO];
if (!obj)
{
- if ([_key hasPrefix: @"Calendar"])
- {
- obj = [self privateCalendar: @"Calendar" inContext: _ctx];
- if (![_key isEqualToString: @"Calendar"])
- obj = [obj lookupName: [_key pathExtension]
- inContext: _ctx acquire: NO];
- }
+ if ([_key isEqualToString: @"Calendar"])
+ obj = [self privateCalendars: @"Calendar" inContext: _ctx];
+// if (![_key isEqualToString: @"Calendar"])
+// obj = [obj lookupName: [_key pathExtension]
+// inContext: _ctx acquire: NO];
else if ([_key isEqualToString: @"Contacts"])
obj = [self privateContacts: _key inContext: _ctx];
- else if ([_key isEqualToString: @"Groups"])
- obj = [self groupsFolder: _key inContext: _ctx];
+// else if ([_key isEqualToString: @"Groups"])
+// obj = [self groupsFolder: _key inContext: _ctx];
else if ([_key isEqualToString: @"Mail"])
obj = [self mailAccountsFolder: _key inContext: _ctx];
else if ([_key isEqualToString: @"freebusy.ifb"])
- obj = [self freeBusyObject:_key inContext:_ctx];
+ obj = [self freeBusyObject:_key inContext: _ctx];
else
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
}
return obj;
}
-/* FIXME: here is a vault of hackish ways to gain access to subobjects by
- granting ro access to the homepage depending on the subobject in question.
- This is wrong and dangerous. */
-- (NSString *) roleOfUser: (NSString *) uid
- inContext: (WOContext *) context
-{
- NSArray *roles, *traversalPath;
- NSString *objectName, *role;
-
- role = nil;
- traversalPath = [context objectForKey: @"SoRequestTraversalPath"];
- if ([traversalPath count] > 1)
- {
- objectName = [traversalPath objectAtIndex: 1];
- if ([objectName isEqualToString: @"Calendar"]
- || [objectName isEqualToString: @"Contacts"])
- {
- roles = [[context activeUser]
- rolesForObject: [self lookupName: objectName
- inContext: context
- acquire: NO]
- inContext: context];
- if ([roles containsObject: SOGoRole_Assistant]
- || [roles containsObject: SOGoRole_Delegate])
- role = SOGoRole_Assistant;
- }
- else if ([objectName isEqualToString: @"freebusy.ifb"])
- role = SOGoRole_Assistant;
- }
-
- return role;
-}
+// /* FIXME: here is a vault of hackish ways to gain access to subobjects by
+// granting ro access to the homepage depending on the subobject in question.
+// This is wrong and dangerous. */
+// - (NSString *) roleOfUser: (NSString *) uid
+// inContext: (WOContext *) context
+// {
+// NSArray *roles, *traversalPath;
+// NSString *objectName, *role;
+
+// role = nil;
+// traversalPath = [context objectForKey: @"SoRequestTraversalPath"];
+// if ([traversalPath count] > 1)
+// {
+// objectName = [traversalPath objectAtIndex: 1];
+// if ([objectName isEqualToString: @"Calendar"]
+// || [objectName isEqualToString: @"Contacts"])
+// {
+// roles = [[context activeUser]
+// rolesForObject: [self lookupName: objectName
+// inContext: context
+// acquire: NO]
+// inContext: context];
+// if ([roles containsObject: SOGoRole_Assistant]
+// || [roles containsObject: SOGoRole_Delegate])
+// role = SOGoRole_Assistant;
+// }
+// else if ([objectName isEqualToString: @"freebusy.ifb"])
+// role = SOGoRole_Assistant;
+// }
+
+// return role;
+// }
/* WebDAV */
return YES;
}
+/* CalDAV support */
+- (NSArray *) davCalendarHomeSet
+{
+ /*
+ <C:calendar-home-set xmlns:D="DAV:"
+ xmlns:C="urn:ietf:params:xml:ns:caldav">
+ <D:href>http://cal.example.com/home/bernard/calendars/</D:href>
+ </C:calendar-home-set>
+
+ Note: this is the *container* for calendar collections, not the
+ collections itself. So for use its the home folder, the
+ public folder and the groups folder.
+ */
+ NSArray *tag;
+
+ tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+ [self baseURLInContext: context], nil];
+
+ return [NSArray arrayWithObject: tag];
+}
+
@end /* SOGoUserFolder */