diff --git a/ChangeLog b/ChangeLog index 339ca7253..da16d0ee2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-04-28 Ludovic Marcotte + + * SoObjects/SOGo/SQLSource.{h,m}: Added resources support, + just like for LDAP-based sources. + * SoObjects/SOGo/SOGoParentFolder.m (_createPersonalFolder): + We now also autocreate database tables if the "user" + is a resource. + 2011-04-25 Francis Lachapelle * UI/WebServerResources/SchedulerUI.js (onFolderUnsubscribeCB): diff --git a/Documentation/SOGo Installation Guide.odt b/Documentation/SOGo Installation Guide.odt index 58ca3f49a..dde99f1a3 100644 Binary files a/Documentation/SOGo Installation Guide.odt and b/Documentation/SOGo Installation Guide.odt differ diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index ea89273ae..9079816b8 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -1,6 +1,6 @@ /* SOGoFolder.m - this file is part of SOGo * - * Copyright (C) 2007-2009 Inverse inc. + * Copyright (C) 2007-2011 Inverse inc. * * Author: Wolfgang Sourdeau * diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 102816827..64cf44218 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -159,7 +159,12 @@ static SoSecurityManager *sm = nil; SOGoGCSFolder *folder; roles = [[context activeUser] rolesForObject: self inContext: context]; - if ([roles containsObject: SoRole_Owner]) + + // We autocreate the calendars if the user is the owner, a superuser or + // if it's a resource as we won't necessarily want to login as a resource + // in order to create its database tables. + if ([roles containsObject: SoRole_Owner] || + [[context activeUser] isResource]) { folder = [subFolderClass objectWithName: @"personal" inContainer: self]; [folder setDisplayName: [self defaultFolderName]]; diff --git a/SoObjects/SOGo/SQLSource.h b/SoObjects/SOGo/SQLSource.h index 418399529..c7ce6a35e 100644 --- a/SoObjects/SOGo/SQLSource.h +++ b/SoObjects/SOGo/SQLSource.h @@ -42,6 +42,10 @@ NSString *_imapLoginField; NSString *_userPasswordAlgorithm; NSURL *_viewURL; + + /* resources handling */ + NSString *_kindField; + NSString *_multipleBookingsField; } @end diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 1f21a948c..62083fe0b 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -83,6 +83,8 @@ _mailFields = nil; _userPasswordAlgorithm = nil; _viewURL = nil; + _kindField = nil; + _multipleBookingsField = nil; } return self; @@ -95,6 +97,8 @@ [_mailFields release]; [_userPasswordAlgorithm release]; [_viewURL release]; + [_kindField release]; + [_multipleBookingsField release]; [super dealloc]; } @@ -109,7 +113,9 @@ ASSIGN(_mailFields, [udSource objectForKey: @"MailFieldNames"]); ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]); ASSIGN(_imapLoginField, [udSource objectForKey: @"IMAPLoginFieldName"]); - + ASSIGN(_kindField, [udSource objectForKey: @"KindFieldName"]); + ASSIGN(_multipleBookingsField, [udSource objectForKey: @"MultipleBookingsFieldName"]); + if (!_userPasswordAlgorithm) _userPasswordAlgorithm = @"none"; @@ -462,6 +468,29 @@ [response setObject: [response objectForKey: _imapLoginField] forKey: @"c_imaplogin"]; } + // We check if it's a resource of not + if (_kindField) + { + if ((value = [response objectForKey: _kindField])) + { + if ([value caseInsensitiveCompare: @"location"] == NSOrderedSame || + [value caseInsensitiveCompare: @"thing"] == NSOrderedSame || + [value caseInsensitiveCompare: @"group"] == NSOrderedSame) + { + [response setObject: [NSNumber numberWithInt: 1] + forKey: @"isResource"]; + } + } + } + + if (_multipleBookingsField) + { + if ((value = [response objectForKey: _multipleBookingsField])) + { + [response setObject: [NSNumber numberWithInt: [value intValue]] + forKey: @"numberOfSimultaneousBookings"]; + } + } } else [self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];