2007-03-18 16:20:38 +01:00
|
|
|
/* UIxAppointmentEditor.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Inverse groupe conseil
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
#import <NGObjWeb/SoObject.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#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
|
|
|
|
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
|
|
|
#import <SoObjects/SOGo/SOGoContentObject.h>
|
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentObject.h>
|
|
|
|
|
|
|
|
#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-10-09 19:19:20 +02:00
|
|
|
repeat = nil;
|
2007-06-07 20:12:20 +02:00
|
|
|
isAllDay = 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];
|
|
|
|
[repeat release];
|
|
|
|
[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)
|
|
|
|
{
|
2007-11-27 00:25:35 +01:00
|
|
|
event = (iCalEvent *) [[self clientObject] component: YES secure: YES];
|
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",
|
|
|
|
[[self clientObject] baseURL]];
|
|
|
|
}
|
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
|
|
|
|
|| (hm && [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
|
|
|
|
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
|
|
|
- (NSArray *) repeatList
|
2006-10-26 02:17:27 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
static NSArray *repeatItems = nil;
|
|
|
|
|
|
|
|
if (!repeatItems)
|
|
|
|
{
|
|
|
|
repeatItems = [NSArray arrayWithObjects: @"DAILY",
|
|
|
|
@"WEEKLY",
|
|
|
|
@"BI-WEEKLY",
|
|
|
|
@"EVERY WEEKDAY",
|
|
|
|
@"MONTHLY",
|
|
|
|
@"YEARLY",
|
|
|
|
@"-",
|
|
|
|
@"CUSTOM",
|
|
|
|
nil];
|
|
|
|
[repeatItems retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return repeatItems;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) itemRepeatText
|
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"-"])
|
|
|
|
text = item;
|
2006-11-07 17:27:46 +01:00
|
|
|
else
|
2007-03-18 16:20:38 +01:00
|
|
|
text = [self labelForKey: [NSString stringWithFormat: @"repeat_%@", item]];
|
|
|
|
|
|
|
|
return text;
|
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
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSArray *) reminderList
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
static NSArray *reminderItems = nil;
|
|
|
|
|
|
|
|
if (!reminderItems)
|
|
|
|
{
|
|
|
|
reminderItems = [NSArray arrayWithObjects: @"5_MINUTES_BEFORE",
|
|
|
|
@"10_MINUTES_BEFORE",
|
|
|
|
@"15_MINUTES_BEFORE",
|
|
|
|
@"30_MINUTES_BEFORE",
|
|
|
|
@"45_MINUTES_BEFORE",
|
|
|
|
@"-",
|
|
|
|
@"1_HOUR_BEFORE",
|
|
|
|
@"2_HOURS_BEFORE",
|
|
|
|
@"5_HOURS_BEFORE",
|
|
|
|
@"15_HOURS_BEFORE",
|
|
|
|
@"-",
|
|
|
|
@"1_DAY_BEFORE",
|
|
|
|
@"2_DAYS_BEFORE",
|
|
|
|
@"1_WEEK_BEFORE",
|
|
|
|
@"-",
|
|
|
|
@"CUSTOM",
|
|
|
|
nil];
|
|
|
|
[reminderItems retain];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
return reminderItems;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
// - (void) setReminder: (NSString *) reminder
|
|
|
|
// {
|
|
|
|
// ASSIGN(reminder, _reminder);
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
// - (NSString *) reminder
|
|
|
|
// {
|
|
|
|
// return reminder;
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-17 16:53:21 +02:00
|
|
|
- (NSString *) reminder
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setReminder: (NSString *) newReminder
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) itemReminderText
|
|
|
|
{
|
|
|
|
NSString *text;
|
2006-10-05 01:15:25 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([item isEqualToString: @"-"])
|
|
|
|
text = item;
|
|
|
|
else
|
|
|
|
text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", item]];
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
return text;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) repeat
|
2006-10-23 23:34:56 +02:00
|
|
|
{
|
2007-10-09 19:19:20 +02:00
|
|
|
return repeat;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setRepeat: (NSString *) newRepeat
|
2006-09-28 19:26:02 +02:00
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
ASSIGN (repeat, newRepeat);
|
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;
|
2007-03-18 16:20:38 +01:00
|
|
|
int hour;
|
|
|
|
|
|
|
|
newStartDate = [self selectedDate];
|
|
|
|
if ([[self queryParameterForKey: @"hm"] length] == 0)
|
|
|
|
{
|
|
|
|
now = [NSCalendarDate calendarDate];
|
2007-04-11 21:08:58 +02:00
|
|
|
timeZone = [[context activeUser] timeZone];
|
|
|
|
[now setTimeZone: timeZone];
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([now isDateOnSameDay: newStartDate])
|
|
|
|
{
|
|
|
|
hour = [now hourOfDay];
|
|
|
|
if (hour < 8)
|
|
|
|
newStartDate = [now hour: 8 minute: 0];
|
|
|
|
else if (hour > 18)
|
|
|
|
newStartDate = [[now tomorrow] hour: 8 minute: 0];
|
|
|
|
else
|
|
|
|
newStartDate = now;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
newStartDate = [newStartDate hour: 8 minute: 0];
|
|
|
|
}
|
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;
|
|
|
|
NSString *duration;
|
|
|
|
unsigned int minutes;
|
2007-10-17 16:53:21 +02:00
|
|
|
iCalRecurrenceRule *rule;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2007-11-26 18:40:44 +01:00
|
|
|
[self event];
|
2007-11-27 17:00:18 +01:00
|
|
|
if ([[self clientObject] isNew])
|
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];
|
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
ASSIGN (aptStartDate, startDate);
|
|
|
|
ASSIGN (aptEndDate, endDate);
|
|
|
|
|
2007-10-09 19:19:20 +02:00
|
|
|
// We initialize our repeat ivars
|
|
|
|
if ([event hasRecurrenceRules])
|
|
|
|
{
|
|
|
|
repeat = @"CUSTOM";
|
|
|
|
|
|
|
|
rule = [[event recurrenceRules] lastObject];
|
|
|
|
|
|
|
|
if ([rule frequency] == iCalRecurrenceFrequenceWeekly)
|
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
if ([rule repeatInterval] == 1)
|
|
|
|
repeat = @"WEEKLY";
|
|
|
|
else if ([rule repeatInterval] == 2)
|
|
|
|
repeat = @"BI-WEEKLY";
|
2007-10-09 19:19:20 +02:00
|
|
|
}
|
|
|
|
else if ([rule frequency] == iCalRecurrenceFrequenceDaily)
|
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
if ([rule byDayMask] == (iCalWeekDayMonday
|
|
|
|
| iCalWeekDayTuesday
|
|
|
|
| iCalWeekDayWednesday
|
|
|
|
| iCalWeekDayThursday
|
|
|
|
| iCalWeekDayFriday))
|
|
|
|
repeat = @"EVERY WEEKDAY";
|
|
|
|
else if (![rule byDayMask])
|
|
|
|
repeat = @"DAILY";
|
2007-10-09 19:19:20 +02:00
|
|
|
}
|
2007-10-17 16:53:21 +02:00
|
|
|
else if ([rule frequency] == iCalRecurrenceFrequenceMonthly
|
|
|
|
&& [rule repeatInterval] == 1)
|
|
|
|
repeat = @"MONTHLY";
|
|
|
|
else if ([rule frequency] == iCalRecurrenceFrequenceYearly
|
|
|
|
&& [rule repeatInterval] == 1)
|
|
|
|
repeat = @"YEARLY";
|
2007-10-09 19:19:20 +02:00
|
|
|
}
|
|
|
|
else
|
2007-10-17 16:53:21 +02:00
|
|
|
DESTROY(repeat);
|
2007-03-18 16:20:38 +01:00
|
|
|
|
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;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
co = [self clientObject];
|
|
|
|
objectId = [co globallyUniqueObjectId];
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([objectId length] > 0)
|
|
|
|
{
|
2007-12-05 23:29:50 +01:00
|
|
|
method = [NSString stringWithFormat:@"%@/%@.ics/editAsAppointment",
|
2007-09-15 00:01:02 +02:00
|
|
|
[co soURL], 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
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (id <WOActionResults>) saveAction
|
2006-10-11 20:56:04 +02:00
|
|
|
{
|
2007-11-18 11:16:25 +01:00
|
|
|
[[self clientObject] saveComponent: event];
|
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
|
|
|
}
|
|
|
|
|
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];
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
return ([[self clientObject] isKindOfClass: [SOGoAppointmentObject class]]
|
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;
|
2007-10-17 16:53:21 +02:00
|
|
|
iCalRecurrenceRule *rule;
|
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];
|
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
if ([clientObject isNew])
|
|
|
|
[event setTransparency: @"OPAQUE"];
|
2007-10-09 19:19:20 +02:00
|
|
|
|
|
|
|
// We remove any repeat rules
|
|
|
|
if (!repeat && [event hasRecurrenceRules])
|
2007-10-17 16:53:21 +02:00
|
|
|
[event removeAllRecurrenceRules];
|
|
|
|
else if (!([repeat caseInsensitiveCompare: @"-"] == NSOrderedSame
|
|
|
|
|| [repeat caseInsensitiveCompare: @"CUSTOM"] == NSOrderedSame))
|
2007-10-09 19:19:20 +02:00
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
rule = [iCalRecurrenceRule new];
|
2007-10-09 19:19:20 +02:00
|
|
|
|
2007-10-17 16:53:21 +02:00
|
|
|
[rule setInterval: @"1"];
|
2007-10-09 19:19:20 +02:00
|
|
|
if ([repeat caseInsensitiveCompare: @"BI-WEEKLY"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
[rule setFrequency: iCalRecurrenceFrequenceWeekly];
|
|
|
|
[rule setInterval: @"2"];
|
|
|
|
}
|
|
|
|
else if ([repeat caseInsensitiveCompare: @"EVERY WEEKDAY"] == NSOrderedSame)
|
|
|
|
{
|
2007-10-17 16:53:21 +02:00
|
|
|
[rule setByDayMask: (iCalWeekDayMonday
|
|
|
|
|iCalWeekDayTuesday
|
|
|
|
|iCalWeekDayWednesday
|
|
|
|
|iCalWeekDayThursday
|
|
|
|
|iCalWeekDayFriday)];
|
2007-10-09 19:19:20 +02:00
|
|
|
[rule setFrequency: iCalRecurrenceFrequenceDaily];
|
|
|
|
}
|
2007-11-03 22:16:59 +01:00
|
|
|
else if ([repeat caseInsensitiveCompare: @"MONTHLY"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
[rule setNamedValue: @"bymonthday"
|
|
|
|
to: [NSString stringWithFormat: @"%d", [aptStartDate dayOfMonth]]];
|
|
|
|
[rule setFrequency: iCalRecurrenceFrequenceMonthly];
|
|
|
|
}
|
2007-10-09 19:19:20 +02:00
|
|
|
else
|
2007-10-17 16:53:21 +02:00
|
|
|
[rule setFrequency:
|
|
|
|
(iCalRecurrenceFrequency) [rule valueForFrequency: repeat]];
|
2007-10-09 19:19:20 +02:00
|
|
|
[event setRecurrenceRules: [NSArray arrayWithObject: rule]];
|
2007-10-17 16:53:21 +02:00
|
|
|
[rule release];
|
2007-10-09 19:19:20 +02:00
|
|
|
}
|
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
|