mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-19 21:53:19 +00:00
See Changelog.
Monotone-Parent: f13b039579047763006c2956ddf349f1bff203a3 Monotone-Revision: f6c7d4502b60b66206223a822d4911218f4bbacf Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-08-26T14:14:10 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -24,9 +24,12 @@
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGObjWeb/SoPermissions.h>
|
||||
#import <NGObjWeb/SoSecurityManager.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/iCalEvent.h>
|
||||
|
||||
#import <SOGo/NSCalendarDate+SOGo.h>
|
||||
@@ -108,4 +111,83 @@
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) copyAction
|
||||
{
|
||||
NSString *destination;
|
||||
NSArray *events;
|
||||
iCalCalendar *calendar;
|
||||
iCalRepeatableEntityObject *masterOccurence;
|
||||
SOGoAppointmentObject *thisEvent;
|
||||
SOGoAppointmentFolder *sourceCalendar, *destinationCalendar;
|
||||
SoSecurityManager *sm;
|
||||
WOResponse *response;
|
||||
WORequest *rq;
|
||||
|
||||
rq = [context request];
|
||||
|
||||
destination = [rq formValueForKey: @"destination"];
|
||||
if (![destination length])
|
||||
destination = @"personal";
|
||||
|
||||
thisEvent = [self clientObject];
|
||||
sourceCalendar = [thisEvent container];
|
||||
destinationCalendar = [[sourceCalendar container] lookupName: destination
|
||||
inContext: context
|
||||
acquire: NO];
|
||||
if (destinationCalendar)
|
||||
{
|
||||
// Verify access rights to destination calendar
|
||||
sm = [SoSecurityManager sharedSecurityManager];
|
||||
if ([sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
||||
onObject: destinationCalendar
|
||||
inContext: context])
|
||||
{
|
||||
response = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"Can't add event to destination calendar."];
|
||||
}
|
||||
// Verify that the destination calendar is not the source calendar
|
||||
else if ([[destinationCalendar nameInContainer] isEqualToString: [sourceCalendar nameInContainer]])
|
||||
{
|
||||
response = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Destination calendar is the source calendar."];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove attendees, recurrence exceptions and single occurences from the event
|
||||
calendar = [thisEvent calendar: NO secure: NO];
|
||||
events = [calendar events];
|
||||
masterOccurence = [events objectAtIndex: 0];
|
||||
|
||||
if ([masterOccurence hasAlarms])
|
||||
[masterOccurence removeAllAlarms];
|
||||
if ([masterOccurence hasRecurrenceRules])
|
||||
{
|
||||
[masterOccurence removeAllExceptionRules];
|
||||
[masterOccurence removeAllExceptionDates];
|
||||
}
|
||||
if ([[masterOccurence attendees] count] > 0)
|
||||
{
|
||||
[masterOccurence setOrganizer: nil];
|
||||
[masterOccurence removeAllAttendees];
|
||||
}
|
||||
[calendar setUniqueChild: masterOccurence];
|
||||
|
||||
// Perform the copy
|
||||
if ([thisEvent copyComponent: calendar
|
||||
toFolder: (SOGoGCSFolder *) destinationCalendar])
|
||||
response = [NSException exceptionWithHTTPStatus: 500
|
||||
reason: @"Can't copy event to destination calendar."];
|
||||
else
|
||||
response = [self responseWith204];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response = [NSException exceptionWithHTTPStatus: 404
|
||||
reason: @"Can't find destination calendar."];
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user