diff --git a/ChangeLog b/ChangeLog index e9f5861ee..69feb0448 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-06-09 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentFolderObject.m + (-_folderCalendars): we now fetch the records only covering the + value of SOGoDAVCalendarStartTimeLimit in days with the current + date as the middle of the time range. + 2010-06-08 Wolfgang Sourdeau * UI/WebServerResources/UIxAttendeesEditor.js diff --git a/SoObjects/Appointments/SOGoAppointmentFolderObject.h b/SoObjects/Appointments/SOGoAppointmentFolderObject.h index c8c1e9175..c6b9c8d4d 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolderObject.h +++ b/SoObjects/Appointments/SOGoAppointmentFolderObject.h @@ -30,6 +30,7 @@ @interface SOGoAppointmentFolderObject : SOGoObject { SOGoAppointmentFolder *folder; + int davTimeHalfLimitSeconds; } - (iCalCalendar *) contentCalendar; diff --git a/SoObjects/Appointments/SOGoAppointmentFolderObject.m b/SoObjects/Appointments/SOGoAppointmentFolderObject.m index 95077945f..f0a339c52 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolderObject.m +++ b/SoObjects/Appointments/SOGoAppointmentFolderObject.m @@ -21,27 +21,51 @@ */ #import +#import #import #import -#import +#import #import +#import #import #import +#import +#import + #import "SOGoAppointmentFolder.h" #import "SOGoCalendarComponent.h" #import "SOGoAppointmentFolderObject.h" +static NSArray *contentFields = nil; + @implementation SOGoAppointmentFolderObject ++ (void) initialize +{ + if (!contentFields) + contentFields = [[NSArray alloc] initWithObjects: @"c_name", @"c_version", + @"c_lastmodified", @"c_creationdate", + @"c_component", nil]; +} + - (id) init { + int davCalendarStartTimeLimit; + SOGoUser *user; + if ((self = [super init])) { folder = nil; + + user = [context activeUser]; + davCalendarStartTimeLimit + = [[user domainDefaults] davCalendarStartTimeLimit]; + /* 43200 = 60 * 60 * 24 / 2 */ + davTimeHalfLimitSeconds = davCalendarStartTimeLimit * 43200; } return self; @@ -118,23 +142,63 @@ } } +- (NSArray *) _fetchFolderRecords +{ + NSCalendarDate *start, *end; + + if (davTimeHalfLimitSeconds) + { + start = [[NSCalendarDate date] addYear: 0 + month: 0 + day: 0 + hour: 0 + minute: 0 + second: -davTimeHalfLimitSeconds]; + end = [start addYear: 0 + month: 0 + day: 0 + hour: 0 + minute: 0 + second: (2 * davTimeHalfLimitSeconds)]; + } + else + { + start = nil; + end = nil; + } + + return [[self _folder] bareFetchFields: contentFields + from: start + to: end + title: nil + component: nil + additionalFilters: nil]; +} + - (NSArray *) _folderCalendars { - NSArray *names; - int count, max; - SOGoCalendarComponent *component; + NSArray *records; NSMutableArray *calendars; + SOGoCalendarComponent *component; + int count, max; + iCalCalendar *calendar; + NSString *name; - names = [[self _folder] toOneRelationshipKeys]; - max = [names count]; + records = [self _fetchFolderRecords]; + max = [records count]; calendars = [NSMutableArray arrayWithCapacity: max]; - for (count = 0; count < max; count++) { - component = [folder lookupName: [names objectAtIndex: count] + name = [[records objectAtIndex: count] objectForKey: @"c_name"]; + component = [folder lookupName: name inContext: context acquire: NO]; - [calendars addObject: [component calendar: NO secure: YES]]; + calendar = [component calendar: NO secure: !activeUserIsOwner]; + if (calendar) + [calendars addObject: calendar]; + else + [self errorWithFormat: @"record with c_name '%@' should obviously not" + @" be listed here", name]; } return calendars;