diff --git a/ChangeLog b/ChangeLog index fe3109dc9..b89517622 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2007-11-08 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder -create]): overriden method that invokes + its ancestor and then activate itself within the user settings. + + * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder + -appendPersonalSources]): when the user is the owner of the + current folder, we create the "personal" folder if it doesn't + exist by invoking "create". + * SoObjects/SOGo/AgenorUserDefaults.m ([AgenorUserDefaults -primaryFetchProfile]): when no row is returned, we initialize "values" to a new dictionary. This solves a bug where the defaults diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 395d92e80..cd1a553f5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -48,6 +48,7 @@ #import #import #import +#import #import #import @@ -962,6 +963,40 @@ static NSNumber *sharedYes = nil; } /* folder management */ +- (BOOL) create +{ + BOOL rc; + NSMutableArray *folderSubscription; + NSUserDefaults *userSettings; + NSMutableDictionary *calendarSettings; + SOGoUser *ownerUser; + + rc = [super create]; + if (rc) + { + ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context] + roles: nil]; + userSettings = [ownerUser userSettings]; + calendarSettings = [userSettings objectForKey: @"Calendar"]; + if (!calendarSettings) + { + calendarSettings = [NSMutableDictionary dictionary]; + [userSettings setObject: calendarSettings forKey: @"Calendar"]; + } + folderSubscription + = [calendarSettings objectForKey: @"ActiveFolders"]; + if (!folderSubscription) + { + folderSubscription = [NSMutableArray array]; + [calendarSettings setObject: folderSubscription + forKey: @"ActiveFolders"]; + } + [folderSubscription addObjectUniquely: nameInContainer]; + [userSettings synchronize]; + } + + return rc; +} - (id) lookupHomeFolderForUID: (NSString *) _uid inContext: (id)_ctx diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index a06e39c9c..c73ed9f12 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -32,6 +32,7 @@ #import #import "SOGoGCSFolder.h" +#import "SOGoPermissions.h" #import "SOGoUser.h" #import "SOGoParentFolder.h" @@ -81,13 +82,30 @@ return @"Personal"; } +- (void) _createPersonalFolder +{ + NSArray *roles; + SOGoGCSFolder *folder; + + roles = [[context activeUser] rolesForObject: self inContext: context]; + if ([roles containsObject: SoRole_Owner]) + { + folder = [subFolderClass objectWithName: @"personal" inContainer: self]; + [folder setDisplayName: [self defaultFolderName]]; + [folder + setOCSPath: [NSString stringWithFormat: @"%@/personal", OCSPath]]; + if ([folder create]) + [subFolders setObject: folder forKey: @"personal"]; + } +} + - (void) _fetchPersonalFolders: (NSString *) sql withChannel: (EOAdaptorChannel *) fc { NSArray *attrs; NSDictionary *row; - SOGoGCSFolder *folder; BOOL hasPersonal; + SOGoGCSFolder *folder; NSString *key; if (!subFolderClass) @@ -111,17 +129,8 @@ row = [fc fetchAttributes: attrs withZone: NULL]; } -// if (!hasPersonal) -// { -// folder = [subFolderClass objectWithName: @"personal" inContainer: self]; -// personalName = [self labelForKey: [self defaultFolderName]]; -// [folder setDisplayName: personalName]; -// path = [NSString stringWithFormat: @"/Users/%@/%@/personal", -// [self ownerInContext: context], -// nameInContainer]; -// [folder setOCSPath: path]; -// [subFolders setObject: folder forKey: @"personal"]; -// } + if (!hasPersonal) + [self _createPersonalFolder]; } - (void) appendPersonalSources