2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo 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 Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-09-28 19:26:02 +02:00
|
|
|
#import <NGCards/NSString+NGCards.h>
|
2006-10-05 01:15:25 +02:00
|
|
|
#import <NGCards/NSCalendarDate+NGCards.h>
|
2006-09-28 19:26:02 +02:00
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
#import <SOGo/AgenorUserManager.h>
|
2006-10-05 01:15:25 +02:00
|
|
|
#import <SOGo/NSCalendarDate+SOGo.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-09-29 20:31:20 +02:00
|
|
|
#import "common.h"
|
|
|
|
#import <NGCards/NGCards.h>
|
|
|
|
#import <NGExtensions/NGCalendarDateRange.h>
|
|
|
|
#import <SOGoUI/SOGoDateFormatter.h>
|
|
|
|
#import <Appointments/SOGoAppointmentFolder.h>
|
|
|
|
#import <Appointments/SOGoAppointmentObject.h>
|
|
|
|
#import "UIxComponent+Agenor.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-10-12 18:42:59 +02:00
|
|
|
#import "UIxAppointmentEditor.h"
|
|
|
|
|
|
|
|
/* TODO: CLEAN UP */
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@implementation UIxAppointmentEditor
|
|
|
|
|
|
|
|
+ (int)version {
|
|
|
|
return [super version] + 0 /* v2 */;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void)initialize {
|
|
|
|
NSAssert2([super version] == 2,
|
|
|
|
@"invalid superclass (%@) version %i !",
|
|
|
|
NSStringFromClass([self superclass]), [super version]);
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2006-09-07 00:31:38 +02:00
|
|
|
[endDate release];
|
2006-06-15 21:34:10 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) setAptStartDate: (NSCalendarDate *)_date
|
|
|
|
{
|
|
|
|
[self setStartDate: _date];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (NSCalendarDate *) aptStartDate
|
|
|
|
{
|
|
|
|
return [self startDate];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) setAptEndDate: (NSCalendarDate *) _date
|
|
|
|
{
|
2006-09-07 00:31:38 +02:00
|
|
|
ASSIGN(endDate, _date);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (NSCalendarDate *) aptEndDate
|
|
|
|
{
|
|
|
|
return endDate;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* transparency */
|
|
|
|
|
2006-10-26 02:17:27 +02:00
|
|
|
- (NSString *) transparency
|
|
|
|
{
|
|
|
|
return @"OPAQUE";
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* iCal */
|
|
|
|
|
|
|
|
- (NSString *)iCalStringTemplate {
|
|
|
|
static NSString *iCalStringTemplate = \
|
|
|
|
@"BEGIN:VCALENDAR\r\n"
|
|
|
|
@"METHOD:REQUEST\r\n"
|
2006-10-26 02:17:27 +02:00
|
|
|
@"PRODID://Inverse groupe conseil/SOGo 0.9\r\n"
|
2006-06-15 21:34:10 +02:00
|
|
|
@"VERSION:2.0\r\n"
|
|
|
|
@"BEGIN:VEVENT\r\n"
|
|
|
|
@"UID:%@\r\n"
|
|
|
|
@"CLASS:PUBLIC\r\n"
|
|
|
|
@"STATUS:CONFIRMED\r\n" /* confirmed by default */
|
2006-10-06 01:28:18 +02:00
|
|
|
@"DTSTAMP:%@Z\r\n"
|
2006-10-12 23:45:03 +02:00
|
|
|
@"DTSTART:%@Z\r\n"
|
|
|
|
@"DTEND:%@Z\r\n"
|
2006-06-15 21:34:10 +02:00
|
|
|
@"TRANSP:%@\r\n"
|
|
|
|
@"SEQUENCE:1\r\n"
|
|
|
|
@"PRIORITY:5\r\n"
|
|
|
|
@"%@" /* organizer */
|
|
|
|
@"%@" /* participants and resources */
|
|
|
|
@"END:VEVENT\r\n"
|
|
|
|
@"END:VCALENDAR";
|
|
|
|
|
2006-10-12 23:45:03 +02:00
|
|
|
NSTimeZone *utc;
|
2006-10-06 01:28:18 +02:00
|
|
|
NSCalendarDate *lStartDate, *lEndDate, *stamp;
|
2006-09-07 00:31:38 +02:00
|
|
|
NSString *template, *s;
|
|
|
|
unsigned minutes;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
s = [self queryParameterForKey:@"dur"];
|
2006-11-07 17:27:46 +01:00
|
|
|
if ([s length] > 0)
|
2006-06-15 21:34:10 +02:00
|
|
|
minutes = [s intValue];
|
2006-11-07 17:27:46 +01:00
|
|
|
else
|
2006-06-15 21:34:10 +02:00
|
|
|
minutes = 60;
|
2006-10-12 23:45:03 +02:00
|
|
|
|
|
|
|
utc = [NSTimeZone timeZoneWithName: @"GMT"];
|
2006-11-07 17:27:46 +01:00
|
|
|
lStartDate = [self newStartDate];
|
2006-10-12 23:45:03 +02:00
|
|
|
[lStartDate setTimeZone: utc];
|
2006-11-07 17:27:46 +01:00
|
|
|
lEndDate = [lStartDate dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: minutes seconds: 0];
|
2006-10-06 01:28:18 +02:00
|
|
|
|
|
|
|
stamp = [NSCalendarDate calendarDate];
|
2006-10-12 23:45:03 +02:00
|
|
|
[stamp setTimeZone: utc];
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
s = [self iCalParticipantsAndResourcesStringFromQueryParameters];
|
|
|
|
template = [NSString stringWithFormat:iCalStringTemplate,
|
2006-08-31 01:11:50 +02:00
|
|
|
[[self clientObject] nameInContainer],
|
2006-10-06 01:28:18 +02:00
|
|
|
[stamp iCalFormattedDateTimeString],
|
|
|
|
[lStartDate iCalFormattedDateTimeString],
|
|
|
|
[lEndDate iCalFormattedDateTimeString],
|
2006-08-31 01:11:50 +02:00
|
|
|
[self transparency],
|
|
|
|
[self iCalOrganizerString],
|
|
|
|
s];
|
2006-06-15 21:34:10 +02:00
|
|
|
return template;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* new */
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id) newAction
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
This method creates a unique ID and redirects to the "edit" method on the
|
|
|
|
new ID.
|
|
|
|
It is actually a folder method and should be defined on the folder.
|
|
|
|
|
|
|
|
Note: 'clientObject' is the SOGoAppointmentFolder!
|
|
|
|
Update: remember that there are group folders as well.
|
|
|
|
*/
|
|
|
|
NSString *uri, *objectId, *method, *ps;
|
|
|
|
|
|
|
|
objectId = [NSClassFromString(@"SOGoAppointmentFolder")
|
|
|
|
globallyUniqueObjectId];
|
|
|
|
if ([objectId length] == 0) {
|
|
|
|
return [NSException exceptionWithHTTPStatus:500 /* Internal Error */
|
|
|
|
reason:@"could not create a unique ID"];
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:56:04 +02:00
|
|
|
method = [NSString stringWithFormat:@"Calendar/%@/editAsAppointment", objectId];
|
2006-06-15 21:34:10 +02:00
|
|
|
method = [[self userFolderPath] stringByAppendingPathComponent:method];
|
|
|
|
|
|
|
|
/* check if participants have already been provided */
|
2006-08-14 22:43:55 +02:00
|
|
|
ps = [self queryParameterForKey:@"ps"];
|
|
|
|
// if (ps) {
|
|
|
|
// [self setQueryParameter:ps forKey:@"ps"];
|
|
|
|
// }
|
|
|
|
if (!ps
|
|
|
|
&& [[self clientObject] respondsToSelector:@selector(calendarUIDs)]) {
|
2006-06-15 21:34:10 +02:00
|
|
|
AgenorUserManager *um;
|
2006-09-07 00:31:38 +02:00
|
|
|
NSArray *uids;
|
|
|
|
NSMutableArray *emails;
|
|
|
|
unsigned i, count;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/* add all current calendarUIDs as default participants */
|
|
|
|
|
|
|
|
um = [AgenorUserManager sharedUserManager];
|
|
|
|
uids = [[self clientObject] calendarUIDs];
|
|
|
|
count = [uids count];
|
|
|
|
emails = [NSMutableArray arrayWithCapacity:count];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
NSString *email;
|
|
|
|
|
|
|
|
email = [um getEmailForUID:[uids objectAtIndex:i]];
|
|
|
|
if (email)
|
|
|
|
[emails addObject:email];
|
|
|
|
}
|
|
|
|
ps = [emails componentsJoinedByString:@","];
|
|
|
|
[self setQueryParameter:ps forKey:@"ps"];
|
|
|
|
}
|
|
|
|
uri = [self completeHrefForMethod:method];
|
|
|
|
return [self redirectToLocation:uri];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save */
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) loadValuesFromAppointment: (iCalEvent *) appointment
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
2006-10-05 01:15:25 +02:00
|
|
|
NSTimeZone *uTZ;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
[self loadValuesFromComponent: appointment];
|
2006-10-05 01:15:25 +02:00
|
|
|
|
|
|
|
uTZ = [[self clientObject] userTimeZone];
|
2006-10-18 16:42:44 +02:00
|
|
|
endDate = [appointment endDate];
|
|
|
|
if (!endDate)
|
|
|
|
endDate = [[self startDate] dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 1 minutes: 0 seconds: 0];
|
|
|
|
|
2006-10-05 01:15:25 +02:00
|
|
|
[endDate setTimeZone: uTZ];
|
|
|
|
[endDate retain];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-23 23:34:56 +02:00
|
|
|
- (void) saveValuesIntoAppointment: (iCalEvent *) _appointment
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* merge in form values */
|
|
|
|
NSArray *attendees, *lResources;
|
2006-09-28 19:26:02 +02:00
|
|
|
iCalRecurrenceRule *rrule;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
[_appointment setStartDate:[self aptStartDate]];
|
|
|
|
[_appointment setEndDate:[self aptEndDate]];
|
2006-09-07 00:31:38 +02:00
|
|
|
|
|
|
|
[_appointment setSummary: [self title]];
|
2006-10-23 23:34:56 +02:00
|
|
|
[_appointment setUrl: [self url]];
|
2006-09-07 00:31:38 +02:00
|
|
|
[_appointment setLocation: [self location]];
|
|
|
|
[_appointment setComment: [self comment]];
|
2006-06-15 21:34:10 +02:00
|
|
|
[_appointment setPriority:[self priority]];
|
2006-11-03 20:38:08 +01:00
|
|
|
[_appointment setAccessClass: [self privacy]];
|
|
|
|
[_appointment setStatus: [self status]];
|
|
|
|
|
2006-11-03 22:18:03 +01:00
|
|
|
// [_appointment setCategories: [[self categories] componentsJoinedByString: @","]];
|
2006-10-26 02:17:27 +02:00
|
|
|
|
2006-10-23 23:34:56 +02:00
|
|
|
[_appointment setTransparency: [self transparency]];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
Note: bad, bad, bad!
|
|
|
|
Organizer is no form value, thus we MUST NOT change it
|
|
|
|
*/
|
2006-09-07 00:31:38 +02:00
|
|
|
[_appointment setOrganizer:organizer];
|
2006-06-15 21:34:10 +02:00
|
|
|
#endif
|
|
|
|
attendees = [self participants];
|
|
|
|
lResources = [self resources];
|
|
|
|
if ([lResources count] > 0) {
|
|
|
|
attendees = ([attendees count] > 0)
|
2006-11-01 22:58:43 +01:00
|
|
|
? [attendees arrayByAddingObjectsFromArray: lResources]
|
2006-06-15 21:34:10 +02:00
|
|
|
: lResources;
|
|
|
|
}
|
2006-09-28 19:26:02 +02:00
|
|
|
[attendees makeObjectsPerformSelector: @selector (setTag:)
|
|
|
|
withObject: @"attendee"];
|
2006-11-01 22:58:43 +01:00
|
|
|
[_appointment setAttendees: attendees];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/* cycles */
|
2006-09-28 19:26:02 +02:00
|
|
|
[_appointment removeAllRecurrenceRules];
|
|
|
|
rrule = [self rrule];
|
|
|
|
if (rrule)
|
|
|
|
[_appointment addToRecurrenceRules: rrule];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-09-28 19:26:02 +02:00
|
|
|
- (iCalEvent *) appointmentFromString: (NSString *) _iCalString
|
|
|
|
{
|
|
|
|
iCalCalendar *calendar;
|
|
|
|
iCalEvent *appointment;
|
|
|
|
SOGoAppointmentObject *clientObject;
|
|
|
|
|
|
|
|
clientObject = [self clientObject];
|
2006-09-29 20:31:20 +02:00
|
|
|
calendar = [iCalCalendar parseSingleFromSource: _iCalString];
|
2006-09-28 19:26:02 +02:00
|
|
|
appointment = [clientObject firstEventFromCalendar: calendar];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-09-28 19:26:02 +02:00
|
|
|
return appointment;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* conflict management */
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (BOOL) containsConflict: (id) _apt
|
|
|
|
{
|
2006-09-07 00:31:38 +02:00
|
|
|
NSArray *attendees, *uids;
|
2006-06-15 21:34:10 +02:00
|
|
|
SOGoAppointmentFolder *groupCalendar;
|
2006-09-07 00:31:38 +02:00
|
|
|
NSArray *infos;
|
|
|
|
NSArray *ranges;
|
|
|
|
id folder;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
[self logWithFormat:@"search from %@ to %@",
|
|
|
|
[_apt startDate], [_apt endDate]];
|
|
|
|
|
|
|
|
folder = [[self clientObject] container];
|
|
|
|
attendees = [_apt attendees];
|
|
|
|
uids = [folder uidsFromICalPersons:attendees];
|
|
|
|
if ([uids count] == 0) {
|
|
|
|
[self logWithFormat:@"Note: no UIDs selected."];
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
groupCalendar = [folder lookupGroupCalendarFolderForUIDs:uids
|
|
|
|
inContext:[self context]];
|
|
|
|
[self debugWithFormat:@"group calendar: %@", groupCalendar];
|
|
|
|
|
|
|
|
if (![groupCalendar respondsToSelector:@selector(fetchFreebusyInfosFrom:to:)]) {
|
|
|
|
[self errorWithFormat:@"invalid folder to run freebusy query on!"];
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
infos = [groupCalendar fetchFreebusyInfosFrom:[_apt startDate]
|
|
|
|
to:[_apt endDate]];
|
|
|
|
[self debugWithFormat:@" process: %d events", [infos count]];
|
|
|
|
|
2006-10-12 18:42:59 +02:00
|
|
|
ranges = [infos arrayByCreatingDateRangesFromObjectsWithStartDateKey: @"startDate"
|
|
|
|
andEndDateKey: @"endDate"];
|
2006-06-15 21:34:10 +02:00
|
|
|
ranges = [ranges arrayByCompactingContainedDateRanges];
|
|
|
|
[self debugWithFormat:@" blocked ranges: %@", ranges];
|
|
|
|
|
|
|
|
return [ranges count] != 0 ? YES : NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actions */
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id) testAction
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* for testing only */
|
2006-09-07 00:31:38 +02:00
|
|
|
WORequest *req;
|
2006-09-28 19:26:02 +02:00
|
|
|
iCalEvent *apt;
|
2006-09-07 00:31:38 +02:00
|
|
|
NSString *content;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
req = [[self context] request];
|
2006-09-28 19:26:02 +02:00
|
|
|
apt = [self appointmentFromString: [self iCalString]];
|
2006-06-15 21:34:10 +02:00
|
|
|
[self saveValuesIntoAppointment:apt];
|
2006-09-28 19:26:02 +02:00
|
|
|
content = [[apt parent] versitString];
|
2006-06-15 21:34:10 +02:00
|
|
|
[self logWithFormat:@"%s -- iCal:\n%@",
|
|
|
|
__PRETTY_FUNCTION__,
|
|
|
|
content];
|
2006-09-28 19:26:02 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id<WOActionResults>) defaultAction
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NSString *ical;
|
|
|
|
|
|
|
|
/* load iCalendar file */
|
|
|
|
|
|
|
|
// TODO: can't we use [clientObject contentAsString]?
|
2006-09-28 19:26:02 +02:00
|
|
|
// ical = [[self clientObject] valueForKey:@"iCalString"];
|
|
|
|
ical = [[self clientObject] contentAsString];
|
2006-06-15 21:34:10 +02:00
|
|
|
if ([ical length] == 0) /* a new appointment */
|
2006-10-18 16:42:44 +02:00
|
|
|
ical = [self iCalStringTemplate];
|
2006-11-07 17:27:46 +01:00
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
[self setICalString:ical];
|
2006-10-05 01:15:25 +02:00
|
|
|
[self loadValuesFromAppointment: [self appointmentFromString: ical]];
|
2006-11-07 17:27:46 +01:00
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
if (![self canEditComponent]) {
|
2006-06-15 21:34:10 +02:00
|
|
|
/* TODO: we need proper ACLs */
|
2006-10-18 16:42:44 +02:00
|
|
|
return [self redirectToLocation: [self completeURIForMethod: @"../view"]];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-10-12 18:42:59 +02:00
|
|
|
- (id <WOActionResults>) saveAction
|
|
|
|
{
|
2006-09-28 19:26:02 +02:00
|
|
|
iCalEvent *apt;
|
2006-09-07 00:31:38 +02:00
|
|
|
iCalPerson *p;
|
2006-10-12 18:42:59 +02:00
|
|
|
id <WOActionResults> result;
|
2006-09-07 00:31:38 +02:00
|
|
|
NSString *content;
|
|
|
|
NSException *ex;
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
if (![self isWriteableClientObject]) {
|
|
|
|
/* return 400 == Bad Request */
|
|
|
|
return [NSException exceptionWithHTTPStatus:400
|
|
|
|
reason:@"method cannot be invoked on "
|
|
|
|
@"the specified object"];
|
|
|
|
}
|
|
|
|
|
2006-09-28 19:26:02 +02:00
|
|
|
apt = [self appointmentFromString: [self iCalString]];
|
2006-06-15 21:34:10 +02:00
|
|
|
if (apt == nil) {
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
s = [self labelForKey:@"Invalid iCal data!"];
|
|
|
|
[self setErrorText:s];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
[self saveValuesIntoAppointment:apt];
|
|
|
|
p = [apt findParticipantWithEmail:[self emailForUser]];
|
|
|
|
if (p) {
|
|
|
|
[p setParticipationStatus:iCalPersonPartStatAccepted];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([self checkForConflicts]) {
|
|
|
|
if ([self containsConflict:apt]) {
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
s = [self labelForKey:@"Conflicts found!"];
|
|
|
|
[self setErrorText:s];
|
2006-09-28 19:26:02 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 19:26:02 +02:00
|
|
|
content = [[apt parent] versitString];
|
|
|
|
// [apt release]; apt = nil;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
if (content == nil) {
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
s = [self labelForKey:@"Could not create iCal data!"];
|
|
|
|
[self setErrorText:s];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
ex = [[self clientObject] saveContentString:content];
|
|
|
|
if (ex != nil) {
|
|
|
|
[self setErrorText:[ex reason]];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-10-12 18:42:59 +02:00
|
|
|
if ([[[[self context] request] formValueForKey: @"nojs"] intValue])
|
|
|
|
result = [self redirectToLocation: [self applicationPath]];
|
|
|
|
else
|
2006-10-18 23:47:27 +02:00
|
|
|
result = [self jsCloseWithRefreshMethod: @"refreshAppointmentsAndDisplay()"];
|
2006-10-12 18:42:59 +02:00
|
|
|
|
|
|
|
return result;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-11 20:56:04 +02:00
|
|
|
- (NSString *) saveUrl
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@/saveAsAppointment",
|
|
|
|
[[self clientObject] baseURL]];
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id) acceptAction
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return [self acceptOrDeclineAction:YES];
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id) declineAction
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return [self acceptOrDeclineAction:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: add tentatively
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id) acceptOrDeclineAction: (BOOL) _accept
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
// TODO: this should live in the SoObjects
|
|
|
|
NSException *ex;
|
|
|
|
|
|
|
|
if ((ex = [self validateObjectForStatusChange]) != nil)
|
|
|
|
return ex;
|
|
|
|
|
|
|
|
ex = [[self clientObject] changeParticipationStatus:
|
|
|
|
_accept ? @"ACCEPTED" : @"DECLINED"
|
|
|
|
inContext:[self context]];
|
|
|
|
if (ex != nil) return ex;
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
return [self redirectToLocation: [self completeURIForMethod: @"../view"]];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end /* UIxAppointmentEditor */
|