From f4fabba6b900b14d53672e4d728b14a584daa88a Mon Sep 17 00:00:00 2001 From: C Robert Date: Wed, 9 Sep 2009 15:30:22 +0000 Subject: [PATCH 1/3] New category for ldifString (NGVCard, NGVList) Monotone-Parent: d124c012f70febcfcbb9a2b5d4f3a20a7a001d7a Monotone-Revision: 2ca761e2d40488480678e105a10bfe240b9c689c Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-09-09T15:30:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++ SOPE/NGCards/ChangeLog | 2 + SOPE/NGCards/NGVCard.h | 1 - SOPE/NGCards/NGVCard.m | 107 -------------------- SOPE/NGCards/NGVList.h | 2 - SOPE/NGCards/NGVList.m | 41 -------- SoObjects/Contacts/GNUmakefile | 2 + SoObjects/Contacts/NGVCard+SOGo.h | 34 +++++++ SoObjects/Contacts/NGVCard+SOGo.m | 137 ++++++++++++++++++++++++++ SoObjects/Contacts/NGVList+SOGo.h | 34 +++++++ SoObjects/Contacts/NGVList+SOGo.m | 73 ++++++++++++++ UI/Contacts/UIxContactFolderActions.m | 4 +- 12 files changed, 290 insertions(+), 153 deletions(-) create mode 100644 SoObjects/Contacts/NGVCard+SOGo.h create mode 100644 SoObjects/Contacts/NGVCard+SOGo.m create mode 100644 SoObjects/Contacts/NGVList+SOGo.h create mode 100644 SoObjects/Contacts/NGVList+SOGo.m diff --git a/ChangeLog b/ChangeLog index d2cd6c3ea..9e2fb3139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,12 @@ userRecordAsLDIFEntry. * UI/Contacts/UIxContactsListView.m: Removed import/export actions * UI/Scheduler/UIxCalView.m: Removed import/export actions + * SoObjects/Contacts/NGVCard+SOGo.m: Added a new category to remove a + circular dependency issue. + * SoObjects/Contacts/NGVList+SOGo.m: Added a new category to remove a + circular dependency issue. + * UI/Contacts/UIxContactFolderActions.m: Changed import instructions to use + the new category. 2009-09-03 Cyril Robert diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index c4f6b93b0..d1163690b 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -2,6 +2,8 @@ * NGVCard.m: Made use of NSDictionary+Utilities' userRecordAsLDIFEntry. * NGVList.m: Made use of NSDictionary+Utilities' userRecordAsLDIFEntry. + * NGVCard.m (ldifString): Moved to a category in SOGo + * NGVList.m (ldifString): Moved to a category in SOGo 2009-09-02 Cyril Robert diff --git a/SOPE/NGCards/NGVCard.h b/SOPE/NGCards/NGVCard.h index 9ede021b0..a687e2a01 100644 --- a/SOPE/NGCards/NGVCard.h +++ b/SOPE/NGCards/NGVCard.h @@ -157,7 +157,6 @@ typedef enum - (NSString *) preferredEMail; - (NSString *) preferredTel; - (CardElement *) preferredAdr; -- (NSString *) ldifString; @end diff --git a/SOPE/NGCards/NGVCard.m b/SOPE/NGCards/NGVCard.m index 5579c7b3f..41cb7c2b9 100644 --- a/SOPE/NGCards/NGVCard.m +++ b/SOPE/NGCards/NGVCard.m @@ -24,8 +24,6 @@ #import #import -#import "../../SoObjects/SOGo/NSDictionary+Utilities.h" - #import "NSArray+NGCards.h" #import "NGVCard.h" @@ -511,109 +509,4 @@ return str; } - -- (NSString *) ldifString -{ - NSMutableString *rc; - NSString *buffer; - NSArray *array; - NSMutableArray *marray; - NSMutableDictionary *entry; - id tmp; - - entry = [NSMutableDictionary dictionary]; - - [entry setObject: [NSString stringWithFormat: @"cn=%@,mail=%@", - [self fn], [self preferredEMail]] - forKey: @"dn"]; - [entry setObject: [NSArray arrayWithObjects: @"top", @"person", - @"organizationalPerson", @"inetOrgPerson", - @"mozillaAbPersonObsolete", nil] - forKey: @"objectclass"]; - [entry setObject: [[self n] objectAtIndex: 1] forKey: @"givenName"]; - [entry setObject: [[self n] objectAtIndex: 0] forKey: @"sn"]; - [entry setObject: [self fn] forKey: @"cn"]; - [entry setObject: [self preferredEMail] forKey: @"mail"]; - [entry setObject: @"0Z" forKey: @"modifytimestamp"]; - - buffer = [self nickname]; - if (buffer && [buffer length] > 0) - [entry setObject: buffer forKey: @"mozillaNickname"]; - - marray = [NSMutableArray arrayWithArray: [self childrenWithTag: @"email"]]; - [marray removeObjectsInArray: [self childrenWithTag: @"email" - andAttribute: @"type" - havingValue: @"pref"]]; - if ([marray count]) - { - buffer = [[marray objectAtIndex: [marray count]-1] value: 0]; - - if ([buffer caseInsensitiveCompare: [self preferredEMail]] != NSOrderedSame) - [entry setObject: buffer forKey: @"mozillaSecondEmail"]; - } - - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"home"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"homePhone"]; - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"fax"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"fax"]; - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"cell"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"mobile"]; - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"pager"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"pager"]; - - array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"home"]; - if ([array count]) - { - tmp = [array objectAtIndex: 0]; - [entry setObject: [tmp value: 0] forKey: @"homeStreet"]; - [entry setObject: [tmp value: 1] forKey: @"mozillaHomeLocalityName"]; - [entry setObject: [tmp value: 2] forKey: @"mozillaHomeState"]; - [entry setObject: [tmp value: 3] forKey: @"mozillaHomePostalCode"]; - [entry setObject: [tmp value: 4] forKey: @"mozillaHomeCountryName"]; - } - - array = [self org]; - if (array && [array count]) - [entry setObject: [array objectAtIndex: 0] forKey: @"o"]; - - array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"]; - if ([array count]) - { - tmp = [array objectAtIndex: 0]; - [entry setObject: [tmp value: 0] forKey: @"street"]; - [entry setObject: [tmp value: 1] forKey: @"l"]; - [entry setObject: [tmp value: 2] forKey: @"st"]; - [entry setObject: [tmp value: 3] forKey: @"postalCode"]; - [entry setObject: [tmp value: 4] forKey: @"c"]; - } - - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"work"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] - forKey: @"telephoneNumber"]; - - array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"work"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] - forKey: @"workurl"]; - - array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"home"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] - forKey: @"homeurl"]; - - tmp = [self note]; - if (tmp && [tmp length]) - [entry setObject: tmp forKey: @"description"]; - - rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; - [rc appendFormat: @"\n"]; - - return rc; -} - @end /* NGVCard */ diff --git a/SOPE/NGCards/NGVList.h b/SOPE/NGCards/NGVList.h index 3d05aa36b..9c11b7d57 100644 --- a/SOPE/NGCards/NGVList.h +++ b/SOPE/NGCards/NGVList.h @@ -64,8 +64,6 @@ - (void) deleteCardReference: (NGVCardReference *) cardRef; - (NSArray *) cardReferences; -- (NSString *) ldifString; - @end #endif /* NGVLIST_H */ diff --git a/SOPE/NGCards/NGVList.m b/SOPE/NGCards/NGVList.m index 926347ca3..3e85fa6ea 100644 --- a/SOPE/NGCards/NGVList.m +++ b/SOPE/NGCards/NGVList.m @@ -25,8 +25,6 @@ #import #import -#import "../../SoObjects/SOGo/NSDictionary+Utilities.h" - #import "NGVCardReference.h" #import "NGVList.h" @@ -200,43 +198,4 @@ return [self childrenWithTag: @"card"]; } -- (NSString *) ldifString -{ - NSMutableString *rc; - NSArray *array; - NSMutableArray *members; - NGVCardReference *tmp; - NSMutableDictionary *entry; - int i, count; - - entry = [NSMutableDictionary dictionary]; - - [entry setObject: [NSString stringWithFormat: @"cn=%@", [self fn]] - forKey: @"dn"]; - [entry setObject: [NSArray arrayWithObjects: @"top", @"groupOfNames", nil] - forKey: @"objectclass"]; - [entry setObject: [self fn] forKey: @"cn"]; - if ([self nickname]) - [entry setObject: [self nickname] forKey: @"mozillaNickname"]; - if ([self description]) - [entry setObject: [self description] forKey: @"description"]; - - array = [self cardReferences]; - count = [array count]; - members = [NSMutableArray array]; - for (i = 0; i < count; i++) - { - tmp = [array objectAtIndex: i]; - [members addObject: [NSString stringWithFormat: - @"cn=%@,mail=%@", [tmp fn], [tmp email]]]; - } - [entry setObject: members forKey: @"member"]; - - rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; - [rc appendFormat: @"\n"]; - - return rc; -} - - @end diff --git a/SoObjects/Contacts/GNUmakefile b/SoObjects/Contacts/GNUmakefile index 1a9872fe3..4d48263be 100644 --- a/SoObjects/Contacts/GNUmakefile +++ b/SoObjects/Contacts/GNUmakefile @@ -9,6 +9,8 @@ Contacts_PRINCIPAL_CLASS = SOGoContactsProduct Contacts_OBJC_FILES = \ Product.m \ + NGVCard+SOGo.m \ + NGVList+SOGo.m \ SOGoFolder+CardDAV.m \ SOGoContactFolders.m \ SOGoContactGCSEntry.m \ diff --git a/SoObjects/Contacts/NGVCard+SOGo.h b/SoObjects/Contacts/NGVCard+SOGo.h new file mode 100644 index 000000000..a758d86c8 --- /dev/null +++ b/SoObjects/Contacts/NGVCard+SOGo.h @@ -0,0 +1,34 @@ +/* NGVCard+SOGo.h - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * 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) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NGVCARD_SOGO_H +#define NGVCARD_SOGO_H + +#import + +@interface NGVCard (SOGoExtensions) + +- (NSString *) ldifString; + +@end + +#endif /* NGVCARD_SOGO_H */ diff --git a/SoObjects/Contacts/NGVCard+SOGo.m b/SoObjects/Contacts/NGVCard+SOGo.m new file mode 100644 index 000000000..750e63518 --- /dev/null +++ b/SoObjects/Contacts/NGVCard+SOGo.m @@ -0,0 +1,137 @@ +/* NGVCard+SOGo.m - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * 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) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import + +#import +#import "NGVCard+SOGo.h" + +@implementation NGVCard (SOGoExtensions) + +- (NSString *) ldifString +{ + NSMutableString *rc; + NSString *buffer; + NSArray *array; + NSMutableArray *marray; + NSMutableDictionary *entry; + id tmp; + + entry = [NSMutableDictionary dictionary]; + + [entry setObject: [NSString stringWithFormat: @"cn=%@,mail=%@", + [self fn], [self preferredEMail]] + forKey: @"dn"]; + [entry setObject: [NSArray arrayWithObjects: @"top", @"person", + @"organizationalPerson", @"inetOrgPerson", + @"mozillaAbPersonObsolete", nil] + forKey: @"objectclass"]; + [entry setObject: [[self n] objectAtIndex: 1] forKey: @"givenName"]; + [entry setObject: [[self n] objectAtIndex: 0] forKey: @"sn"]; + [entry setObject: [self fn] forKey: @"cn"]; + [entry setObject: [self preferredEMail] forKey: @"mail"]; + [entry setObject: @"0Z" forKey: @"modifytimestamp"]; + + buffer = [self nickname]; + if (buffer && [buffer length] > 0) + [entry setObject: buffer forKey: @"mozillaNickname"]; + + marray = [NSMutableArray arrayWithArray: [self childrenWithTag: @"email"]]; + [marray removeObjectsInArray: [self childrenWithTag: @"email" + andAttribute: @"type" + havingValue: @"pref"]]; + if ([marray count]) + { + buffer = [[marray objectAtIndex: [marray count]-1] value: 0]; + + if ([buffer caseInsensitiveCompare: [self preferredEMail]] != NSOrderedSame) + [entry setObject: buffer forKey: @"mozillaSecondEmail"]; + } + + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"home"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"homePhone"]; + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"fax"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"fax"]; + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"cell"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"mobile"]; + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"pager"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"pager"]; + + array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"home"]; + if ([array count]) + { + tmp = [array objectAtIndex: 0]; + [entry setObject: [tmp value: 0] forKey: @"homeStreet"]; + [entry setObject: [tmp value: 1] forKey: @"mozillaHomeLocalityName"]; + [entry setObject: [tmp value: 2] forKey: @"mozillaHomeState"]; + [entry setObject: [tmp value: 3] forKey: @"mozillaHomePostalCode"]; + [entry setObject: [tmp value: 4] forKey: @"mozillaHomeCountryName"]; + } + + array = [self org]; + if (array && [array count]) + [entry setObject: [array objectAtIndex: 0] forKey: @"o"]; + + array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"]; + if ([array count]) + { + tmp = [array objectAtIndex: 0]; + [entry setObject: [tmp value: 0] forKey: @"street"]; + [entry setObject: [tmp value: 1] forKey: @"l"]; + [entry setObject: [tmp value: 2] forKey: @"st"]; + [entry setObject: [tmp value: 3] forKey: @"postalCode"]; + [entry setObject: [tmp value: 4] forKey: @"c"]; + } + + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"work"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] + forKey: @"telephoneNumber"]; + + array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"work"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] + forKey: @"workurl"]; + + array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"home"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] + forKey: @"homeurl"]; + + tmp = [self note]; + if (tmp && [tmp length]) + [entry setObject: tmp forKey: @"description"]; + + rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; + [rc appendFormat: @"\n"]; + + return rc; +} + +@end /* NGVCard */ diff --git a/SoObjects/Contacts/NGVList+SOGo.h b/SoObjects/Contacts/NGVList+SOGo.h new file mode 100644 index 000000000..04601ae1c --- /dev/null +++ b/SoObjects/Contacts/NGVList+SOGo.h @@ -0,0 +1,34 @@ +/* NGVCard+SOGo.h - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * 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) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NGVLIST_SOGO_H +#define NGVLIST_SOGO_H + +#import + +@interface NGVList (SOGoExtensions) + +- (NSString *) ldifString; + +@end + +#endif /* NGVLIST_SOGO_H */ diff --git a/SoObjects/Contacts/NGVList+SOGo.m b/SoObjects/Contacts/NGVList+SOGo.m new file mode 100644 index 000000000..bce521a31 --- /dev/null +++ b/SoObjects/Contacts/NGVList+SOGo.m @@ -0,0 +1,73 @@ +/* NGVCard+SOGo.m - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * 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) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import + +#import +#import "NGVList+SOGo.h" + +#import + +@implementation NGVList (SOGoExtensions) + +- (NSString *) ldifString +{ + NSMutableString *rc; + NSArray *array; + NSMutableArray *members; + NGVCardReference *tmp; + NSMutableDictionary *entry; + int i, count; + + entry = [NSMutableDictionary dictionary]; + + [entry setObject: [NSString stringWithFormat: @"cn=%@", [self fn]] + forKey: @"dn"]; + [entry setObject: [NSArray arrayWithObjects: @"top", @"groupOfNames", nil] + forKey: @"objectclass"]; + [entry setObject: [self fn] forKey: @"cn"]; + if ([self nickname]) + [entry setObject: [self nickname] forKey: @"mozillaNickname"]; + if ([self description]) + [entry setObject: [self description] forKey: @"description"]; + + array = [self cardReferences]; + count = [array count]; + members = [NSMutableArray array]; + for (i = 0; i < count; i++) + { + tmp = [array objectAtIndex: i]; + [members addObject: [NSString stringWithFormat: + @"cn=%@,mail=%@", [tmp fn], [tmp email]]]; + } + [entry setObject: members forKey: @"member"]; + + rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; + [rc appendFormat: @"\n"]; + + return rc; +} + +@end /* NGVList */ diff --git a/UI/Contacts/UIxContactFolderActions.m b/UI/Contacts/UIxContactFolderActions.m index b55c1f5f0..4dfc2a99d 100644 --- a/UI/Contacts/UIxContactFolderActions.m +++ b/UI/Contacts/UIxContactFolderActions.m @@ -35,8 +35,8 @@ #import #import -#import -#import +#import +#import #import #import #import From 6a4dd19e85f92a462dbbd11c39ad95f4db50d983 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 9 Sep 2009 17:35:03 +0000 Subject: [PATCH 2/3] Monotone-Parent: 3e7ac334a4ea19aa4ec2dcbc525628005ca75fb7 Monotone-Revision: edd72b1e960245b7bca420619b28446ba3ce513b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-09-09T17:35:03 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 11 +++ .../Appointments/SOGoAppointmentFolder.m | 99 ++++++++++--------- SoObjects/SOGo/SOGoUser.m | 2 +- 3 files changed, 65 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5003f0ed..aa3f29b1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-09-09 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentFolder.m + (-_getMaxStartDate): do not compute the start date if the active + user is a super user. + (_enforceTimeLimitOnFilter:withStartDate:andEndDate:): same as + above. + + * SoObjects/SOGo/SOGoUser.m (-rolesForObject:inContext:): directly + invoke [self isSuperUser] + 2009-09-03 Cyril Robert * UI/Contacts/UIxContactsListView.m: Added ldif / vcard import diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index a449f8cce..9095a2abc 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -81,7 +81,8 @@ static NGLogger *logger = nil; static NSNumber *sharedYes = nil; -static int davCalendarStartTimeLimit = 0; +static int davCalendarStartTimeLimit, davTimeLimitSeconds, + davTimeHalfLimitSeconds; + (void) initialize { @@ -107,6 +108,10 @@ static int davCalendarStartTimeLimit = 0; ud = [NSUserDefaults standardUserDefaults]; davCalendarStartTimeLimit = [ud integerForKey: @"SOGoDAVCalendarStartTimeLimit"]; + davTimeLimitSeconds = davCalendarStartTimeLimit * 86400; + /* 86400 / 2 = 43200. We hardcode that value in order to avoid + integer and float confusion. */ + davTimeHalfLimitSeconds = davCalendarStartTimeLimit * 43200; } } @@ -1350,12 +1355,12 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir - (NSCalendarDate *) _getMaxStartDate { - NSCalendarDate *tmp, *rc; + NSCalendarDate *now, *rc; - if (davCalendarStartTimeLimit > 0) + if (davCalendarStartTimeLimit > 0 && ![[context activeUser] isSuperUser]) { - tmp = [NSCalendarDate date]; - rc = [tmp addTimeInterval: davCalendarStartTimeLimit * -86400]; + now = [NSCalendarDate date]; + rc = [now addTimeInterval: -davTimeLimitSeconds]; } else rc = nil; @@ -1364,42 +1369,44 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir } - (void) _enforceTimeLimitOnFilter: (NSMutableDictionary *) filter + withStartDate: (NSCalendarDate *) startDate + andEndDate: (NSCalendarDate *) endDate { - NSCalendarDate *start, *end, *now; + NSCalendarDate *now; int interval, intervalStart, intervalEnd; - start = [filter objectForKey: @"start"]; - end = [filter objectForKey: @"end"]; - now = [NSCalendarDate date]; - interval = ([end timeIntervalSinceDate: start] / 86400); - - if (davCalendarStartTimeLimit > 0 && interval > davCalendarStartTimeLimit) + if (davCalendarStartTimeLimit > 0 && ![[context activeUser] isSuperUser]) { - if ([now compare: start] == NSOrderedDescending - && [now compare: end] == NSOrderedAscending) + interval = ([endDate timeIntervalSinceDate: startDate] / 86400); + if (interval > davCalendarStartTimeLimit) { - intervalStart = [now timeIntervalSinceDate: start] / 86400; - intervalEnd = [end timeIntervalSinceDate: now] / 86400; - if (intervalStart > davCalendarStartTimeLimit / 2) + now = [NSCalendarDate date]; + if ([now compare: startDate] == NSOrderedDescending + && [now compare: endDate] == NSOrderedAscending) { - start = [now addTimeInterval: (davCalendarStartTimeLimit / 2) * -86400]; - [filter setObject: start forKey: @"start"]; + intervalStart = [now timeIntervalSinceDate: startDate] / 86400; + intervalEnd = [endDate timeIntervalSinceDate: now] / 86400; + if (intervalStart > davCalendarStartTimeLimit / 2) + { + startDate = [now addTimeInterval: -davTimeHalfLimitSeconds]; + [filter setObject: startDate forKey: @"start"]; + } + if (intervalEnd > davCalendarStartTimeLimit / 2) + { + endDate = [now addTimeInterval: davTimeHalfLimitSeconds]; + [filter setObject: endDate forKey: @"end"]; + } } - if (intervalEnd > davCalendarStartTimeLimit / 2) + else if ([now compare: endDate] == NSOrderedDescending) { - end = [now addTimeInterval: (davCalendarStartTimeLimit / 2) * 86400]; - [filter setObject: end forKey: @"end"]; + startDate = [endDate addTimeInterval: -davTimeLimitSeconds]; + [filter setObject: startDate forKey: @"start"]; + } + else if ([now compare: startDate] == NSOrderedAscending) + { + endDate = [startDate addTimeInterval: davTimeLimitSeconds]; + [filter setObject: endDate forKey: @"end"]; } - } - else if ([now compare: end] == NSOrderedDescending) - { - start = [end addTimeInterval: davCalendarStartTimeLimit * -86400]; - [filter setObject: start forKey: @"start"]; - } - else if ([now compare: start] == NSOrderedAscending) - { - end = [start addTimeInterval: davCalendarStartTimeLimit * 86400]; - [filter setObject: end forKey: @"end"]; } } } @@ -1407,30 +1414,30 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir - (void) _appendTimeRange: (id ) timeRangeElement toFilter: (NSMutableDictionary *) filter { - NSCalendarDate *parsedDate; + NSCalendarDate *startDate, *endDate; - parsedDate = [[timeRangeElement attribute: @"start"] asCalendarDate]; - if (!parsedDate) - parsedDate = [NSCalendarDate distantPast]; - [filter setObject: parsedDate forKey: @"start"]; - parsedDate = [[timeRangeElement attribute: @"end"] asCalendarDate]; - if (!parsedDate) - parsedDate = [NSCalendarDate distantFuture]; - [filter setObject: parsedDate forKey: @"end"]; + startDate = [[timeRangeElement attribute: @"start"] asCalendarDate]; + if (!startDate) + startDate = [NSCalendarDate distantPast]; + [filter setObject: startDate forKey: @"start"]; - [self _enforceTimeLimitOnFilter: filter]; + endDate = [[timeRangeElement attribute: @"end"] asCalendarDate]; + if (!endDate) + endDate = [NSCalendarDate distantFuture]; + [filter setObject: endDate forKey: @"end"]; + + [self _enforceTimeLimitOnFilter: filter + withStartDate: startDate andEndDate: endDate]; } - (void) _addDateRangeLimitToFilter: (NSMutableDictionary *) filter { NSCalendarDate *now; - NSTimeInterval rangeLimit; now = [NSCalendarDate date]; - rangeLimit = (davCalendarStartTimeLimit / 2) * -86400; - [filter setObject: [now addTimeInterval: rangeLimit] + [filter setObject: [now addTimeInterval: davTimeHalfLimitSeconds] forKey: @"start"]; - [filter setObject: [now addTimeInterval: rangeLimit * -1] + [filter setObject: [now addTimeInterval: -davTimeHalfLimitSeconds] forKey: @"end"]; } diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 8371bf42f..7d3691ae9 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -974,7 +974,7 @@ _timeValue (NSString *key) if (sogoRoles) [rolesForObject addObjectsFromArray: sogoRoles]; - if ((superUsernames && [superUsernames containsObject: login]) + if ([self isSuperUser] || [[object ownerInContext: context] isEqualToString: login]) [rolesForObject addObject: SoRole_Owner]; else if ([object isKindOfClass: [SOGoObject class]]) From 62e41486c0bfacc7183a426821f2faf4b83f9dda Mon Sep 17 00:00:00 2001 From: C Robert Date: Thu, 10 Sep 2009 13:03:14 +0000 Subject: [PATCH 3/3] Added a dependency on sope4.9-libxmlsaxdriver Monotone-Parent: 2ca761e2d40488480678e105a10bfe240b9c689c Monotone-Revision: 40d996b280dc1152661e729288981bcbd446b344 Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-09-10T13:03:14 Monotone-Branch: ca.inverse.sogo --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 07a1934a1..36033a0bf 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Standards-Version: 3.8.2 Package: sogo Section: web Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tmpreaper +Depends: ${shlibs:Depends}, ${misc:Depends}, tmpreaper, sope4.9-libxmlsaxdriver Suggests: nginx Description: a modern and scalable groupware SOGo is a groupware server built around OpenGroupware.org (OGo) and