Remove invalid occurrences when saving master

This commit is contained in:
Francis Lachapelle
2018-05-16 14:58:04 -04:00
parent 452083e767
commit 0c5b5446dd
4 changed files with 46 additions and 13 deletions
+1
View File
@@ -4,6 +4,7 @@
Enhancements
- [web] now possible to show events/task for the current year
- [web] show current ordering setting in lists
- [web] remove invalid occurrences when modifying a recurrent event
- [web] updated Angular Material to version 1.1.9
Bug fixes
@@ -1,5 +1,5 @@
/*
Copyright (C) 2007-2016 Inverse inc.
Copyright (C) 2007-2018 Inverse inc.
This file is part of SOGo
@@ -49,6 +49,8 @@
alarm: (iCalAlarm *) alarm
forRecurrenceId: (NSCalendarDate *) _recurrenceId;
- (void) prepareDeleteOccurence: (iCalEvent *) occurence;
//
// Old CalDAV scheduling (draft 4 and below) methods. We keep them since we still
// advertise for its support but we do everything within the calendar-auto-scheduling code
+14 -7
View File
@@ -317,16 +317,23 @@
}
count++;
}
// Add an date exception.
event = (iCalRepeatableEntityObject*)[calendar firstChildWithTag: [object componentTag]];
[event addToExceptionDates: recurrenceId];
[event increaseSequence];
[event setLastModified: [NSCalendarDate calendarDate]];
if (event)
{
[event addToExceptionDates: recurrenceId];
[event increaseSequence];
[event setLastModified: [NSCalendarDate calendarDate]];
// We save the updated iCalendar in the database.
[object saveCalendar: calendar];
// We save the updated iCalendar in the database.
[object saveCalendar: calendar];
}
else
{
// No more child; kill the parent
[object delete];
}
}
}
else
+28 -5
View File
@@ -1,6 +1,6 @@
/* UIxAppointmentEditor.m - this file is part of SOGo
*
* Copyright (C) 2007-2017 Inverse inc.
* Copyright (C) 2007-2018 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
@@ -45,6 +45,7 @@
#import <Appointments/iCalCalendar+SOGo.h>
#import <Appointments/iCalEntityObject+SOGo.h>
#import <Appointments/iCalPerson+SOGo.h>
#import <Appointments/iCalRepeatableEntityObject+SOGo.h>
#import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentObject.h>
#import <Appointments/SOGoAppointmentOccurence.h>
@@ -189,14 +190,20 @@
- (NSException *) _adjustRecurrentRules
{
iCalEvent *event;
iCalRecurrenceRule *rule;
NSArray *events;
NSCalendarDate *untilDate, *recurrenceId;
NSEnumerator *rules;
NSException *ex;
NSCalendarDate *untilDate;
SOGoUserDefaults *ud;
NSTimeZone *timeZone;
SOGoAppointmentObject *co;
SOGoUserDefaults *ud;
iCalCalendar *calendar;
iCalEvent *event;
iCalRecurrenceRule *rule;
iCalRepeatableEntityObject *masterEvent, *occurrence;
int count, max;
co = [self clientObject];
event = [self event];
rules = [[event recurrenceRules] objectEnumerator];
ex = nil;
@@ -234,6 +241,22 @@
}
}
// Remove invalid occurrences
calendar = [event parent];
events = [calendar events];
masterEvent = [events objectAtIndex: 0];
max = [events count];
for (count = max - 1; count > 0; count--)
{
occurrence = [events objectAtIndex: count];
recurrenceId = [occurrence recurrenceId];
if (recurrenceId && ![masterEvent doesOccurOnDate: recurrenceId])
{
[co prepareDeleteOccurence: (iCalEvent *)occurrence]; // notify attendees, update their calendars
[calendar removeChild: occurrence];
}
}
return ex;
}