From 1c60ab2337815b73ab651ac39f5465944c10e479 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 24 Sep 2014 12:02:12 -0400 Subject: [PATCH] Fix for bug #2889 --- SOPE/NGCards/iCalTimeZone.m | 6 +- SOPE/NGCards/iCalTimeZonePeriod.m | 4 +- .../Appointments/SOGoAppointmentObject.m | 56 +++++++++++++------ 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/SOPE/NGCards/iCalTimeZone.m b/SOPE/NGCards/iCalTimeZone.m index 354cadc5c..21fbbb22f 100644 --- a/SOPE/NGCards/iCalTimeZone.m +++ b/SOPE/NGCards/iCalTimeZone.m @@ -1,10 +1,6 @@ /* iCalTimeZone.m - this file is part of SOPE * - * Copyright (C) 2006-2011 Inverse inc. - * - * Author: Wolfgang Sourdeau - * Ludovic Marcotte - * Francis Lachapelle + * Copyright (C) 2006-2014 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/SOPE/NGCards/iCalTimeZonePeriod.m b/SOPE/NGCards/iCalTimeZonePeriod.m index a7e21879a..5da8db47a 100644 --- a/SOPE/NGCards/iCalTimeZonePeriod.m +++ b/SOPE/NGCards/iCalTimeZonePeriod.m @@ -1,8 +1,6 @@ /* iCalTimeZonePeriod.m - this file is part of SOPE * - * Copyright (C) 2006-2009 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2006-2014 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/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 05ec676b4..620900854 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -42,6 +42,9 @@ #import #import +#import +#import +#import #import #import @@ -161,7 +164,7 @@ object = nil; } else - object = nil; + object = nil; } } @@ -182,8 +185,8 @@ // // - (void) _addOrUpdateEvent: (iCalEvent *) theEvent - forUID: (NSString *) theUID - owner: (NSString *) theOwner + forUID: (NSString *) theUID + owner: (NSString *) theOwner { if (![theUID isEqualToString: theOwner]) { @@ -433,17 +436,20 @@ while ((currentAttendee = [enumerator nextObject])) { currentUID = [currentAttendee uid]; + if (currentUID) { user = [SOGoUser userWithLogin: currentUID]; us = [user userSettings]; moduleSettings = [us objectForKey:@"Calendar"]; + // Check if the user prevented his account from beeing invited to events if (![user isResource] && [[moduleSettings objectForKey:@"PreventInvitations"] boolValue]) { // Check if the user have a whiteList whiteListString = [moduleSettings objectForKey:@"PreventInvitationsWhitelist"]; whiteList = [whiteListString objectFromJSONString]; + // If the filter have a hit, do not add the currentUID to the unavailableAttendees array if (![whiteList objectForKey:ownerUID]) { @@ -455,9 +461,11 @@ } count = [unavailableAttendees count]; + if (count > 0) { reason = [NSMutableString stringWithString:[self labelForKey: @"Inviting the following persons is prohibited:"]]; + // Add all the unavailable users in the warning message for (i = 0; i < count; i++) { @@ -466,10 +474,14 @@ if (i < count-2) [reason appendString:@", "]; } + [unavailableAttendees release]; + return [NSException exceptionWithHTTPStatus:409 reason: reason]; } + [unavailableAttendees release]; + return nil; } @@ -524,14 +536,14 @@ if ([user isResource]) { + NSCalendarDate *start, *end, *rangeStartDate, *rangeEndDate; SOGoAppointmentFolder *folder; - NSCalendarDate *start, *end; NGCalendarDateRange *range; NSMutableArray *fbInfo; NSArray *allOccurences; BOOL must_delete; - int i, j; + int i, j, delta; // We get the start/end date for our conflict range. If the event to be added is recurring, we // check for at least a year to start with. @@ -574,8 +586,18 @@ for (i = [fbInfo count]-1; i >= 0; i--) { - range = [NGCalendarDateRange calendarDateRangeWithStartDate: [[fbInfo objectAtIndex: i] objectForKey: @"startDate"] - endDate: [[fbInfo objectAtIndex: i] objectForKey: @"endDate"]]; + // We MUST use the -uniqueChildWithTag method here because the event has been flattened, so its timezone has been + // modified in SOGoAppointmentFolder: -fixupCycleRecord: .... + rangeStartDate = [[fbInfo objectAtIndex: i] objectForKey: @"startDate"]; + delta = [[rangeStartDate timeZoneDetail] timeZoneSecondsFromGMT] - [[[(iCalDateTime *)[theEvent uniqueChildWithTag: @"dtstart"] timeZone] periodForDate: [theEvent startDate]] secondsOffsetFromGMT]; + rangeStartDate = [rangeStartDate dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: delta]; + + rangeEndDate = [[fbInfo objectAtIndex: i] objectForKey: @"endDate"]; + delta = [[rangeEndDate timeZoneDetail] timeZoneSecondsFromGMT] - [[[(iCalDateTime *)[theEvent uniqueChildWithTag: @"dtend"] timeZone] periodForDate: [theEvent endDate]] secondsOffsetFromGMT]; + rangeEndDate = [rangeEndDate dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: delta]; + + range = [NGCalendarDateRange calendarDateRangeWithStartDate: rangeStartDate + endDate: rangeEndDate]; if ([[[fbInfo objectAtIndex: i] objectForKey: @"c_uid"] compare: [theEvent uid]] == NSOrderedSame) { @@ -608,9 +630,9 @@ { currentAttendee = [theAttendees objectAtIndex: i]; if ([[currentAttendee uid] isEqualToString: currentUID]) - break; + break; else - currentAttendee = nil; + currentAttendee = nil; } if ([fbInfo count]) @@ -956,10 +978,10 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent - (NSException *) _updateAttendee: (iCalPerson *) attendee withDelegate: (iCalPerson *) delegate ownerUser: (SOGoUser *) theOwnerUser - forEventUID: (NSString *) eventUID - withRecurrenceId: (NSCalendarDate *) recurrenceId - withSequence: (NSNumber *) sequence - forUID: (NSString *) uid + forEventUID: (NSString *) eventUID + withRecurrenceId: (NSCalendarDate *) recurrenceId + withSequence: (NSNumber *) sequence + forUID: (NSString *) uid shouldAddSentBy: (BOOL) b { SOGoAppointmentObject *eventObject; @@ -1022,12 +1044,12 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent } } else - addDelegate = YES; + addDelegate = YES; } else { if (otherDelegate) - removeDelegate = YES; + removeDelegate = YES; } if (removeDelegate) @@ -1094,8 +1116,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent - (NSException *) _handleAttendee: (iCalPerson *) attendee withDelegate: (iCalPerson *) delegate ownerUser: (SOGoUser *) theOwnerUser - statusChange: (NSString *) newStatus - inEvent: (iCalEvent *) event + statusChange: (NSString *) newStatus + inEvent: (iCalEvent *) event { NSString *currentStatus, *organizerUID; SOGoUser *ownerUser, *currentUser;