Fix for bug 2007

pull/13/head
Ludovic Marcotte 2013-09-30 10:50:27 -04:00
parent 3cce9b2012
commit 05990e9a14
6 changed files with 54 additions and 46 deletions

View File

@ -1,8 +1,6 @@
/* SOGoAppointmentFolders.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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;

View File

@ -1,9 +1,7 @@
/* SOGoAppointmentFolders.m - this file is part of SOGo
*
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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];
}
}
}

View File

@ -1,9 +1,6 @@
/* NSString+Utilities.h - this file is part of SOGo
*
* Copyright (C) 2006-2011 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Ludovic Marcotte <lmarcotte@inverse.ca>
* 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

View File

@ -2,9 +2,6 @@
*
* Copyright (C) 2006-2013 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Ludovic Marcotte <lmarcotte@inverse.ca>
*
* 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)

View File

@ -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)

View File

@ -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"];