Skip to content

Commit

Permalink
(fix) calendar component move across collections (fixes #4116)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Mar 31, 2017
1 parent 9995ccc commit 43dc7de
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-------------------

Bug fixes
- [core] fixed calendar component move across collections (#4116)
- [eas] fixed opacity in EAS freebusy (#4033)

2.3.20 (2017-03-10)
Expand Down
74 changes: 37 additions & 37 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -1197,25 +1197,28 @@ - (NSArray *) getUIDsForICalPersons: (NSArray *) iCalPersons
return uids;
}

- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
- (NSException *) _copyComponent: (iCalCalendar *) calendar
toFolder: (SOGoGCSFolder *) newFolder
updateUID: (BOOL) updateUID
{
return [self copyComponent: [self calendar: NO secure: NO]
toFolder: newFolder];
}

- (NSException *) copyComponent: (iCalCalendar *) calendar
toFolder: (SOGoGCSFolder *) newFolder
{
NSArray *elements;
NSString *newUID;
unsigned int count, max;
SOGoCalendarComponent *newComponent;

newUID = [self globallyUniqueObjectId];
elements = [calendar allObjects];
max = [elements count];
for (count = 0; count < max; count++)
[[elements objectAtIndex: count] setUid: newUID];
if (updateUID)
{
NSArray *elements;
unsigned int count, max;

newUID = [self globallyUniqueObjectId];
elements = [calendar allObjects];
max = [elements count];
for (count = 0; count < max; count++)
[[elements objectAtIndex: count] setUid: newUID];
}
else
{
newUID = [[[calendar allObjects] objectAtIndex: 0] uid];
}

newComponent = [[self class] objectWithName:
[NSString stringWithFormat: @"%@.ics", newUID]
Expand All @@ -1224,33 +1227,30 @@ - (NSException *) copyComponent: (iCalCalendar *) calendar
return [newComponent saveCalendar: calendar];
}

- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
{
SOGoCalendarComponent *newComponent;
NSException *ex;
id o;
return [self copyComponent: [self calendar: NO secure: NO]
toFolder: newFolder];
}

// Lookup to see if the event exists in the target calendar. During a MOVE, we do
// keep the ID of the event intact.
o = [newFolder lookupName: [self nameInContainer]
inContext: context
acquire: NO];
- (NSException *) copyComponent: (iCalCalendar *) calendar
toFolder: (SOGoGCSFolder *) newFolder
{
return [self _copyComponent: calendar
toFolder: newFolder
updateUID: YES];
}

if ([o isKindOfClass: [NSException class]])
{
newComponent = [[self class] objectWithName: [self nameInContainer]
inContainer: newFolder];
- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder
{
NSException *ex;

ex = [newComponent saveCalendar: [self calendar: NO secure: NO]];
ex = [self _copyComponent: [self calendar: NO secure: NO]
toFolder: newFolder
updateUID: NO];

if (!ex)
ex = [self delete];
}
else
{
ex = [NSException exceptionWithHTTPStatus: 409
reason: @"Target exists - MOVE disallowed."];
}
if (!ex)
ex = [self delete];

return ex;
}
Expand Down

0 comments on commit 43dc7de

Please sign in to comment.