2007-03-18 16:20:38 +01:00
|
|
|
/* UIxAppointmentEditor.m - this file is part of SOGo
|
|
|
|
*
|
2008-09-27 03:13:41 +02:00
|
|
|
* Copyright (C) 2007 Inverse inc.
|
2007-03-18 16:20:38 +01:00
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
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>
|
|
|
|
|
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>
|
2007-10-09 19:19:20 +02:00
|
|
|
#import <NGCards/iCalRecurrenceRule.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2008-08-19 16:48:30 +02:00
|
|
|
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
2008-08-19 00:45:59 +02:00
|
|
|
#import <SoObjects/SOGo/SOGoDateFormatter.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <SoObjects/SOGo/SOGoContentObject.h>
|
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentObject.h>
|
2008-11-03 15:17:57 +01:00
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentOccurence.h>
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
#import <SoObjects/Appointments/SOGoComponentOccurence.h>
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
aptStartDate = nil;
|
|
|
|
aptEndDate = nil;
|
|
|
|
item = nil;
|
|
|
|
event = nil;
|
2007-06-07 20:12:20 +02:00
|
|
|
isAllDay = NO;
|
2008-12-01 23:46:31 +01:00
|
|
|
isTransparent = NO;
|
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
|
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
[item release];
|
2008-07-11 19:26:11 +02:00
|
|
|
[event release];
|
2007-10-17 16:53:21 +02:00
|
|
|
[aptStartDate release];
|
|
|
|
[aptEndDate release];
|
2007-10-09 19:19:20 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
/* template values */
|
|
|
|
- (iCalEvent *) event
|
|
|
|
{
|
2007-11-19 22:07:54 +01:00
|
|
|
if (!event)
|
|
|
|
{
|
2008-07-17 23:12:43 +02:00
|
|
|
event = (iCalEvent *) [[self clientObject] occurence];
|
2007-11-19 22:07:54 +01:00
|
|
|
[event retain];
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
return event;
|
|
|
|
}
|
2006-10-12 18:42:59 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) saveURL
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@/saveAsAppointment",
|
2008-03-07 23:18:01 +01:00
|
|
|
[[self clientObject] baseURL]];
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
2006-10-12 18:42:59 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
/* icalendar values */
|
|
|
|
- (BOOL) isAllDay
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-06-11 23:25:43 +02:00
|
|
|
NSString *hm;
|
|
|
|
|
|
|
|
hm = [self queryParameterForKey: @"hm"];
|
|
|
|
|
|
|
|
return (isAllDay
|
2008-07-11 19:26:11 +02:00
|
|
|
|| [hm isEqualToString: @"allday"]);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setIsAllDay: (BOOL) newIsAllDay
|
|
|
|
{
|
2007-06-07 20:12:20 +02:00
|
|
|
isAllDay = newIsAllDay;
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-12-01 23:46:31 +01:00
|
|
|
- (BOOL) isTransparent
|
2008-11-06 18:19:14 +01:00
|
|
|
{
|
2008-12-01 23:46:31 +01:00
|
|
|
return isTransparent;
|
2008-11-06 18:19:14 +01:00
|
|
|
}
|
|
|
|
|
2008-12-01 23:46:31 +01:00
|
|
|
- (void) setIsTransparent: (BOOL) newIsTransparent
|
2008-11-06 18:19:14 +01:00
|
|
|
{
|
2008-12-01 23:46:31 +01:00
|
|
|
isTransparent = newIsTransparent;
|
2008-11-06 18:19:14 +01:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setAptStartDate: (NSCalendarDate *) newAptStartDate
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (aptStartDate, newAptStartDate);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (NSCalendarDate *) aptStartDate
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
return aptStartDate;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setAptEndDate: (NSCalendarDate *) newAptEndDate
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (aptEndDate, newAptEndDate);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (NSCalendarDate *) aptEndDate
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
return aptEndDate;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setItem: (NSString *) newItem
|
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
ASSIGN (item, newItem);
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-08-22 08:44:27 +02:00
|
|
|
- (SOGoAppointmentFolder *) componentCalendar
|
|
|
|
{
|
|
|
|
return componentCalendar;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setComponentCalendar: (SOGoAppointmentFolder *) _componentCalendar
|
|
|
|
{
|
|
|
|
ASSIGN (componentCalendar, _componentCalendar);
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* actions */
|
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;
|
2008-07-18 21:25:26 +02:00
|
|
|
SOGoUser *user;
|
2007-03-18 16:20:38 +01:00
|
|
|
int hour;
|
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
|
|
|
{
|
|
|
|
now = [NSCalendarDate calendarDate];
|
2007-04-11 21:08:58 +02:00
|
|
|
timeZone = [[context activeUser] timeZone];
|
|
|
|
[now setTimeZone: timeZone];
|
2008-07-18 21:25:26 +02:00
|
|
|
|
|
|
|
user = [context activeUser];
|
|
|
|
uStart = [user dayStartHour];
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([now isDateOnSameDay: newStartDate])
|
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
uEnd = [user dayEndHour];
|
2007-03-18 16:20:38 +01:00
|
|
|
hour = [now hourOfDay];
|
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
|
|
|
|
newStartDate = now;
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
2007-03-18 16:20:38 +01:00
|
|
|
unsigned int minutes;
|
2008-07-17 23:12:43 +02:00
|
|
|
SOGoObject <SOGoComponentOccurence> *co;
|
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];
|
|
|
|
if ([co isNew]
|
|
|
|
&& [co isKindOfClass: [SOGoCalendarComponent class]])
|
2007-03-18 16:20:38 +01:00
|
|
|
{
|
|
|
|
startDate = [self newStartDate];
|
|
|
|
duration = [self queryParameterForKey:@"dur"];
|
|
|
|
if ([duration length] > 0)
|
|
|
|
minutes = [duration intValue];
|
|
|
|
else
|
|
|
|
minutes = 60;
|
|
|
|
endDate
|
|
|
|
= [startDate dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: minutes seconds: 0];
|
|
|
|
}
|
2007-11-27 17:00:18 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
startDate = [event startDate];
|
|
|
|
isAllDay = [event isAllDay];
|
|
|
|
if (isAllDay)
|
|
|
|
endDate = [[event endDate] dateByAddingYears: 0 months: 0 days: -1];
|
|
|
|
else
|
|
|
|
endDate = [event endDate];
|
2008-12-01 23:46:31 +01:00
|
|
|
isTransparent = ![event isOpaque];
|
2007-11-27 17:00:18 +01:00
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
ASSIGN (aptStartDate, startDate);
|
|
|
|
ASSIGN (aptEndDate, endDate);
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (id <WOActionResults>) newAction
|
2006-10-12 18:42:59 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
NSString *objectId, *method, *uri;
|
2006-10-12 18:42:59 +02:00
|
|
|
id <WOActionResults> result;
|
2007-09-15 00:01:02 +02:00
|
|
|
SOGoAppointmentFolder *co;
|
2008-08-25 21:13:18 +02:00
|
|
|
SoSecurityManager *sm;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
co = [self clientObject];
|
|
|
|
objectId = [co globallyUniqueObjectId];
|
2008-07-11 19:26:11 +02:00
|
|
|
if ([objectId length])
|
2007-03-18 16:20:38 +01:00
|
|
|
{
|
2008-08-25 21:13:18 +02:00
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
|
|
|
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
|
|
|
onObject: co
|
|
|
|
inContext: context])
|
|
|
|
{
|
|
|
|
method = [NSString stringWithFormat:@"%@/%@.ics/editAsAppointment",
|
|
|
|
[co soURL], objectId];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
method = [NSString stringWithFormat: @"%@/Calendar/personal/%@.vcf/editAsAppointment",
|
|
|
|
[self userFolderPath], objectId];
|
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
uri = [self completeHrefForMethod: method];
|
|
|
|
result = [self redirectToLocation: uri];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2006-10-12 18:42:59 +02:00
|
|
|
else
|
2007-03-18 16:20:38 +01:00
|
|
|
result = [NSException exceptionWithHTTPStatus: 500 /* Internal Error */
|
|
|
|
reason: @"could not create a unique ID"];
|
2006-10-12 18:42:59 +02:00
|
|
|
|
|
|
|
return result;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-11-26 17:26:32 +01:00
|
|
|
//
|
|
|
|
// This method needs to carefully handle the following cases :
|
|
|
|
//
|
|
|
|
// A- Alice creates an event in her calendar
|
|
|
|
// B- Alice creates an event in Bob's calendar (and invites herself or not)
|
|
|
|
// C- Alice moves an event to an other calendar
|
|
|
|
//
|
2007-03-18 16:20:38 +01:00
|
|
|
- (id <WOActionResults>) saveAction
|
2006-10-11 20:56:04 +02:00
|
|
|
{
|
2008-08-25 21:13:18 +02:00
|
|
|
SOGoAppointmentFolder *thisFolder;
|
2008-08-10 23:44:25 +02:00
|
|
|
SOGoAppointmentObject *co;
|
|
|
|
SoSecurityManager *sm;
|
|
|
|
NSException *ex;
|
2008-11-26 17:26:32 +01:00
|
|
|
NSString *aOwner;
|
2008-08-10 23:44:25 +02:00
|
|
|
|
2008-11-26 17:26:32 +01:00
|
|
|
// See A.
|
2008-08-10 23:44:25 +02:00
|
|
|
co = [self clientObject];
|
2008-11-26 17:26:32 +01:00
|
|
|
|
|
|
|
if (componentCalendar)
|
|
|
|
{
|
|
|
|
aOwner = [componentCalendar ownerInContext: context];
|
|
|
|
|
|
|
|
// See B.
|
|
|
|
if (![aOwner isEqualToString: [[context activeUser] login]])
|
|
|
|
{
|
|
|
|
co = [componentCalendar lookupName: [co nameInContainer]
|
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We save the component
|
2008-08-10 23:44:25 +02:00
|
|
|
[co saveComponent: event];
|
|
|
|
|
2008-11-26 17:26:32 +01:00
|
|
|
// See C.
|
2008-08-22 08:44:27 +02:00
|
|
|
if (componentCalendar)
|
2008-08-10 23:44:25 +02:00
|
|
|
{
|
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
|
|
|
|
2008-11-03 15:17:57 +01:00
|
|
|
if ([co isKindOfClass: [SOGoAppointmentOccurence class]])
|
|
|
|
co = [co container];
|
2008-08-10 23:44:25 +02:00
|
|
|
thisFolder = [co container];
|
2008-08-22 08:44:27 +02:00
|
|
|
if (componentCalendar != thisFolder)
|
|
|
|
if (![sm validatePermission: SoPerm_DeleteObjects
|
|
|
|
onObject: thisFolder
|
|
|
|
inContext: context])
|
|
|
|
{
|
|
|
|
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
|
|
|
onObject: componentCalendar
|
|
|
|
inContext: context])
|
2008-08-25 21:13:18 +02:00
|
|
|
ex = [co moveToFolder: componentCalendar]; // TODO: handle exception
|
2008-08-22 08:44:27 +02:00
|
|
|
}
|
2008-08-10 23:44:25 +02:00
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2007-06-11 23:25:43 +02:00
|
|
|
return [self jsCloseWithRefreshMethod: @"refreshEventsAndDisplay()"];
|
2006-10-11 20:56:04 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
- (id <WOActionResults>) viewAction
|
|
|
|
{
|
2008-08-19 16:48:30 +02:00
|
|
|
WOResponse *result;
|
2008-08-19 00:45:59 +02:00
|
|
|
NSDictionary *data;
|
|
|
|
SOGoAppointmentFolder *co;
|
|
|
|
SOGoDateFormatter *dateFormatter;
|
|
|
|
SOGoUser *user;
|
2008-08-19 16:48:30 +02:00
|
|
|
NSCalendarDate *startDate;
|
2008-08-19 00:45:59 +02:00
|
|
|
|
|
|
|
result = [context response];
|
|
|
|
user = [context activeUser];
|
|
|
|
co = [self clientObject];
|
|
|
|
dateFormatter = [user dateFormatterInContext: context];
|
2008-08-19 16:48:30 +02:00
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
[self event];
|
2008-08-19 16:48:30 +02:00
|
|
|
startDate = [[event startDate] copy];
|
|
|
|
[startDate setTimeZone: [user timeZone]];
|
2008-08-19 00:45:59 +02:00
|
|
|
|
|
|
|
data = [NSDictionary dictionaryWithObjectsAndKeys:
|
2008-08-19 16:48:30 +02:00
|
|
|
[dateFormatter formattedDate: startDate], @"startDate",
|
|
|
|
[dateFormatter formattedTime: startDate], @"startTime",
|
|
|
|
([event hasRecurrenceRules]? @"1": @"0"), @"isReccurent",
|
|
|
|
([event isAllDay] ? @"1": @"0"), @"isAllDay",
|
2008-08-19 00:45:59 +02:00
|
|
|
[event summary], @"summary",
|
|
|
|
[event location], @"location",
|
|
|
|
[event comment], @"description",
|
|
|
|
nil];
|
2008-08-19 16:48:30 +02:00
|
|
|
[result appendContentString: [data jsonRepresentation]];
|
|
|
|
[startDate release];
|
2008-08-19 00:45:59 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
|
|
|
inContext: (WOContext*) context
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-08-24 00:13:12 +02:00
|
|
|
NSString *actionName;
|
|
|
|
|
|
|
|
actionName = [[request requestHandlerPath] lastPathComponent];
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
return ([[self clientObject] conformsToProtocol: @protocol (SOGoComponentOccurence)]
|
2007-08-24 00:13:12 +02:00
|
|
|
&& [actionName hasPrefix: @"save"]);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) takeValuesFromRequest: (WORequest *) _rq
|
|
|
|
inContext: (WOContext *) _ctx
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
SOGoAppointmentObject *clientObject;
|
2007-06-07 20:12:20 +02:00
|
|
|
int nbrDays;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
clientObject = [self clientObject];
|
2007-11-26 18:40:44 +01:00
|
|
|
[self event];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
[super takeValuesFromRequest: _rq inContext: _ctx];
|
|
|
|
|
2007-06-07 20:12:20 +02:00
|
|
|
if (isAllDay)
|
|
|
|
{
|
|
|
|
nbrDays = ((float) abs ([aptEndDate timeIntervalSinceDate: aptStartDate])
|
|
|
|
/ 86400) + 1;
|
|
|
|
[event setAllDayWithStartDate: aptStartDate
|
|
|
|
duration: nbrDays];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[event setStartDate: aptStartDate];
|
|
|
|
[event setEndDate: aptEndDate];
|
|
|
|
}
|
2008-11-06 18:19:14 +01:00
|
|
|
|
2008-12-01 23:46:31 +01:00
|
|
|
[event setTransparency: (isTransparent? @"TRANSPARENT" : @"OPAQUE")];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 20:19:44 +01:00
|
|
|
// TODO: add tentatively
|
|
|
|
|
2007-11-18 11:16:25 +01:00
|
|
|
- (id) acceptAction
|
2007-03-18 20:19:44 +01:00
|
|
|
{
|
2007-11-18 11:16:25 +01:00
|
|
|
[[self clientObject] changeParticipationStatus: @"ACCEPTED"];
|
2007-03-18 20:19:44 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2007-03-21 15:29:31 +01:00
|
|
|
- (id) declineAction
|
|
|
|
{
|
2007-11-18 11:16:25 +01:00
|
|
|
[[self clientObject] changeParticipationStatus: @"DECLINED"];
|
|
|
|
|
|
|
|
return self;
|
2007-03-21 15:29:31 +01:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
@end
|