diff --git a/ChangeLog b/ChangeLog index 9c897fd6a..911d6cdca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2009-12-08 Wolfgang Sourdeau + * Main/SOGo.m (-lookupName:inContext:acquire:): ensure the web + access is enabled or the request is a DAV request before + proceeding. + + * SoObjects/SOGo/SOGoUserFolder.m (-toManyRelationShipKeys) + (-fetchContentObjectNames): ensure the proper dav access is + enabled in order before listing the related objects. + + * SoObjects/SOGo/SOGoSystemDefaults.m (-isWebAccessEnabled) + (-isCalendarDAVAccessEnabled, isAddressBookDAVAccessEnabled): new + self-explanatory accessors. + * Main/SOGo.m (-davURLAsString): we ensure that the url ends with "/" since the /SOGo object is a collection and the caller may rely on this. diff --git a/Main/SOGo.m b/Main/SOGo.m index 8e06119b2..41d10a471 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -33,7 +33,7 @@ #import #import -#import +#import #import #import @@ -311,28 +311,35 @@ static BOOL debugLeaks; acquire: (BOOL) _flag { id obj; + SOGoSystemDefaults *sd; /* put locale info into the context in case it's not there */ [self _setupLocaleInContext:_ctx]; - - /* first check attributes directly bound to the application */ - obj = [super lookupName:_key inContext:_ctx acquire:_flag]; - if (!obj) + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd isWebAccessEnabled] || [[_ctx request] isSoWebDAVRequest]) { - /* - The problem is, that at this point we still get request for resources, - eg 'favicon.ico'. - - Addition: we also get queries for various other methods, like "GET" if - no method was provided in the query path. - */ + /* first check attributes directly bound to the application */ + obj = [super lookupName:_key inContext:_ctx acquire:_flag]; + if (!obj) + { + /* + The problem is, that at this point we still get request for + resources, eg 'favicon.ico'. + + Addition: we also get queries for various other methods, like + "GET" if no method was provided in the query path. + */ - if (![_key isEqualToString:@"favicon.ico"]) - { - if ([self isUserName: _key inContext: _ctx]) - obj = [self lookupUser: _key inContext: _ctx]; - } + if (![_key isEqualToString:@"favicon.ico"]) + { + if ([self isUserName: _key inContext: _ctx]) + obj = [self lookupUser: _key inContext: _ctx]; + } + } } + else + obj = nil; return obj; } diff --git a/SoObjects/SOGo/SOGoDefaults.plist b/SoObjects/SOGo/SOGoDefaults.plist index ff1f201f3..9a1798bc0 100644 --- a/SoObjects/SOGo/SOGoDefaults.plist +++ b/SoObjects/SOGo/SOGoDefaults.plist @@ -22,6 +22,10 @@ SOGoSMTPServer = "localhost"; SOGoMailSpoolPath = "/tmp"; + SOGoWebAccessEnabled = YES; + SOGoCalendarDAVAccessEnabled = YES; + SOGoAddressBookDAVAccessEnabled = YES; + SOGoLoginModule = "Mail"; SOGoLanguage = "English"; SOGoSupportedLanguages = ( "Czech", "Welsh", "English", "Spanish", diff --git a/SoObjects/SOGo/SOGoSystemDefaults.h b/SoObjects/SOGo/SOGoSystemDefaults.h index 5c7bafa44..88547db62 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.h +++ b/SoObjects/SOGo/SOGoSystemDefaults.h @@ -38,6 +38,10 @@ - (BOOL) trustProxyAuthentication; - (BOOL) useRelativeURLs; +- (BOOL) isWebAccessEnabled; +- (BOOL) isCalendarDAVAccessEnabled; +- (BOOL) isAddressBookDAVAccessEnabled; + - (NSString *) faviconRelativeURL; - (NSString *) zipPath; - (int) port; diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index f53b41c93..a70c58a7f 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -205,6 +205,21 @@ BootstrapNSUserDefaults () return [self boolForKey: @"WOUseRelativeURLs"]; } +- (BOOL) isWebAccessEnabled +{ + return [self boolForKey: @"SOGoWebAccessEnabled"]; +} + +- (BOOL) isCalendarDAVAccessEnabled +{ + return [self boolForKey: @"SOGoCalendarDAVAccessEnabled"]; +} + +- (BOOL) isAddressBookDAVAccessEnabled +{ + return [self boolForKey: @"SOGoAddressBookDAVAccessEnabled"]; +} + - (NSString *) faviconRelativeURL { return [self stringForKey: @"SOGoFaviconRelativeURL"]; diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index 6033c782b..fe593b41d 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -31,6 +31,7 @@ #import #import #import +#import #import #import @@ -53,6 +54,7 @@ #import "NSDictionary+Utilities.h" #import "SOGoUserManager.h" #import "SOGoPermissions.h" +#import "SOGoSystemDefaults.h" #import "SOGoUser.h" #import "WORequest+SOGo.h" @@ -66,11 +68,16 @@ { NSMutableArray *children; SOGoUser *currentUser; + BOOL isDAVRequest; + SOGoSystemDefaults *sd; children = [NSMutableArray arrayWithCapacity: 4]; + sd = [SOGoSystemDefaults sharedSystemDefaults]; + isDAVRequest = [[context request] isSoWebDAVRequest]; currentUser = [context activeUser]; - if ([currentUser canAccessModule: @"Calendar"]) + if ((!isDAVRequest || [sd isCalendarDAVAccessEnabled]) + && [currentUser canAccessModule: @"Calendar"]) { [children addObject: @"Calendar"]; /* support for caldav-proxy, which is currently limited to iCal but may @@ -82,7 +89,8 @@ [children addObject: @"calendar-proxy-read"]; } } - [children addObject: @"Contacts"]; + if (isDAVRequest && [sd isAddressBookDAVAccessEnabled]) + [children addObject: @"Contacts"]; if ([currentUser canAccessModule: @"Mail"]) [children addObject: @"Mail"]; // [children addObject: @"Preferences"]; @@ -543,15 +551,20 @@ inContext: (WOContext *) _ctx acquire: (BOOL) _flag { - id obj; SOGoUser *currentUser; + BOOL isDAVRequest; + SOGoSystemDefaults *sd; + id obj; /* first check attributes directly bound to the application */ obj = [super lookupName: _key inContext: _ctx acquire: NO]; if (!obj) { + sd = [SOGoSystemDefaults sharedSystemDefaults]; + isDAVRequest = [[context request] isSoWebDAVRequest]; currentUser = [_ctx activeUser]; - if ([currentUser canAccessModule: @"Calendar"]) + if ((!isDAVRequest || [sd isCalendarDAVAccessEnabled]) + && [currentUser canAccessModule: @"Calendar"]) { if ([_key isEqualToString: @"Calendar"]) obj = [self privateCalendars: @"Calendar" inContext: _ctx]; @@ -568,7 +581,9 @@ && [currentUser canAccessModule: @"Mail"]) obj = [self mailAccountsFolder: _key inContext: _ctx]; - if (!obj && [_key isEqualToString: @"Contacts"]) + if (!obj + && [_key isEqualToString: @"Contacts"] + && (isDAVRequest && [sd isAddressBookDAVAccessEnabled])) obj = [self privateContacts: _key inContext: _ctx]; // else if ([_key isEqualToString: @"Preferences"]) @@ -586,10 +601,20 @@ - (NSArray *) fetchContentObjectNames { + SOGoSystemDefaults *sd; + SOGoUser *currentUser; static NSArray *cos = nil; - - if (!cos) - cos = [[NSArray alloc] initWithObjects: @"freebusy.ifb", nil]; + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + currentUser = [context activeUser]; + if ((![[context request] isSoWebDAVRequest] || [sd isCalendarDAVAccessEnabled]) + && [currentUser canAccessModule: @"Calendar"]) + { + if (!cos) + cos = [[NSArray alloc] initWithObjects: @"freebusy.ifb", nil]; + } + else + cos = [NSArray array]; return cos; }