diff --git a/SoObjects/Appointments/SOGoAppointmentFolders.h b/SoObjects/Appointments/SOGoAppointmentFolders.h index a4b84a6dc..c196d5dc5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolders.h +++ b/SoObjects/Appointments/SOGoAppointmentFolders.h @@ -1,8 +1,6 @@ /* SOGoAppointmentFolders.h - this file is part of SOGo * - * Copyright (C) 2007 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2013 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,8 +33,8 @@ NSMutableArray *folderObjectKeys; } -- (SOGoWebAppointmentFolder *) newWebCalendarWithName: (NSString *) folderDisplayName - atURL: (NSString *) url; +- (SOGoWebAppointmentFolder *) newWebCalendarWithURL: (NSString *) urlString + nameInContainer: (NSString *) name; - (void) reloadWebCalendars: (BOOL) forceReload; diff --git a/SoObjects/Appointments/SOGoAppointmentFolders.m b/SoObjects/Appointments/SOGoAppointmentFolders.m index b2dde6b4d..883564a7e 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolders.m +++ b/SoObjects/Appointments/SOGoAppointmentFolders.m @@ -1,9 +1,7 @@ /* SOGoAppointmentFolders.m - this file is part of SOGo * - * Copyright (C) 2007-2010 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2013 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -133,18 +131,29 @@ static SoSecurityManager *sm = nil; return [self labelForKey: @"Personal Calendar" inContext: context]; } -- (SOGoWebAppointmentFolder *) - newWebCalendarWithName: (NSString *) folderDisplayName - atURL: (NSString *) urlString + + +- (SOGoWebAppointmentFolder *) newWebCalendarWithURL: (NSString *) urlString + nameInContainer: (NSString *) name { - NSException *error; - SOGoAppointmentFolder *aptFolder; + NSString *folderDisplayName, *tmp; SOGoWebAppointmentFolder *webCalendar; - NSString *name; + SOGoAppointmentFolder *aptFolder; + NSException *error; NSURL *url; + folderDisplayName = [self labelForKey: @"Web Calendar"]; webCalendar = nil; + tmp = [urlString lastPathComponent]; + if (tmp) + { + if ([[tmp pathExtension] caseInsensitiveCompare: @"ics"] == NSOrderedSame) + folderDisplayName = [tmp substringToIndex: [tmp length] - 4]; + else + folderDisplayName = tmp; + } + if ([folderDisplayName length] > 0 && [urlString length] > 0) { url = [NSURL URLWithString: urlString]; @@ -154,6 +163,10 @@ static SoSecurityManager *sm = nil; nameInContainer: &name]; if (!error) { + // We make sure we initialized our subfolfers list. This can happen + // when auto-creating Web calendars during the logon process. + [self subFolders]; + aptFolder = [subFolders objectForKey: name]; [aptFolder setFolderPropertyValue: urlString inCategory: @"WebCalendars"]; @@ -561,9 +574,25 @@ static SoSecurityManager *sm = nil; folder = [SOGoWebAppointmentFolder folderWithSubscriptionReference: ref inContainer: self]; - if (folder - && (forceReload || [folder reloadOnLogin])) - [folder loadWebCalendar]; + + if (forceReload || [folder reloadOnLogin] || !folder) + { + if (!folder) + { + NSString *s, *urlString; + + urlString = [[calSettings objectForKey: @"WebCalendars"] objectForKey: ref]; + s = [ref lastPathComponent]; + + // See bug #2007. Some admins want to subscribe users to Web calendars + // using sogo-tool. If they do that, the db tables won't be created + // so we must detect that here and create them upon login. + folder = [self newWebCalendarWithURL: urlString + nameInContainer: s]; + } + + [folder loadWebCalendar]; + } } } diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index df82535e2..245df3a3e 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -1,9 +1,6 @@ /* NSString+Utilities.h - this file is part of SOGo * - * Copyright (C) 2006-2011 Inverse inc. - * - * Author: Wolfgang Sourdeau - * Ludovic Marcotte + * Copyright (C) 2006-2013 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index afca514b9..59241ba4b 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -2,9 +2,6 @@ * * Copyright (C) 2006-2013 Inverse inc. * - * Author: Wolfgang Sourdeau - * Ludovic Marcotte - * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index a3cb35394..e806beca0 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -364,7 +364,11 @@ static SoSecurityManager *sm = nil; NSString *newFolderID; NSException *error; - newFolderID = [self globallyUniqueObjectId]; + newFolderID = *newNameInContainer; + + if (!newFolderID) + newFolderID = [self globallyUniqueObjectId]; + error = [self newFolderWithName: name andNameInContainer: newFolderID]; if (error) diff --git a/UI/Scheduler/UIxCalMainActions.m b/UI/Scheduler/UIxCalMainActions.m index e416d221c..756c65b8c 100644 --- a/UI/Scheduler/UIxCalMainActions.m +++ b/UI/Scheduler/UIxCalMainActions.m @@ -37,24 +37,6 @@ @implementation UIxCalMainActions -- (NSString *) displayNameForUrl: (NSString *) calendarURL -{ - NSString *rc, *tmp; - - tmp = [calendarURL lastPathComponent]; - if (tmp) - { - if ([[tmp pathExtension] caseInsensitiveCompare: @"ics"] == NSOrderedSame) - rc = [tmp substringToIndex: [tmp length] - 4]; - else - rc = tmp; - } - else - rc = [self labelForKey: @"Web Calendar"]; - - return rc; -} - - (WOResponse *) addWebCalendarAction { WORequest *r; @@ -70,11 +52,12 @@ if ([urlString length] > 0) { folders = [self clientObject]; - displayName = [self displayNameForUrl: urlString]; - folder = [folders newWebCalendarWithName: displayName - atURL: urlString]; + folder = [folders newWebCalendarWithURL: urlString + nameInContainer: nil]; + if (folder) { + displayName = [folder displayName]; response = [self responseWithStatus: 200]; [response setHeader: @"application/json" forKey: @"content-type"];