2007-03-18 16:20:38 +01:00
|
|
|
/* UIxAppointmentEditor.m - this file is part of SOGo
|
|
|
|
*
|
2016-02-11 16:54:07 +01:00
|
|
|
* Copyright (C) 2007-2016 Inverse inc.
|
2007-03-18 16:20:38 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-06-07 20:12:20 +02:00
|
|
|
#include <math.h>
|
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2008-12-23 19:39:36 +01:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
2008-12-30 15:47:58 +01:00
|
|
|
#import <Foundation/NSTimeZone.h>
|
2014-09-12 14:34:15 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2008-08-19 00:45:59 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <NGObjWeb/SoObject.h>
|
2008-08-10 23:44:25 +02:00
|
|
|
#import <NGObjWeb/SoPermissions.h>
|
|
|
|
#import <NGObjWeb/SoSecurityManager.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
2007-12-17 16:29:06 +01:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
2014-09-12 14:34:15 +02:00
|
|
|
#import <NGExtensions/NGCalendarDateRange.h>
|
2015-02-12 21:01:26 +01:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2014-02-05 22:02:38 +01:00
|
|
|
#import <NGExtensions/NSString+misc.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2009-04-22 23:02:11 +02:00
|
|
|
#import <NGCards/iCalAlarm.h>
|
2007-11-09 00:18:52 +01:00
|
|
|
#import <NGCards/iCalCalendar.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <NGCards/iCalEvent.h>
|
|
|
|
#import <NGCards/iCalPerson.h>
|
2009-04-22 23:02:11 +02:00
|
|
|
#import <NGCards/iCalTrigger.h>
|
2007-10-09 19:19:20 +02:00
|
|
|
#import <NGCards/iCalRecurrenceRule.h>
|
2009-10-26 14:39:28 +01:00
|
|
|
#import <NGCards/iCalTimeZone.h>
|
|
|
|
#import <NGCards/iCalDateTime.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2015-02-17 22:09:16 +01:00
|
|
|
#import <SOGo/NSCalendarDate+SOGo.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
2011-06-15 16:04:51 +02:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoContentObject.h>
|
|
|
|
#import <SOGo/SOGoDateFormatter.h>
|
|
|
|
#import <SOGo/SOGoPermissions.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2014-12-16 15:20:27 +01:00
|
|
|
#import <Appointments/iCalAlarm+SOGo.h>
|
2014-09-12 14:34:15 +02:00
|
|
|
#import <Appointments/iCalCalendar+SOGo.h>
|
2013-06-19 16:23:47 +02:00
|
|
|
#import <Appointments/iCalEntityObject+SOGo.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <Appointments/iCalPerson+SOGo.h>
|
|
|
|
#import <Appointments/SOGoAppointmentFolder.h>
|
|
|
|
#import <Appointments/SOGoAppointmentObject.h>
|
|
|
|
#import <Appointments/SOGoAppointmentOccurence.h>
|
|
|
|
|
|
|
|
#import <Appointments/SOGoComponentOccurence.h>
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
#import "UIxComponentEditor.h"
|
|
|
|
#import "UIxAppointmentEditor.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
@implementation UIxAppointmentEditor
|
2006-09-28 19:26:02 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (id) init
|
|
|
|
{
|
2009-07-29 20:46:44 +02:00
|
|
|
SOGoUser *user;
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2009-07-29 20:46:44 +02:00
|
|
|
user = [[self context] activeUser];
|
|
|
|
ASSIGN (dateFormatter, [user dateFormatterInContext: context]);
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
return self;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-09 19:19:20 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2009-07-29 20:46:44 +02:00
|
|
|
[dateFormatter release];
|
2007-10-09 19:19:20 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (iCalEvent *) event
|
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
return (iCalEvent *) component;
|
2008-08-22 08:44:27 +02:00
|
|
|
}
|
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
/*
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSCalendarDate *) newStartDate
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
NSCalendarDate *newStartDate, *now;
|
2007-04-11 21:08:58 +02:00
|
|
|
NSTimeZone *timeZone;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
2011-06-13 22:28:10 +02:00
|
|
|
int hour, minute;
|
2008-07-18 21:25:26 +02:00
|
|
|
unsigned int uStart, uEnd;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
newStartDate = [self selectedDate];
|
2008-07-11 19:26:11 +02:00
|
|
|
if (![[self queryParameterForKey: @"hm"] length])
|
2007-03-18 16:20:38 +01:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
ud = [[context activeUser] userDefaults];
|
|
|
|
timeZone = [ud timeZone];
|
2007-03-18 16:20:38 +01:00
|
|
|
now = [NSCalendarDate calendarDate];
|
2007-04-11 21:08:58 +02:00
|
|
|
[now setTimeZone: timeZone];
|
2008-07-18 21:25:26 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
uStart = [ud dayStartHour];
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([now isDateOnSameDay: newStartDate])
|
|
|
|
{
|
2013-01-21 19:33:40 +01:00
|
|
|
uEnd = [ud dayEndHour];
|
2007-03-18 16:20:38 +01:00
|
|
|
hour = [now hourOfDay];
|
2011-06-13 22:28:10 +02:00
|
|
|
minute = [now minuteOfHour];
|
|
|
|
if (minute % 15)
|
|
|
|
minute += 15 - (minute % 15);
|
2008-07-18 21:25:26 +02:00
|
|
|
if (hour < uStart)
|
|
|
|
newStartDate = [now hour: uStart minute: 0];
|
|
|
|
else if (hour > uEnd)
|
|
|
|
newStartDate = [[now tomorrow] hour: uStart minute: 0];
|
2007-03-18 16:20:38 +01:00
|
|
|
else
|
2011-06-13 22:28:10 +02:00
|
|
|
newStartDate = [now hour: [now hourOfDay] minute: minute];
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
|
|
|
else
|
2008-07-18 21:25:26 +02:00
|
|
|
newStartDate = [newStartDate hour: uStart minute: 0];
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
2006-09-28 19:26:02 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
return newStartDate;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2015-02-12 21:01:26 +01:00
|
|
|
*/
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
/*
|
2007-03-18 16:20:38 +01:00
|
|
|
- (id <WOActionResults>) defaultAction
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
NSCalendarDate *startDate, *endDate;
|
2008-12-01 23:46:31 +01:00
|
|
|
NSString *duration;
|
2009-07-29 20:46:44 +02:00
|
|
|
NSTimeZone *timeZone;
|
2010-02-11 03:36:43 +01:00
|
|
|
unsigned int total, hours, minutes;
|
2011-01-21 22:56:09 +01:00
|
|
|
signed int offset;
|
2008-07-17 23:12:43 +02:00
|
|
|
SOGoObject <SOGoComponentOccurence> *co;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2007-11-26 18:40:44 +01:00
|
|
|
[self event];
|
2008-07-17 23:12:43 +02:00
|
|
|
co = [self clientObject];
|
2009-11-29 05:19:32 +01:00
|
|
|
|
|
|
|
ud = [[context activeUser] userDefaults];
|
|
|
|
timeZone = [ud timeZone];
|
2009-07-29 20:46:44 +02:00
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
if ([co isNew]
|
|
|
|
&& [co isKindOfClass: [SOGoCalendarComponent class]])
|
2007-03-18 16:20:38 +01:00
|
|
|
{
|
|
|
|
startDate = [self newStartDate];
|
2010-02-11 03:36:43 +01:00
|
|
|
duration = [self queryParameterForKey:@"duration"];
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([duration length] > 0)
|
2010-02-11 03:36:43 +01:00
|
|
|
{
|
|
|
|
total = [duration intValue];
|
|
|
|
hours = total / 100;
|
|
|
|
minutes = total % 100;
|
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
else
|
2010-02-11 03:36:43 +01:00
|
|
|
{
|
|
|
|
hours = 1;
|
|
|
|
minutes = 0;
|
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
endDate
|
2009-07-14 19:17:06 +02:00
|
|
|
= [startDate dateByAddingYears: 0 months: 0 days: 0
|
2010-02-11 03:36:43 +01:00
|
|
|
hours: hours minutes: minutes seconds: 0];
|
2013-06-18 20:14:42 +02:00
|
|
|
sendAppointmentNotifications = YES;
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
2007-11-27 17:00:18 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
startDate = [event startDate];
|
|
|
|
isAllDay = [event isAllDay];
|
2010-03-12 21:24:59 +01:00
|
|
|
endDate = [event endDate];
|
2007-11-27 17:00:18 +01:00
|
|
|
if (isAllDay)
|
2013-01-21 19:33:40 +01:00
|
|
|
{
|
|
|
|
endDate = [endDate dateByAddingYears: 0 months: 0 days: -1];
|
|
|
|
|
2013-01-29 20:53:57 +01:00
|
|
|
// Convert the dates to the user's timezone
|
|
|
|
offset = [timeZone secondsFromGMTForDate: startDate];
|
|
|
|
startDate = [startDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
|
2013-01-21 19:33:40 +01:00
|
|
|
seconds:-offset];
|
2013-01-29 20:53:57 +01:00
|
|
|
endDate = [endDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
|
|
|
|
seconds:-offset];
|
2013-01-21 19:33:40 +01:00
|
|
|
}
|
2015-02-12 21:01:26 +01:00
|
|
|
isTransparent = ![event isOpaque];
|
2013-06-18 20:14:42 +02:00
|
|
|
sendAppointmentNotifications = ([event firstChildWithTag: @"X-SOGo-Send-Appointment-Notifications"] ? NO : YES);
|
2007-11-27 17:00:18 +01:00
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2009-07-29 20:46:44 +02:00
|
|
|
[startDate setTimeZone: timeZone];
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (aptStartDate, startDate);
|
2009-07-29 20:46:44 +02:00
|
|
|
|
|
|
|
[endDate setTimeZone: timeZone];
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (aptEndDate, endDate);
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
2015-02-12 21:01:26 +01:00
|
|
|
*/
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-12-23 19:39:36 +01:00
|
|
|
- (void) _adjustRecurrentRules
|
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
iCalEvent *event;
|
2008-12-23 19:39:36 +01:00
|
|
|
iCalRecurrenceRule *rule;
|
|
|
|
NSEnumerator *rules;
|
|
|
|
NSCalendarDate *untilDate;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
|
|
|
NSTimeZone *timeZone;
|
2015-02-12 21:01:26 +01:00
|
|
|
|
|
|
|
event = [self event];
|
2008-12-23 19:39:36 +01:00
|
|
|
rules = [[event recurrenceRules] objectEnumerator];
|
2009-11-29 05:19:32 +01:00
|
|
|
ud = [[context activeUser] userDefaults];
|
|
|
|
timeZone = [ud timeZone];
|
|
|
|
|
2008-12-23 19:39:36 +01:00
|
|
|
while ((rule = [rules nextObject]))
|
|
|
|
{
|
|
|
|
untilDate = [rule untilDate];
|
|
|
|
if (untilDate)
|
2013-01-21 19:33:40 +01:00
|
|
|
{
|
|
|
|
// The until date must match the time of the end date
|
|
|
|
NSCalendarDate *date;
|
|
|
|
|
|
|
|
date = [[event endDate] copy];
|
|
|
|
[date setTimeZone: timeZone];
|
|
|
|
[untilDate setTimeZone: timeZone];
|
|
|
|
untilDate = [untilDate dateByAddingYears:0
|
|
|
|
months:0
|
|
|
|
days:0
|
|
|
|
hours:[date hourOfDay]
|
|
|
|
minutes:[date minuteOfHour]
|
|
|
|
seconds:0];
|
|
|
|
[rule setUntilDate: untilDate];
|
|
|
|
[date release];
|
|
|
|
}
|
2008-12-23 19:39:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
/**
|
|
|
|
* @api {post} /so/:username/Calendar/:calendarId/:appointmentId/rsvpAppointment Set participation state
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName PostEventRsvp
|
|
|
|
* @apiGroup Calendar
|
|
|
|
* @apiDescription Set the participation state of an attendee.
|
|
|
|
* @apiExample {curl} Example usage:
|
|
|
|
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/71B6-54904400-1-7C308500.ics/rsvpAppointment \
|
|
|
|
* -H 'Content-Type: application/json' \
|
|
|
|
* -d '{ "reply": 1, \
|
|
|
|
* "alarm": { { "quantity": 15, "unit": "MINUTES", "action": "display", "reference": "BEFORE", "relation": "START" } }'
|
|
|
|
*
|
|
|
|
* @apiParam {Number} reply 0 if needs-action, 1 if accepted, 2 if declined, 3 if tentative, 4 if delegated
|
|
|
|
* @apiParam {String} [delegatedTo] Email address of delegated attendee
|
|
|
|
* @apiParam {Object[]} [alarm] Set an alarm for the attendee
|
|
|
|
* @apiParam {String} alarm.action Either display or email
|
|
|
|
* @apiParam {Number} alarm.quantity Quantity of units
|
|
|
|
* @apiParam {String} alarm.unit Either MINUTES, HOURS, or DAYS
|
|
|
|
* @apiParam {String} alarm.reference Either BEFORE or AFTER
|
|
|
|
* @apiParam {String} alarm.relation Either START or END
|
|
|
|
* @apiParam {Boolean} [alarm.attendees] Alert attendees by email if 1 and action is email
|
|
|
|
* @apiParam {Boolean} [alarm.organizer] Alert organizer by email if 1 and action is email
|
|
|
|
*/
|
2014-12-16 15:20:27 +01:00
|
|
|
- (id <WOActionResults>) rsvpAction
|
|
|
|
{
|
|
|
|
iCalPerson *delegatedAttendee;
|
2015-08-05 22:44:25 +02:00
|
|
|
NSDictionary *params, *jsonResponse;
|
2014-12-16 15:20:27 +01:00
|
|
|
WOResponse *response;
|
|
|
|
WORequest *request;
|
|
|
|
iCalAlarm *anAlarm;
|
2015-08-05 22:44:25 +02:00
|
|
|
NSException *ex;
|
2014-12-16 15:20:27 +01:00
|
|
|
NSString *status;
|
2015-08-05 22:44:25 +02:00
|
|
|
id alarm;
|
2014-12-16 15:20:27 +01:00
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
int replyList;
|
2014-12-16 15:20:27 +01:00
|
|
|
|
|
|
|
request = [context request];
|
2015-08-05 22:44:25 +02:00
|
|
|
params = [[request contentAsString] objectFromJSONString];
|
2014-12-16 15:20:27 +01:00
|
|
|
|
|
|
|
delegatedAttendee = nil;
|
|
|
|
anAlarm = nil;
|
|
|
|
status = nil;
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
replyList = [[params objectForKey: @"reply"] intValue];
|
2014-12-16 15:20:27 +01:00
|
|
|
|
|
|
|
switch (replyList)
|
|
|
|
{
|
2015-08-05 22:44:25 +02:00
|
|
|
case iCalPersonPartStatAccepted:
|
2014-12-16 15:20:27 +01:00
|
|
|
status = @"ACCEPTED";
|
|
|
|
break;
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
case iCalPersonPartStatDeclined:
|
2014-12-16 15:20:27 +01:00
|
|
|
status = @"DECLINED";
|
|
|
|
break;
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
case iCalPersonPartStatNeedsAction:
|
2014-12-16 15:20:27 +01:00
|
|
|
status = @"NEEDS-ACTION";
|
|
|
|
break;
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
case iCalPersonPartStatTentative:
|
2014-12-16 15:20:27 +01:00
|
|
|
status = @"TENTATIVE";
|
|
|
|
break;
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
case iCalPersonPartStatDelegated:
|
2014-12-16 15:20:27 +01:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
NSString *delegatedEmail, *delegatedUid;
|
|
|
|
SOGoUser *user;
|
|
|
|
|
|
|
|
status = @"DELEGATED";
|
2015-08-05 22:44:25 +02:00
|
|
|
delegatedEmail = [[params objectForKey: @"delegatedTo"] stringByTrimmingSpaces];
|
2014-12-16 15:20:27 +01:00
|
|
|
|
|
|
|
if ([delegatedEmail length])
|
|
|
|
{
|
|
|
|
user = [context activeUser];
|
|
|
|
delegatedAttendee = [iCalPerson new];
|
|
|
|
[delegatedAttendee autorelease];
|
|
|
|
[delegatedAttendee setEmail: delegatedEmail];
|
2015-07-22 22:45:42 +02:00
|
|
|
delegatedUid = [delegatedAttendee uidInDomain: [user domain]];
|
2014-12-16 15:20:27 +01:00
|
|
|
if (delegatedUid)
|
|
|
|
{
|
|
|
|
SOGoUser *delegatedUser;
|
|
|
|
delegatedUser = [SOGoUser userWithLogin: delegatedUid];
|
|
|
|
[delegatedAttendee setCn: [delegatedUser cn]];
|
|
|
|
}
|
|
|
|
|
|
|
|
[delegatedAttendee setRole: @"REQ-PARTICIPANT"];
|
|
|
|
[delegatedAttendee setRsvp: @"TRUE"];
|
|
|
|
[delegatedAttendee setParticipationStatus: iCalPersonPartStatNeedsAction];
|
|
|
|
[delegatedAttendee setDelegatedFrom:
|
|
|
|
[NSString stringWithFormat: @"mailto:%@", [[user allEmails] objectAtIndex: 0]]];
|
|
|
|
}
|
|
|
|
else
|
2015-08-05 22:44:25 +02:00
|
|
|
{
|
|
|
|
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
@"failure", @"status",
|
|
|
|
@"missing 'delegatedTo' parameter", @"message",
|
|
|
|
nil];
|
|
|
|
return [self responseWithStatus: 400
|
|
|
|
andString: [jsonResponse jsonRepresentation]];
|
|
|
|
}
|
2014-12-16 15:20:27 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
// Set an alarm for the user
|
|
|
|
alarm = [params objectForKey: @"alarm"];
|
|
|
|
if ([alarm isKindOfClass: [NSDictionary class]])
|
2014-12-16 15:20:27 +01:00
|
|
|
{
|
2015-08-05 22:44:25 +02:00
|
|
|
NSString *reminderAction, *reminderUnit, *reminderQuantity, *reminderReference, *reminderRelation;
|
|
|
|
BOOL reminderEmailAttendees, reminderEmailOrganizer;
|
|
|
|
|
|
|
|
reminderAction = [alarm objectForKey: @"action"];
|
|
|
|
reminderUnit = [alarm objectForKey: @"unit"];
|
|
|
|
reminderQuantity = [alarm objectForKey: @"quantity"];
|
|
|
|
reminderReference = [alarm objectForKey: @"reference"];
|
|
|
|
reminderRelation = [alarm objectForKey: @"relation"];
|
|
|
|
reminderEmailAttendees = [[alarm objectForKey: @"attendees"] boolValue];
|
|
|
|
reminderEmailOrganizer = [[alarm objectForKey: @"organizer"] boolValue];
|
2014-12-16 15:20:27 +01:00
|
|
|
anAlarm = [iCalAlarm alarmForEvent: [self event]
|
|
|
|
owner: [[self clientObject] ownerInContext: context]
|
2015-08-05 22:44:25 +02:00
|
|
|
action: reminderAction
|
|
|
|
unit: reminderUnit
|
|
|
|
quantity: reminderQuantity
|
|
|
|
reference: reminderReference
|
|
|
|
reminderRelation: reminderRelation
|
|
|
|
emailAttendees: reminderEmailAttendees
|
|
|
|
emailOrganizer: reminderEmailOrganizer];
|
2014-12-16 15:20:27 +01:00
|
|
|
}
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
ex = [[self clientObject] changeParticipationStatus: status
|
|
|
|
withDelegate: delegatedAttendee
|
|
|
|
alarm: anAlarm];
|
2014-12-16 15:20:27 +01:00
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
if (ex)
|
|
|
|
{
|
|
|
|
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[ex reason], @"message",
|
|
|
|
nil];
|
|
|
|
response = [self responseWithStatus: [ex httpStatus]
|
|
|
|
andString: [jsonResponse jsonRepresentation]];
|
|
|
|
}
|
|
|
|
else
|
2014-12-16 15:20:27 +01:00
|
|
|
response = [self responseWith204];
|
2015-08-05 22:44:25 +02:00
|
|
|
|
2014-12-16 15:20:27 +01:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
/**
|
2015-06-04 20:36:58 +02:00
|
|
|
* @api {post} /so/:username/Calendar/:calendarId/:appointmentId/save(AsAppointment) Save event
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName PostEventSave
|
|
|
|
* @apiGroup Calendar
|
2015-06-04 20:36:58 +02:00
|
|
|
* @apiDescription When saving a new event, the action URL must be saveAsAppointment,
|
|
|
|
* otherwise it is optional.
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiExample {curl} Example usage:
|
|
|
|
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/71B6-54904400-1-7C308500.ics/save \
|
|
|
|
* -H 'Content-Type: application/json' \
|
|
|
|
* -d '{ "summary": "Meeting", "startDate": "2015-01-28", "startTime": "10:00", \
|
|
|
|
* "endDate": "2015-01-28", "endTime": "12:00" }'
|
|
|
|
*
|
2015-06-25 17:23:18 +02:00
|
|
|
* @apiParam {_} . _Save in [iCalEvent+SOGo setAttributes:inContext:]_
|
|
|
|
*
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiParam {String} startDate Start date (YYYY-MM-DD)
|
|
|
|
* @apiParam {String} startTime Start time (HH:MM)
|
|
|
|
* @apiParam {String} endDate End date (YYYY-MM-DD)
|
|
|
|
* @apiParam {String} endTime End time (HH:MM)
|
|
|
|
* @apiParam {Number} [isAllDay] 1 if event is all-day
|
|
|
|
* @apiParam {Number} isTransparent 1 if the event is not opaque
|
|
|
|
*
|
2015-06-25 17:23:18 +02:00
|
|
|
* @apiParam {_} .. _Save in [iCalEntityObject+SOGo setAttributes:inContext:]_
|
2015-02-12 21:01:26 +01:00
|
|
|
*
|
|
|
|
* @apiParam {Number} [sendAppointmentNotifications] 0 if notifications must not be sent
|
|
|
|
* @apiParam {String} [summary] Summary
|
|
|
|
* @apiParam {String} [location] Location
|
|
|
|
* @apiParam {String} [comment] Comment
|
|
|
|
* @apiParam {String} [status] Status
|
|
|
|
* @apiParam {String} [attachUrl] Attached URL
|
|
|
|
* @apiParam {Number} [priority] Priority
|
|
|
|
* @apiParam {NSString} [classification] Either public, confidential or private
|
|
|
|
* @apiParam {String[]} [categories] Categories
|
|
|
|
* @apiParam {Object[]} [attendees] List of attendees
|
|
|
|
* @apiParam {String} [attendees.name] Attendee's name
|
|
|
|
* @apiParam {String} attendees.email Attendee's email address
|
|
|
|
* @apiParam {String} [attendees.uid] System user ID
|
|
|
|
* @apiParam {String} attendees.status Attendee's participation status
|
|
|
|
* @apiParam {String} [attendees.role] Either CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, or NON-PARTICIPANT
|
|
|
|
* @apiParam {String} [attendees.delegatedTo] User that the original request was delegated to
|
|
|
|
* @apiParam {String} [attendees.delegatedFrom] User the request was delegated from
|
|
|
|
* @apiParam {Object[]} [alarm] Alarm definition
|
|
|
|
* @apiParam {String} alarm.action Either display or email
|
|
|
|
* @apiParam {Number} alarm.quantity Quantity of units
|
|
|
|
* @apiParam {String} alarm.unit Either MINUTES, HOURS, or DAYS
|
|
|
|
* @apiParam {String} alarm.reference Either BEFORE or AFTER
|
|
|
|
* @apiParam {String} alarm.relation Either START or END
|
|
|
|
* @apiParam {Boolean} [alarm.attendees] Alert attendees by email if true and action is email
|
2015-08-05 22:44:25 +02:00
|
|
|
* @apiParam {Boolean} [alarm.organizer] Alert organizer by email if true and action is email
|
2015-02-12 21:01:26 +01:00
|
|
|
*
|
2015-06-25 17:23:18 +02:00
|
|
|
* @apiParam {_} ... _Save in [iCalRepeatbleEntityObject+SOGo setAttributes:inContext:]_
|
2015-02-12 21:01:26 +01:00
|
|
|
*
|
|
|
|
* @apiParam {Object} [repeat] Recurrence rule definition
|
|
|
|
* @apiParam {String} repeat.frequency Either daily, every weekday, weekly, bi-weekly, monthly, or yearly
|
|
|
|
* @apiParam {Number} repeat.interval Intervals the recurrence rule repeats
|
|
|
|
* @apiParam {String} [repeat.count] Number of occurrences at which to range-bound the recurrence
|
|
|
|
* @apiParam {String} [repeat.until] A date (YYYY-MM-DD) that bounds the recurrence rule in an inclusive manner
|
|
|
|
* @apiParam {Object[]} [repeat.days] List of days of the week (by day mask)
|
|
|
|
* @apiParam {String} [repeat.days.day] Day of the week (SU, MO, TU, WE, TH, FR, SA)
|
|
|
|
* @apiParam {Number} [repeat.days.occurence] Occurrence of a specific day within the monthly or yearly rule (values are -5 to 5)
|
|
|
|
* @apiParam {Number[]} [repeat.months] List of months of the year (values are 1 to 12)
|
|
|
|
* @apiParam {Number[]} [repeat.monthdays] Days of the month (values are 1 to 31)
|
|
|
|
*
|
2015-06-25 17:23:18 +02:00
|
|
|
* @apiParam {_} .... _Save in [UIxComponentEditor setAttributes:]_
|
2015-02-12 21:01:26 +01:00
|
|
|
*
|
2015-05-14 17:36:21 +02:00
|
|
|
* @apiParam {String} [destinationCalendar] ID of destination calendar
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiParam {Object} [organizer] Appointment organizer
|
|
|
|
* @apiParam {String} organizer.name Organizer's name
|
|
|
|
* @apiParam {String} organizer.email Organizer's email address
|
|
|
|
*
|
|
|
|
* @apiError (Error 500) {Object} error The error message
|
|
|
|
*/
|
2007-03-18 16:20:38 +01:00
|
|
|
- (id <WOActionResults>) saveAction
|
2006-10-11 20:56:04 +02:00
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
NSDictionary *params;
|
|
|
|
NSString *jsonResponse;
|
|
|
|
NSException *ex;
|
|
|
|
iCalEvent *event;
|
2008-12-12 19:44:07 +01:00
|
|
|
SOGoAppointmentFolder *previousCalendar;
|
2008-08-10 23:44:25 +02:00
|
|
|
SOGoAppointmentObject *co;
|
|
|
|
SoSecurityManager *sm;
|
2015-02-12 21:01:26 +01:00
|
|
|
WORequest *request;
|
2016-02-15 21:58:58 +01:00
|
|
|
id error;
|
2016-02-11 16:54:07 +01:00
|
|
|
|
2015-05-01 15:08:07 +02:00
|
|
|
unsigned int httpStatus;
|
2016-02-11 16:54:07 +01:00
|
|
|
BOOL forceSave;
|
2008-08-10 23:44:25 +02:00
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
event = [self event];
|
2008-08-10 23:44:25 +02:00
|
|
|
co = [self clientObject];
|
2008-12-12 19:44:07 +01:00
|
|
|
if ([co isKindOfClass: [SOGoAppointmentOccurence class]])
|
|
|
|
co = [co container];
|
|
|
|
previousCalendar = [co container];
|
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
2008-11-26 17:26:32 +01:00
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
ex = nil;
|
|
|
|
request = [context request];
|
|
|
|
params = [[request contentAsString] objectFromJSONString];
|
|
|
|
if (params == nil)
|
2008-11-26 17:26:32 +01:00
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
ex = [NSException exceptionWithName: @"JSONParsingException"
|
|
|
|
reason: @"Can't parse JSON string"
|
|
|
|
userInfo: nil];
|
2008-11-26 17:26:32 +01:00
|
|
|
}
|
2008-12-12 19:44:07 +01:00
|
|
|
else
|
2008-08-10 23:44:25 +02:00
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
[self setAttributes: params];
|
2016-02-15 21:58:58 +01:00
|
|
|
forceSave = [[params objectForKey: @"ignoreConflicts"] boolValue];
|
2008-08-10 23:44:25 +02:00
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
if ([event hasRecurrenceRules])
|
|
|
|
[self _adjustRecurrentRules];
|
|
|
|
|
|
|
|
if ([co isNew])
|
2013-01-21 19:33:40 +01:00
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
if (componentCalendar
|
|
|
|
&& ![[componentCalendar ocsPath]
|
|
|
|
isEqualToString: [previousCalendar ocsPath]])
|
2013-01-21 19:33:40 +01:00
|
|
|
{
|
2015-02-12 21:01:26 +01:00
|
|
|
// New event in a different calendar -- make sure the user can
|
|
|
|
// write to the selected calendar since the rights were verified
|
|
|
|
// on the calendar specified in the URL, not on the selected
|
|
|
|
// calendar of the popup menu.
|
2013-01-21 19:33:40 +01:00
|
|
|
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
2015-02-12 21:01:26 +01:00
|
|
|
onObject: componentCalendar
|
|
|
|
inContext: context])
|
|
|
|
co = [componentCalendar lookupName: [co nameInContainer]
|
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save the event.
|
2016-02-11 16:54:07 +01:00
|
|
|
ex = [co saveComponent: event force: forceSave];
|
2015-02-12 21:01:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The event was modified -- save it.
|
2016-02-11 16:54:07 +01:00
|
|
|
ex = [co saveComponent: event force: forceSave];
|
2015-02-12 21:01:26 +01:00
|
|
|
|
|
|
|
if (componentCalendar
|
|
|
|
&& ![[componentCalendar ocsPath]
|
|
|
|
isEqualToString: [previousCalendar ocsPath]])
|
|
|
|
{
|
|
|
|
// The event was moved to a different calendar.
|
|
|
|
if (![sm validatePermission: SoPerm_DeleteObjects
|
|
|
|
onObject: previousCalendar
|
|
|
|
inContext: context])
|
|
|
|
{
|
|
|
|
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
|
|
|
onObject: componentCalendar
|
|
|
|
inContext: context])
|
|
|
|
ex = [co moveToFolder: componentCalendar];
|
|
|
|
}
|
2013-01-21 19:33:40 +01:00
|
|
|
}
|
|
|
|
}
|
2008-08-10 23:44:25 +02:00
|
|
|
}
|
2011-04-25 12:31:08 +02:00
|
|
|
|
|
|
|
if (ex)
|
2015-05-01 15:08:07 +02:00
|
|
|
{
|
|
|
|
httpStatus = 500;
|
2016-02-11 16:54:07 +01:00
|
|
|
|
2016-02-12 19:48:51 +01:00
|
|
|
if ([ex respondsToSelector: @selector(httpStatus)])
|
2016-02-11 16:54:07 +01:00
|
|
|
httpStatus = [ex httpStatus];
|
|
|
|
|
2016-02-15 21:58:58 +01:00
|
|
|
error = [[ex reason] objectFromJSONString];
|
|
|
|
if (error == nil)
|
|
|
|
error = [ex reason];
|
2015-05-01 15:08:07 +02:00
|
|
|
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
|
2016-02-15 21:58:58 +01:00
|
|
|
error, @"message", nil];
|
2015-05-01 15:08:07 +02:00
|
|
|
}
|
2011-04-25 12:31:08 +02:00
|
|
|
else
|
2015-05-01 15:08:07 +02:00
|
|
|
{
|
|
|
|
httpStatus = 200;
|
|
|
|
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
@"success", @"status", nil];
|
|
|
|
}
|
2015-02-12 21:01:26 +01:00
|
|
|
|
2015-05-01 15:08:07 +02:00
|
|
|
return [self responseWithStatus: httpStatus
|
2015-02-12 21:01:26 +01:00
|
|
|
andJSONRepresentation: jsonResponse];
|
2006-10-11 20:56:04 +02:00
|
|
|
}
|
|
|
|
|
2015-01-22 18:12:51 +01:00
|
|
|
/**
|
|
|
|
* @api {get} /so/:username/Calendar/:calendarId/:eventId/view Get event
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName GetEventView
|
|
|
|
* @apiGroup Calendar
|
|
|
|
* @apiExample {curl} Example usage:
|
|
|
|
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/71B6-54904400-1-7C308500.ics/view
|
|
|
|
*
|
2015-06-22 15:20:35 +02:00
|
|
|
* @apiParam {Number} [resetAlarm] Mark alarm as triggered if set to 1
|
|
|
|
* @apiParam {Number} [snoozeAlarm] Snooze the alarm for this number of minutes
|
2015-01-22 18:12:51 +01:00
|
|
|
*
|
2015-07-01 20:34:35 +02:00
|
|
|
* @apiSuccess {_} . _From [UIxAppointmentEditor viewAction]_
|
|
|
|
*
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String} id Event ID
|
2015-07-27 22:02:05 +02:00
|
|
|
* @apiSuccess (Success 200) {String} [occurrenceId] Occurrence ID
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String} pid Calendar ID (event's folder)
|
|
|
|
* @apiSuccess (Success 200) {String} calendar Human readable name of calendar
|
2015-02-18 22:36:37 +01:00
|
|
|
* @apiSuccess (Success 200) {String} startDate Start date (ISO8601)
|
2015-01-28 16:05:18 +01:00
|
|
|
* @apiSuccess (Success 200) {String} localizedStartDate Formatted start date
|
2015-02-18 22:36:37 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [localizedStartTime] Formatted start time
|
|
|
|
* @apiSuccess (Success 200) {String} endDate End date (ISO8601)
|
2015-01-28 16:05:18 +01:00
|
|
|
* @apiSuccess (Success 200) {String} localizedEndDate Formatted end date
|
2015-02-18 22:36:37 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [localizedEndTime] Formatted end time
|
2015-04-24 20:25:04 +02:00
|
|
|
* @apiSuccess (Success 200) {Number} isReadOnly 1 if event is read-only
|
2015-08-05 22:44:25 +02:00
|
|
|
* @apiSuccess (Success 200) {Number} userHasRSVP 1 if owner is invited
|
|
|
|
* @apiSuccess (Success 200) {Number} [reply] 0 if needs-action, 1 if accepted, 2 if declined, 3 if tentative, 4 if delegated
|
2015-07-01 20:34:35 +02:00
|
|
|
* @apiSuccess (Success 200) {Object[]} [attachUrls] Attached URLs
|
|
|
|
* @apiSuccess (Success 200) {String} attachUrls.value URL
|
2015-02-12 21:01:26 +01:00
|
|
|
*
|
2015-07-01 20:34:35 +02:00
|
|
|
* @apiSuccess {_} .. _From [UIxComponentEditor alarm]_
|
2015-06-25 17:23:18 +02:00
|
|
|
*
|
|
|
|
* @apiSuccess (Success 200) {Object[]} [alarm] Alarm definition
|
|
|
|
* @apiSuccess (Success 200) {String} alarm.action Either display or email
|
|
|
|
* @apiSuccess (Success 200) {Number} alarm.quantity Quantity of units
|
|
|
|
* @apiSuccess (Success 200) {String} alarm.unit Either MINUTES, HOURS, or DAYS
|
|
|
|
* @apiSuccess (Success 200) {String} alarm.reference Either BEFORE or AFTER
|
|
|
|
* @apiSuccess (Success 200) {String} alarm.relation Either START or END
|
2015-08-05 22:44:25 +02:00
|
|
|
* @apiSuccess (Success 200) {Boolean} alarm.attendees Alert attendees by email if true and action is email
|
|
|
|
* @apiSuccess (Success 200) {Boolean} alarm.organizer Alert organizer by email if true and action is email
|
2015-06-25 17:23:18 +02:00
|
|
|
*
|
2015-10-09 22:50:09 +02:00
|
|
|
* @apiSuccess {_} ... _From [iCalEvent+SOGo attributesInContext:]_
|
2015-02-12 21:01:26 +01:00
|
|
|
*
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {Number} isAllDay 1 if event is all-day
|
|
|
|
* @apiSuccess (Success 200) {Number} isTransparent 1 if the event is not opaque
|
|
|
|
*
|
2015-10-09 22:50:09 +02:00
|
|
|
* @apiSuccess {_} .... _From [iCalEntityObject+SOGo attributesInContext:]_
|
2015-01-22 18:12:51 +01:00
|
|
|
*
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {Number} sendAppointmentNotifications 1 if notifications must be sent
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String} component "vevent"
|
|
|
|
* @apiSuccess (Success 200) {String} summary Summary
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [location] Location
|
|
|
|
* @apiSuccess (Success 200) {String} [comment] Comment
|
2015-04-24 22:48:41 +02:00
|
|
|
* @apiSuccess (Success 200) {String} [status] Status (tentative, confirmed, or cancelled)
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [createdBy] Value of custom header X-SOGo-Component-Created-By or organizer's "SENT-BY"
|
2015-04-24 22:48:41 +02:00
|
|
|
* @apiSuccess (Success 200) {Number} priority Priority (0-9)
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {NSString} [classification] Either public, confidential or private
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String[]} [categories] Categories
|
|
|
|
* @apiSuccess (Success 200) {Object} [organizer] Appointment organizer
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [organizer.name] Organizer's name
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String} organizer.email Organizer's email address
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [organizer.uid] Organizer's user ID
|
|
|
|
* @apiSuccess (Success 200) {String} [organizer.sentBy] Email address of user that is acting on behalf of the calendar owner
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {Object[]} [attendees] List of attendees
|
|
|
|
* @apiSuccess (Success 200) {String} [attendees.name] Attendee's name
|
|
|
|
* @apiSuccess (Success 200) {String} attendees.email Attendee's email address
|
|
|
|
* @apiSuccess (Success 200) {String} [attendees.uid] System user ID
|
|
|
|
* @apiSuccess (Success 200) {String} attendees.status Attendee's participation status
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [attendees.role] Either CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, or NON-PARTICIPANT
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [attendees.delegatedTo] User that the original request was delegated to
|
|
|
|
* @apiSuccess (Success 200) {String} [attendees.delegatedFrom] User the request was delegated from
|
|
|
|
*
|
2015-10-09 22:50:09 +02:00
|
|
|
* @apiSuccess {_} ..... _From [iCalRepeatableEntityObject+SOGo attributesInContext:]_
|
2015-01-22 18:12:51 +01:00
|
|
|
*
|
|
|
|
* @apiSuccess (Success 200) {Object} [repeat] Recurrence rule definition
|
|
|
|
* @apiSuccess (Success 200) {String} repeat.frequency Either daily, (every weekday), weekly, (bi-weekly), monthly, or yearly
|
|
|
|
* @apiSuccess (Success 200) {Number} repeat.interval Intervals the recurrence rule repeats
|
|
|
|
* @apiSuccess (Success 200) {String} [repeat.count] Number of occurrences at which to range-bound the recurrence
|
|
|
|
* @apiSuccess (Success 200) {String} [repeat.until] A Unix epoch value that bounds the recurrence rule in an inclusive manner
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {Object[]} [repeat.days] List of days of the week (by day mask)
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {String} repeat.days.day Day of the week (SU, MO, TU, WE, TH, FR, SA)
|
2015-02-12 21:01:26 +01:00
|
|
|
* @apiSuccess (Success 200) {Number} [repeat.days.occurence] Occurrence of a specific day within the monthly or yearly rule (values are -5 to 5)
|
2015-01-22 18:12:51 +01:00
|
|
|
* @apiSuccess (Success 200) {Number[]} [repeat.months] List of months of the year (values are 1 to 12)
|
|
|
|
* @apiSuccess (Success 200) {Number[]} [repeat.monthdays] Days of the month (values are 1 to 31)
|
|
|
|
*/
|
2008-08-19 00:45:59 +02:00
|
|
|
- (id <WOActionResults>) viewAction
|
|
|
|
{
|
2015-02-18 22:36:37 +01:00
|
|
|
BOOL isAllDay;
|
2015-07-01 20:34:35 +02:00
|
|
|
NSArray *attachUrls;
|
2015-01-22 18:12:51 +01:00
|
|
|
NSMutableDictionary *data;
|
2012-01-03 22:42:23 +01:00
|
|
|
NSCalendarDate *eventStartDate, *eventEndDate;
|
2008-12-30 15:47:58 +01:00
|
|
|
NSTimeZone *timeZone;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
2008-12-30 15:47:58 +01:00
|
|
|
SOGoCalendarComponent *co;
|
2014-09-12 14:34:15 +02:00
|
|
|
iCalAlarm *anAlarm;
|
2015-02-12 21:01:26 +01:00
|
|
|
iCalEvent *event;
|
2013-06-19 16:23:47 +02:00
|
|
|
|
2011-10-03 21:32:37 +02:00
|
|
|
BOOL resetAlarm;
|
2015-11-03 21:47:30 +01:00
|
|
|
NSInteger offset;
|
|
|
|
NSUInteger snoozeAlarm;
|
2008-12-30 15:47:58 +01:00
|
|
|
|
2015-02-12 21:01:26 +01:00
|
|
|
event = [self event];
|
2015-02-18 22:36:37 +01:00
|
|
|
co = [self clientObject];
|
2008-08-19 00:45:59 +02:00
|
|
|
|
2015-02-18 22:36:37 +01:00
|
|
|
isAllDay = [event isAllDay];
|
2009-11-29 05:19:32 +01:00
|
|
|
ud = [[context activeUser] userDefaults];
|
|
|
|
timeZone = [ud timeZone];
|
2012-01-03 22:42:23 +01:00
|
|
|
eventStartDate = [event startDate];
|
|
|
|
eventEndDate = [event endDate];
|
2015-11-03 21:47:30 +01:00
|
|
|
|
|
|
|
if (isAllDay)
|
2015-02-18 22:36:37 +01:00
|
|
|
{
|
2015-11-03 21:47:30 +01:00
|
|
|
eventEndDate = [eventEndDate dateByAddingYears: 0 months: 0 days: -1];
|
|
|
|
|
|
|
|
// Convert the dates to the user's timezone
|
|
|
|
offset = [timeZone secondsFromGMTForDate: eventStartDate];
|
|
|
|
eventStartDate = [eventStartDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
|
|
|
|
seconds:-offset];
|
|
|
|
offset = [timeZone secondsFromGMTForDate: eventEndDate];
|
|
|
|
eventEndDate = [eventEndDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
|
|
|
|
seconds:-offset];
|
2015-02-18 22:36:37 +01:00
|
|
|
}
|
2014-09-12 14:34:15 +02:00
|
|
|
|
2015-11-03 21:47:30 +01:00
|
|
|
[eventStartDate setTimeZone: timeZone];
|
|
|
|
[eventEndDate setTimeZone: timeZone];
|
|
|
|
|
2014-09-12 14:34:15 +02:00
|
|
|
// resetAlarm=yes is set only when we are about to show the alarm popup in the Web
|
|
|
|
// interface of SOGo. See generic.js for details. snoozeAlarm=X is called when the
|
|
|
|
// user clicks on "Snooze for" X minutes, when the popup is being displayed.
|
2015-01-22 18:12:51 +01:00
|
|
|
// If either is set, we must find the right alarm.
|
2014-09-12 14:34:15 +02:00
|
|
|
resetAlarm = [[[context request] formValueForKey: @"resetAlarm"] boolValue];
|
|
|
|
snoozeAlarm = [[[context request] formValueForKey: @"snoozeAlarm"] intValue];
|
2015-02-12 21:01:26 +01:00
|
|
|
|
2014-09-12 14:34:15 +02:00
|
|
|
if (resetAlarm || snoozeAlarm)
|
2009-04-22 23:02:11 +02:00
|
|
|
{
|
2014-09-12 14:34:15 +02:00
|
|
|
iCalEvent *master;
|
|
|
|
|
|
|
|
master = event;
|
|
|
|
[componentCalendar findEntityForClosestAlarm: &event
|
|
|
|
timezone: timeZone
|
|
|
|
startDate: &eventStartDate
|
|
|
|
endDate: &eventEndDate];
|
2015-02-12 21:01:26 +01:00
|
|
|
|
2014-09-12 20:09:28 +02:00
|
|
|
anAlarm = [event firstDisplayOrAudioAlarm];
|
|
|
|
|
2011-10-03 21:32:37 +02:00
|
|
|
if (resetAlarm)
|
|
|
|
{
|
|
|
|
iCalTrigger *aTrigger;
|
2014-09-12 20:09:28 +02:00
|
|
|
|
2011-10-03 21:32:37 +02:00
|
|
|
aTrigger = [anAlarm trigger];
|
2015-02-12 21:01:26 +01:00
|
|
|
[aTrigger setValue: 0 ofAttribute: @"x-webstatus" to: @"triggered"];
|
2014-09-12 14:34:15 +02:00
|
|
|
[co saveComponent: master];
|
2011-10-03 21:32:37 +02:00
|
|
|
}
|
|
|
|
else if (snoozeAlarm)
|
|
|
|
{
|
2014-09-12 20:09:28 +02:00
|
|
|
[co snoozeAlarm: snoozeAlarm];
|
2011-10-03 21:32:37 +02:00
|
|
|
}
|
2009-04-22 23:02:11 +02:00
|
|
|
}
|
|
|
|
|
2015-01-22 18:12:51 +01:00
|
|
|
data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[componentCalendar nameInContainer], @"pid",
|
|
|
|
[componentCalendar displayName], @"calendar",
|
2015-11-03 21:47:30 +01:00
|
|
|
[NSNumber numberWithBool: isAllDay], @"isAllDay",
|
2015-04-24 20:25:04 +02:00
|
|
|
[NSNumber numberWithBool: [self isReadOnly]], @"isReadOnly",
|
2015-08-05 22:44:25 +02:00
|
|
|
[NSNumber numberWithBool: [self userHasRSVP]], @"userHasRSVP",
|
2015-11-03 21:47:30 +01:00
|
|
|
[eventStartDate iso8601DateString], @"startDate",
|
|
|
|
[eventEndDate iso8601DateString], @"endDate",
|
2015-01-28 16:05:18 +01:00
|
|
|
[dateFormatter formattedDate: eventStartDate], @"localizedStartDate",
|
|
|
|
[dateFormatter formattedDate: eventEndDate], @"localizedEndDate",
|
2015-07-01 20:34:35 +02:00
|
|
|
[self alarm], @"alarm",
|
2013-01-21 19:33:40 +01:00
|
|
|
nil];
|
2008-08-19 00:45:59 +02:00
|
|
|
|
2015-07-27 22:02:05 +02:00
|
|
|
if ([self isChildOccurrence])
|
|
|
|
{
|
|
|
|
[data setObject: [[co container] nameInContainer] forKey: @"id"];
|
|
|
|
[data setObject: [co nameInContainer] forKey: @"occurrenceId"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[data setObject: [co nameInContainer] forKey: @"id"];
|
|
|
|
}
|
|
|
|
|
2015-07-01 20:34:35 +02:00
|
|
|
attachUrls = [self attachUrls];
|
|
|
|
if ([attachUrls count]) [data setObject: attachUrls forKey: @"attachUrls"];
|
|
|
|
|
2015-02-18 22:36:37 +01:00
|
|
|
if (!isAllDay)
|
|
|
|
{
|
|
|
|
[data setObject: [dateFormatter formattedTime: eventStartDate] forKey: @"localizedStartTime"];
|
|
|
|
[data setObject: [dateFormatter formattedTime: eventEndDate] forKey: @"localizedEndTime"];
|
|
|
|
}
|
|
|
|
|
2015-08-05 22:44:25 +02:00
|
|
|
if ([self userHasRSVP])
|
|
|
|
[data setObject: [self reply] forKey: @"reply"];
|
|
|
|
|
2015-01-28 16:05:18 +01:00
|
|
|
// Add attributes from iCalEvent+SOGo, iCalEntityObject+SOGo and iCalRepeatableEntityObject+SOGo
|
2015-02-17 22:09:16 +01:00
|
|
|
[data addEntriesFromDictionary: [event attributesInContext: context]];
|
2015-01-22 18:12:51 +01:00
|
|
|
|
|
|
|
// Return JSON representation
|
|
|
|
return [self responseWithStatus: 200 andJSONRepresentation: data];
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
@end
|