2006-10-18 16:42:44 +02:00
|
|
|
/* UIxComponentEditor.m - this file is part of SOGo
|
|
|
|
*
|
2009-04-21 16:34:22 +02:00
|
|
|
* Copyright (C) 2006-2009 Inverse inc.
|
2006-10-18 16:42:44 +02: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSBundle.h>
|
2008-07-04 18:06:09 +02:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2007-04-11 21:38:06 +02:00
|
|
|
#import <Foundation/NSKeyValueCoding.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
#import <Foundation/NSString.h>
|
2009-07-27 14:48:27 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2006-10-19 16:35:50 +02:00
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2006-10-23 23:34:56 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
#import <NGCards/iCalAlarm.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
#import <NGCards/iCalPerson.h>
|
|
|
|
#import <NGCards/iCalRepeatableEntityObject.h>
|
|
|
|
#import <NGCards/iCalRecurrenceRule.h>
|
2009-04-21 16:34:22 +02:00
|
|
|
#import <NGCards/iCalTrigger.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
#import <NGCards/NSString+NGCards.h>
|
|
|
|
#import <NGCards/NSCalendarDate+NGCards.h>
|
2007-06-01 23:01:44 +02:00
|
|
|
#import <NGObjWeb/SoSecurityManager.h>
|
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2009-01-07 19:32:24 +01:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
2007-06-01 23:01:44 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <NGExtensions/NSString+misc.h>
|
|
|
|
|
2007-11-19 17:37:20 +01:00
|
|
|
#import <SoObjects/Appointments/iCalEntityObject+SOGo.h>
|
2007-11-18 11:16:25 +01:00
|
|
|
#import <SoObjects/Appointments/iCalPerson+SOGo.h>
|
2007-04-02 21:27:46 +02:00
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
2007-09-15 00:01:02 +02:00
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolders.h>
|
2006-11-07 19:15:29 +01:00
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentObject.h>
|
2009-07-23 22:11:06 +02:00
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentOccurence.h>
|
2006-11-07 19:15:29 +01:00
|
|
|
#import <SoObjects/Appointments/SOGoTaskObject.h>
|
2007-11-19 17:37:20 +01:00
|
|
|
#import <SoObjects/SOGo/iCalEntityObject+Utilities.h>
|
2007-11-15 20:02:23 +01:00
|
|
|
#import <SoObjects/SOGo/LDAPUserManager.h>
|
2009-07-15 21:28:20 +02:00
|
|
|
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
2007-11-19 22:07:54 +01:00
|
|
|
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
2007-04-11 21:34:24 +02:00
|
|
|
#import <SoObjects/SOGo/NSString+Utilities.h>
|
2007-06-01 23:01:44 +02:00
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
|
|
|
#import <SoObjects/SOGo/SOGoPermissions.h>
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
#import "../../Main/SOGo.h"
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
#import "UIxComponentEditor.h"
|
2009-01-07 22:01:16 +01:00
|
|
|
#import "UIxDatePicker.h"
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
static NSArray *reminderItems = nil;
|
|
|
|
static NSArray *reminderValues = nil;
|
|
|
|
|
2008-02-08 18:10:20 +01:00
|
|
|
#define iREPEAT(X) \
|
|
|
|
- (NSString *) repeat##X; \
|
|
|
|
- (void) setRepeat##X: (NSString *) theValue
|
|
|
|
|
|
|
|
#define iRANGE(X) \
|
|
|
|
- (NSString *) range##X; \
|
|
|
|
- (void) setRange##X: (NSString *) theValue
|
|
|
|
|
2009-01-07 22:01:16 +01:00
|
|
|
|
2008-02-08 18:10:20 +01:00
|
|
|
@interface UIxComponentEditor (Private)
|
|
|
|
|
|
|
|
iREPEAT(1);
|
|
|
|
iREPEAT(2);
|
|
|
|
iREPEAT(3);
|
|
|
|
iREPEAT(4);
|
|
|
|
iREPEAT(5);
|
|
|
|
iREPEAT(6);
|
|
|
|
iREPEAT(7);
|
|
|
|
iRANGE(1);
|
|
|
|
iRANGE(2);
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
#define REPEAT(X) \
|
|
|
|
- (NSString *) repeat##X { return repeat##X; } \
|
2008-11-05 22:04:16 +01:00
|
|
|
- (void) setRepeat##X: (NSString *) theValue { ASSIGN(repeat##X, theValue); } \
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
#define RANGE(X) \
|
|
|
|
- (NSString *) range##X { return range##X; } \
|
|
|
|
- (void) setRange##X: (NSString *) theValue { ASSIGN(range##X, theValue); }
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
@implementation UIxComponentEditor
|
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (!reminderItems && !reminderValues)
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
reminderValues = [NSArray arrayWithObjects:
|
|
|
|
@"-PT5M",
|
|
|
|
@"-PT10M",
|
|
|
|
@"-PT15M",
|
|
|
|
@"-PT30M",
|
|
|
|
@"-PT45M",
|
|
|
|
@"",
|
|
|
|
@"-PT1H",
|
|
|
|
@"-PT2H",
|
|
|
|
@"-PT5H",
|
|
|
|
@"-PT15H",
|
|
|
|
@"",
|
|
|
|
@"-P1D",
|
|
|
|
@"-P2D",
|
|
|
|
@"-P1W",
|
|
|
|
@"",
|
|
|
|
@"",
|
|
|
|
nil];
|
|
|
|
|
|
|
|
[reminderItems retain];
|
|
|
|
[reminderValues retain];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
2009-03-24 21:11:18 +01:00
|
|
|
UIxDatePicker *datePicker;
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2009-01-07 22:01:16 +01:00
|
|
|
// We must instanciate a UIxDatePicker object to retrieve
|
|
|
|
// the proper date format to use.
|
|
|
|
datePicker = [[UIxDatePicker alloc] initWithContext: context];
|
|
|
|
dateFormat = [datePicker dateFormat];
|
2009-03-24 21:11:18 +01:00
|
|
|
[datePicker release];
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
component = nil;
|
2009-03-24 17:34:03 +01:00
|
|
|
componentCalendar = nil;
|
2006-11-03 20:38:08 +01:00
|
|
|
[self setPrivacy: @"PUBLIC"];
|
2006-10-18 16:42:44 +02:00
|
|
|
[self setIsCycleEndNever];
|
2006-10-19 16:35:50 +02:00
|
|
|
componentOwner = @"";
|
2007-03-19 00:52:08 +01:00
|
|
|
organizer = nil;
|
2008-11-05 22:04:16 +01:00
|
|
|
//organizerIdentity = nil;
|
2007-03-18 16:20:38 +01:00
|
|
|
attendeesNames = nil;
|
2007-11-15 20:02:23 +01:00
|
|
|
attendeesUIDs = nil;
|
2007-03-18 16:20:38 +01:00
|
|
|
attendeesEmails = nil;
|
2007-12-12 18:48:19 +01:00
|
|
|
attendeesStates = nil;
|
2007-04-02 21:27:46 +02:00
|
|
|
calendarList = nil;
|
2008-01-14 14:57:28 +01:00
|
|
|
repeat = nil;
|
|
|
|
reminder = nil;
|
2009-04-21 16:34:22 +02:00
|
|
|
reminderQuantity = nil;
|
|
|
|
reminderUnit = nil;
|
|
|
|
reminderRelation = nil;
|
|
|
|
reminderReference = nil;
|
2008-01-14 14:57:28 +01:00
|
|
|
repeatType = nil;
|
|
|
|
repeat1 = nil;
|
|
|
|
repeat2 = nil;
|
|
|
|
repeat3 = nil;
|
|
|
|
repeat4 = nil;
|
|
|
|
repeat5 = nil;
|
|
|
|
repeat6 = nil;
|
|
|
|
repeat7 = nil;
|
|
|
|
range1 = nil;
|
|
|
|
range2 = nil;
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[item release];
|
|
|
|
[cycleUntilDate release];
|
|
|
|
[title release];
|
|
|
|
[location release];
|
|
|
|
[organizer release];
|
2008-11-05 22:04:16 +01:00
|
|
|
//[organizerIdentity release];
|
2006-10-18 16:42:44 +02:00
|
|
|
[comment release];
|
|
|
|
[priority release];
|
|
|
|
[categories release];
|
|
|
|
[cycle release];
|
|
|
|
[cycleEnd release];
|
2009-07-07 23:17:43 +02:00
|
|
|
[attachUrl release];
|
2007-03-18 16:20:38 +01:00
|
|
|
[attendeesNames release];
|
2007-11-15 20:02:23 +01:00
|
|
|
[attendeesUIDs release];
|
2007-03-18 16:20:38 +01:00
|
|
|
[attendeesEmails release];
|
2007-12-12 18:48:19 +01:00
|
|
|
[attendeesStates release];
|
2007-04-02 21:27:46 +02:00
|
|
|
[calendarList release];
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
[reminder release];
|
2009-04-21 16:34:22 +02:00
|
|
|
[reminderQuantity release];
|
|
|
|
[reminderUnit release];
|
|
|
|
[reminderRelation release];
|
|
|
|
[reminderReference release];
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
[repeat release];
|
2008-01-14 14:57:28 +01:00
|
|
|
[repeatType release];
|
|
|
|
[repeat1 release];
|
|
|
|
[repeat2 release];
|
|
|
|
[repeat3 release];
|
|
|
|
[repeat4 release];
|
|
|
|
[repeat5 release];
|
|
|
|
[repeat6 release];
|
|
|
|
[repeat7 release];
|
|
|
|
[range1 release];
|
|
|
|
[range2 release];
|
2009-03-24 21:11:18 +01:00
|
|
|
|
2007-11-19 22:07:54 +01:00
|
|
|
[component release];
|
2009-03-24 17:34:03 +01:00
|
|
|
[componentCalendar release];
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) _loadAttendees
|
|
|
|
{
|
|
|
|
NSEnumerator *attendees;
|
|
|
|
iCalPerson *currentAttendee;
|
2007-12-12 18:48:19 +01:00
|
|
|
NSMutableString *names, *uids, *emails, *states;
|
2007-11-15 20:02:23 +01:00
|
|
|
NSString *uid;
|
|
|
|
LDAPUserManager *um;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2009-03-24 17:34:03 +01:00
|
|
|
names = [NSMutableString string];
|
|
|
|
uids = [NSMutableString string];
|
|
|
|
emails = [NSMutableString string];
|
|
|
|
states = [NSMutableString string];
|
2007-11-15 20:02:23 +01:00
|
|
|
um = [LDAPUserManager sharedUserManager];
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
attendees = [[component attendees] objectEnumerator];
|
2008-04-25 17:15:05 +02:00
|
|
|
while ((currentAttendee = [attendees nextObject]))
|
2007-03-18 16:20:38 +01:00
|
|
|
{
|
2008-11-23 16:26:14 +01:00
|
|
|
if ([[currentAttendee cn] length])
|
|
|
|
[names appendFormat: @"%@,", [currentAttendee cn]];
|
|
|
|
else
|
|
|
|
[names appendFormat: @"%@,", [currentAttendee rfc822Email]];
|
2009-03-24 21:11:18 +01:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
[emails appendFormat: @"%@,", [currentAttendee rfc822Email]];
|
2007-11-15 20:02:23 +01:00
|
|
|
uid = [um getUIDForEmail: [currentAttendee rfc822Email]];
|
|
|
|
if (uid != nil)
|
|
|
|
[uids appendFormat: @"%@,", uid];
|
|
|
|
else
|
|
|
|
[uids appendString: @","];
|
2008-04-25 17:15:05 +02:00
|
|
|
[states appendFormat: @"%@,",
|
|
|
|
[[currentAttendee partStat] lowercaseString]];
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ([names length] > 0)
|
|
|
|
{
|
|
|
|
ASSIGN (attendeesNames, [names substringToIndex: [names length] - 1]);
|
2007-11-15 20:02:23 +01:00
|
|
|
ASSIGN (attendeesUIDs, [uids substringToIndex: [uids length] - 1]);
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (attendeesEmails,
|
|
|
|
[emails substringToIndex: [emails length] - 1]);
|
2007-12-12 18:48:19 +01:00
|
|
|
ASSIGN (attendeesStates, [states substringToIndex: [states length] - 1]);
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-21 18:01:28 +02:00
|
|
|
- (void) _loadCategories
|
|
|
|
{
|
|
|
|
NSString *compCategories, *simpleCategory;
|
|
|
|
|
|
|
|
compCategories = [component categories];
|
|
|
|
if ([compCategories length] > 0)
|
|
|
|
{
|
|
|
|
simpleCategory = [[compCategories componentsSeparatedByString: @","]
|
|
|
|
objectAtIndex: 0];
|
2009-07-15 21:28:20 +02:00
|
|
|
ASSIGN (category, simpleCategory);
|
2007-08-21 18:01:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
- (NSString *) _dayMaskToInteger: (unsigned int) theMask
|
|
|
|
{
|
2008-03-27 15:12:03 +01:00
|
|
|
iCalWeekDay maskDays[] = {iCalWeekDaySunday, iCalWeekDayMonday,
|
|
|
|
iCalWeekDayTuesday, iCalWeekDayWednesday,
|
|
|
|
iCalWeekDayThursday, iCalWeekDayFriday,
|
|
|
|
iCalWeekDaySaturday};
|
2008-01-16 18:07:46 +01:00
|
|
|
unsigned int i;
|
2008-03-27 15:12:03 +01:00
|
|
|
NSMutableString *s;
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
s = [NSMutableString string];
|
|
|
|
|
2008-03-27 15:12:03 +01:00
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
if ((theMask & maskDays[i]))
|
|
|
|
[s appendFormat: @"%d,", i];
|
|
|
|
[s deleteSuffix: @","];
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _loadRRules
|
|
|
|
{
|
|
|
|
// We initialize our repeat ivars
|
|
|
|
if ([component hasRecurrenceRules])
|
|
|
|
{
|
|
|
|
iCalRecurrenceRule *rule;
|
|
|
|
|
|
|
|
[self setRepeat: @"CUSTOM"];
|
2008-01-15 22:45:48 +01:00
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
rule = [[component recurrenceRules] lastObject];
|
|
|
|
|
|
|
|
if ([rule frequency] == iCalRecurrenceFrequenceDaily)
|
|
|
|
{
|
|
|
|
repeatType = @"0";
|
|
|
|
|
|
|
|
if ([rule byDayMask] == (iCalWeekDayMonday
|
|
|
|
| iCalWeekDayTuesday
|
|
|
|
| iCalWeekDayWednesday
|
|
|
|
| iCalWeekDayThursday
|
|
|
|
| iCalWeekDayFriday))
|
|
|
|
{
|
|
|
|
if ([rule isInfinite])
|
2008-03-27 15:12:03 +01:00
|
|
|
repeat = @"EVERY WEEKDAY";
|
2008-01-14 14:57:28 +01:00
|
|
|
repeat1 = @"1";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
repeat1 = @"0";
|
|
|
|
|
2008-01-16 18:07:46 +01:00
|
|
|
if ([rule repeatInterval] == 1 && [rule isInfinite])
|
2008-03-27 15:12:03 +01:00
|
|
|
repeat = @"DAILY";
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
[self setRepeat2: [NSString stringWithFormat: @"%d", [rule repeatInterval]]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ([rule frequency] == iCalRecurrenceFrequenceWeekly)
|
|
|
|
{
|
|
|
|
repeatType = @"1";
|
|
|
|
|
|
|
|
if (![rule byDayMask])
|
|
|
|
{
|
|
|
|
if ([rule repeatInterval] == 1)
|
|
|
|
repeat = @"WEEKLY";
|
|
|
|
else if ([rule repeatInterval] == 2)
|
|
|
|
repeat = @"BI-WEEKLY";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self setRepeat1: [NSString stringWithFormat: @"%d", [rule repeatInterval]]];
|
|
|
|
[self setRepeat2: [self _dayMaskToInteger: [rule byDayMask]]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ([rule frequency] == iCalRecurrenceFrequenceMonthly)
|
|
|
|
{
|
|
|
|
repeatType = @"2";
|
|
|
|
|
|
|
|
if ([rule byDayMask])
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
[self setRepeat2: @"0"];
|
|
|
|
}
|
|
|
|
else if ([[rule byMonthDay] count])
|
|
|
|
{
|
|
|
|
[self setRepeat2: @"1"];
|
|
|
|
[self setRepeat5: [[rule byMonthDay] componentsJoinedByString: @","]];
|
|
|
|
}
|
|
|
|
else if ([rule repeatInterval] == 1)
|
|
|
|
repeat = @"MONTHLY";
|
|
|
|
|
|
|
|
[self setRepeat1: [NSString stringWithFormat: @"%d", [rule repeatInterval]]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
repeatType = @"3";
|
|
|
|
|
|
|
|
if ([rule namedValue: @"bymonth"])
|
|
|
|
{
|
|
|
|
if (![rule byDayMask])
|
|
|
|
{
|
|
|
|
[self setRepeat2: @"0"];
|
|
|
|
[self setRepeat3: [rule namedValue: @"bymonthday"]];
|
|
|
|
[self setRepeat4: [NSString stringWithFormat: @"%d", [[rule namedValue: @"bymonth"] intValue]-1]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
[self setRepeat2: @"1"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ([rule repeatInterval] == 1)
|
|
|
|
repeat = @"YEARLY";
|
|
|
|
|
|
|
|
[self setRepeat1: [NSString stringWithFormat: @"%d", [rule repeatInterval]]];
|
|
|
|
}
|
|
|
|
|
|
|
|
// We decode the proper end date, recurrences count, etc.
|
|
|
|
if ([rule repeatCount])
|
|
|
|
{
|
|
|
|
[self setRange1: @"1"];
|
|
|
|
[self setRange2: [rule namedValue: @"count"]];
|
|
|
|
}
|
|
|
|
else if ([rule untilDate])
|
|
|
|
{
|
2009-01-07 19:32:24 +01:00
|
|
|
NSCalendarDate *date;
|
2009-01-07 22:01:16 +01:00
|
|
|
|
2009-01-07 19:32:24 +01:00
|
|
|
date = [[rule untilDate] copy];
|
|
|
|
[date setTimeZone: [[context activeUser] timeZone]];
|
2008-01-14 14:57:28 +01:00
|
|
|
[self setRange1: @"2"];
|
2009-01-07 22:01:16 +01:00
|
|
|
[self setRange2: [date descriptionWithCalendarFormat: dateFormat]];
|
2009-01-07 19:40:25 +01:00
|
|
|
[date release];
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
else
|
2008-03-27 15:12:03 +01:00
|
|
|
[self setRange1: @"0"];
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
else
|
2009-03-24 21:11:18 +01:00
|
|
|
{
|
|
|
|
DESTROY(repeat);
|
|
|
|
repeatType = @"0";
|
|
|
|
repeat1 = @"0";
|
|
|
|
repeat2 = @"1";
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
- (void) _loadAlarms
|
|
|
|
{
|
|
|
|
if ([component hasAlarms])
|
|
|
|
{
|
|
|
|
// We currently have the following limitations for alarms:
|
|
|
|
// - only the first alarm is considered;
|
|
|
|
// - the alarm's action must be of type DISPLAY;
|
|
|
|
// - the alarm's trigger value type must be DURATION.
|
|
|
|
|
|
|
|
iCalAlarm *anAlarm;
|
|
|
|
iCalTrigger *aTrigger;
|
|
|
|
NSString *duration, *quantity;
|
|
|
|
unichar c;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
anAlarm = [[component alarms] objectAtIndex: 0];
|
|
|
|
aTrigger = [anAlarm trigger];
|
|
|
|
if ([[anAlarm action] caseInsensitiveCompare: @"DISPLAY"] == NSOrderedSame &&
|
|
|
|
[[aTrigger valueType] caseInsensitiveCompare: @"DURATION"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
duration = [aTrigger value];
|
|
|
|
i = [reminderValues indexOfObject: duration];
|
|
|
|
|
|
|
|
if (i == NSNotFound)
|
|
|
|
{
|
|
|
|
// Custom alarm
|
|
|
|
ASSIGN (reminder, @"CUSTOM");
|
|
|
|
ASSIGN (reminderRelation, [aTrigger relationType]);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
c = [duration characterAtIndex: i];
|
|
|
|
if (c == '-')
|
|
|
|
{
|
|
|
|
ASSIGN (reminderReference, @"BEFORE");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ASSIGN (reminderReference, @"AFTER");
|
|
|
|
}
|
|
|
|
|
|
|
|
c = [duration characterAtIndex: i];
|
|
|
|
if (c == 'P')
|
|
|
|
{
|
|
|
|
quantity = @"";
|
|
|
|
// Parse duration -- ignore first character (P)
|
|
|
|
for (i++; i < [duration length]; i++)
|
|
|
|
{
|
|
|
|
c = [duration characterAtIndex: i];
|
|
|
|
if (c == 't' || c == 'T')
|
|
|
|
// time -- ignore character
|
|
|
|
continue;
|
|
|
|
else if (isdigit (c))
|
|
|
|
quantity = [quantity stringByAppendingFormat: @"%c", c];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 'D': /* day */
|
|
|
|
ASSIGN (reminderUnit, @"DAYS");
|
|
|
|
break;
|
|
|
|
case 'H': /* hour */
|
|
|
|
ASSIGN (reminderUnit, @"HOURS");
|
|
|
|
break;
|
|
|
|
case 'M': /* min */
|
|
|
|
ASSIGN (reminderUnit, @"MINUTES");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NSLog(@"Cannot process duration unit: '%c'", c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ([quantity length])
|
|
|
|
ASSIGN (reminderQuantity, quantity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// Matches one of the predefined alarms
|
|
|
|
ASSIGN (reminder, [reminderItems objectAtIndex: i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
/* warning: we use this method which will be triggered by the template system
|
|
|
|
when the page is instantiated, but we should find another and cleaner way of
|
|
|
|
doing this... for example, when the clientObject is set */
|
|
|
|
- (void) setComponent: (iCalRepeatableEntityObject *) newComponent
|
|
|
|
{
|
|
|
|
// iCalRecurrenceRule *rrule;
|
|
|
|
SOGoObject *co;
|
|
|
|
|
|
|
|
if (!component)
|
|
|
|
{
|
2007-11-19 22:07:54 +01:00
|
|
|
ASSIGN (component, newComponent);
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
co = [self clientObject];
|
|
|
|
componentOwner = [co ownerInContext: nil];
|
2007-11-13 18:39:03 +01:00
|
|
|
if (component)
|
|
|
|
{
|
|
|
|
ASSIGN (title, [component summary]);
|
|
|
|
ASSIGN (location, [component location]);
|
|
|
|
ASSIGN (comment, [component comment]);
|
2009-07-07 23:17:43 +02:00
|
|
|
ASSIGN (attachUrl, [[component attach] absoluteString]);
|
2007-11-13 18:39:03 +01:00
|
|
|
ASSIGN (privacy, [component accessClass]);
|
|
|
|
ASSIGN (priority, [component priority]);
|
|
|
|
ASSIGN (status, [component status]);
|
2009-07-15 21:28:20 +02:00
|
|
|
ASSIGN (categories,
|
|
|
|
[[component categories] componentsWithSafeSeparator: ',']);
|
2007-11-13 18:39:03 +01:00
|
|
|
ASSIGN (organizer, [component organizer]);
|
|
|
|
[self _loadCategories];
|
|
|
|
[self _loadAttendees];
|
2008-01-14 14:57:28 +01:00
|
|
|
[self _loadRRules];
|
2009-04-21 16:34:22 +02:00
|
|
|
[self _loadAlarms];
|
2008-08-22 08:44:27 +02:00
|
|
|
|
2009-03-24 17:34:03 +01:00
|
|
|
[componentCalendar release];
|
2008-08-22 08:44:27 +02:00
|
|
|
componentCalendar = [co container];
|
|
|
|
if ([componentCalendar isKindOfClass: [SOGoCalendarComponent class]])
|
|
|
|
componentCalendar = [componentCalendar container];
|
2008-12-17 15:32:13 +01:00
|
|
|
[componentCalendar retain];
|
2007-11-13 18:39:03 +01:00
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
}
|
|
|
|
// /* cycles */
|
|
|
|
// if ([component isRecurrent])
|
|
|
|
// {
|
|
|
|
// rrule = [[component recurrenceRules] objectAtIndex: 0];
|
|
|
|
// [self adjustCycleControlsForRRule: rrule];
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSaveURL: (NSString *) newSaveURL
|
|
|
|
{
|
|
|
|
saveURL = newSaveURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) saveURL
|
|
|
|
{
|
|
|
|
return saveURL;
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
/* accessors */
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
- (BOOL) isChildOccurence
|
|
|
|
{
|
|
|
|
return [[self clientObject] isKindOfClass: [SOGoComponentOccurence class]];
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) setItem: (id) _item
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (item, _item);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemPriorityText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"prio_%@", item]];
|
|
|
|
}
|
|
|
|
|
2006-11-03 20:38:08 +01:00
|
|
|
- (NSString *) itemPrivacyText
|
|
|
|
{
|
2007-04-27 21:41:04 +02:00
|
|
|
NSString *tag;
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
tag = [[component tag] lowercaseString];
|
2007-04-27 21:41:04 +02:00
|
|
|
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"%@_%@", item, tag]];
|
2006-11-03 20:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemStatusText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"status_%@", item]];
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setTitle: (NSString *) _value
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (title, _value);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) title
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2009-07-16 17:57:31 +02:00
|
|
|
SOGoCalendarComponent *co;
|
2009-07-14 20:04:50 +02:00
|
|
|
NSString *tag;
|
|
|
|
|
|
|
|
co = [self clientObject];
|
|
|
|
if ([co isNew] && [co isKindOfClass: [SOGoCalendarComponent class]])
|
|
|
|
{
|
|
|
|
tag = [co componentTag];
|
|
|
|
if ([tag isEqualToString: @"vevent"])
|
|
|
|
[self setTitle: [self labelForKey: @"New Event"]];
|
|
|
|
else if ([tag isEqualToString: @"vtodo"])
|
|
|
|
[self setTitle: [self labelForKey: @"New Task"]];
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
return title;
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
2009-07-07 23:17:43 +02:00
|
|
|
- (void) setAttach: (NSString *) _attachUrl
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2009-07-07 23:17:43 +02:00
|
|
|
ASSIGN (attachUrl, _attachUrl);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
2009-07-07 23:17:43 +02:00
|
|
|
- (NSString *) attach
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2009-07-07 23:17:43 +02:00
|
|
|
return attachUrl;
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
2007-11-19 22:07:54 +01:00
|
|
|
- (NSString *) organizerName
|
|
|
|
{
|
|
|
|
return [organizer mailAddress];
|
|
|
|
}
|
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
// - (BOOL) canBeOrganizer
|
|
|
|
// {
|
|
|
|
// NSString *owner;
|
|
|
|
// SOGoObject <SOGoComponentOccurence> *co;
|
|
|
|
// SOGoUser *currentUser;
|
|
|
|
// BOOL hasOrganizer;
|
|
|
|
// SoSecurityManager *sm;
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
// co = [self clientObject];
|
|
|
|
// owner = [co ownerInContext: context];
|
|
|
|
// currentUser = [context activeUser];
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
// hasOrganizer = ([[organizer value: 0] length] > 0);
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
// sm = [SoSecurityManager sharedSecurityManager];
|
2007-12-07 23:40:21 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
// return ([co isNew]
|
|
|
|
// || (([owner isEqualToString: [currentUser login]]
|
|
|
|
// || ![sm validatePermission: SOGoCalendarPerm_ModifyComponent
|
|
|
|
// onObject: co
|
|
|
|
// inContext: context])
|
|
|
|
// && (!hasOrganizer || [component userIsOrganizer: currentUser])));
|
|
|
|
// }
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2007-11-18 11:16:25 +01:00
|
|
|
- (BOOL) hasOrganizer
|
|
|
|
{
|
2008-11-05 22:04:16 +01:00
|
|
|
// We check if there's an organizer and if it's not ourself
|
|
|
|
NSString *value;
|
2007-11-18 11:16:25 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
value = [organizer rfc822Email];
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
if ([value length])
|
2007-11-19 22:07:54 +01:00
|
|
|
{
|
2008-11-05 22:04:16 +01:00
|
|
|
NSDictionary *currentIdentity;
|
|
|
|
NSEnumerator *identities;
|
|
|
|
NSArray *allIdentities;
|
|
|
|
|
|
|
|
allIdentities = [[context activeUser] allIdentities];
|
|
|
|
identities = [allIdentities objectEnumerator];
|
|
|
|
currentIdentity = nil;
|
|
|
|
|
|
|
|
while ((currentIdentity = [identities nextObject]))
|
|
|
|
if ([[currentIdentity objectForKey: @"email"]
|
|
|
|
caseInsensitiveCompare: value]
|
|
|
|
== NSOrderedSame)
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
return YES;
|
2007-11-19 22:07:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
return NO;
|
2007-11-19 22:07:54 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
//return ([[organizer value: 0] length] && ![self canBeOrganizer]);
|
2007-11-19 22:07:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
//- (void) setOrganizerIdentity: (NSDictionary *) newOrganizerIdentity
|
|
|
|
//{
|
|
|
|
// ASSIGN (organizerIdentity, newOrganizerIdentity);
|
|
|
|
//}
|
|
|
|
|
|
|
|
// - (NSDictionary *) organizerIdentity
|
|
|
|
// {
|
|
|
|
// NSArray *allIdentities;
|
|
|
|
// NSEnumerator *identities;
|
|
|
|
// NSDictionary *currentIdentity;
|
|
|
|
// NSString *orgEmail;
|
|
|
|
|
|
|
|
// orgEmail = [organizer rfc822Email];
|
|
|
|
// if (!organizerIdentity)
|
|
|
|
// {
|
|
|
|
// if ([orgEmail length])
|
|
|
|
// {
|
|
|
|
// allIdentities = [[context activeUser] allIdentities];
|
|
|
|
// identities = [allIdentities objectEnumerator];
|
|
|
|
// while (!organizerIdentity
|
|
|
|
// && ((currentIdentity = [identities nextObject])))
|
|
|
|
// if ([[currentIdentity objectForKey: @"email"]
|
|
|
|
// caseInsensitiveCompare: orgEmail]
|
|
|
|
// == NSOrderedSame)
|
|
|
|
// ASSIGN (organizerIdentity, currentIdentity);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return organizerIdentity;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//- (NSArray *) organizerList
|
|
|
|
//{
|
|
|
|
// return [[context activeUser] allIdentities];
|
|
|
|
//}
|
|
|
|
|
|
|
|
//- (NSString *) itemOrganizerText
|
|
|
|
//{
|
|
|
|
// return [item keysWithFormat: @"%{fullName} <%{email}>"];
|
|
|
|
//}
|
2007-11-18 11:16:25 +01:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setAttendeesNames: (NSString *) newAttendeesNames
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (attendeesNames, newAttendeesNames);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) attendeesNames
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
return attendeesNames;
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
2007-11-15 20:02:23 +01:00
|
|
|
- (void) setAttendeesUIDs: (NSString *) newAttendeesUIDs
|
|
|
|
{
|
|
|
|
ASSIGN (attendeesUIDs, newAttendeesUIDs);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) attendeesUIDs
|
|
|
|
{
|
|
|
|
return attendeesUIDs;
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) setAttendeesEmails: (NSString *) newAttendeesEmails
|
2006-10-23 23:34:56 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (attendeesEmails, newAttendeesEmails);
|
2006-10-23 23:34:56 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSString *) attendeesEmails
|
2006-10-23 23:34:56 +02:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
return attendeesEmails;
|
2006-10-23 23:34:56 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:48:19 +01:00
|
|
|
- (void) setAttendeesStates: (NSString *) newAttendeesStates
|
|
|
|
{
|
|
|
|
ASSIGN (attendeesStates, newAttendeesStates);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) attendeesStates
|
|
|
|
{
|
|
|
|
return attendeesStates;
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) setLocation: (NSString *) _value
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (location, _value);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) location
|
|
|
|
{
|
|
|
|
return location;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) hasLocation
|
|
|
|
{
|
|
|
|
return [location length] > 0;
|
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
- (void) setComment: (NSString *) _value
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (comment, _value);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) comment
|
|
|
|
{
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) hasComment
|
|
|
|
{
|
|
|
|
return [comment length] > 0;
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (NSArray *) categoryList
|
2006-10-18 16:42:44 +02:00
|
|
|
{
|
2009-07-15 21:28:20 +02:00
|
|
|
NSMutableArray *categoryList;
|
2009-07-16 15:52:53 +02:00
|
|
|
NSArray *categoryLabels;
|
2009-07-16 17:57:31 +02:00
|
|
|
NSUserDefaults *defaults;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
2009-07-16 17:57:31 +02:00
|
|
|
defaults = [[context activeUser] userDefaults];
|
|
|
|
categoryLabels = [defaults arrayForKey: @"CalendarCategories"];
|
|
|
|
if (!categoryLabels)
|
|
|
|
categoryLabels = [[self labelForKey: @"category_labels"]
|
|
|
|
componentsSeparatedByString: @","];
|
2009-07-16 15:52:53 +02:00
|
|
|
categoryList
|
|
|
|
= [NSMutableArray arrayWithCapacity: [categoryLabels count] + 1];
|
|
|
|
if ([category length] && ![categoryLabels containsObject: category])
|
|
|
|
[categoryList addObject: category];
|
|
|
|
[categoryList addObjectsFromArray: categoryLabels];
|
2009-07-15 21:28:20 +02:00
|
|
|
|
2009-07-16 15:52:53 +02:00
|
|
|
return categoryList;
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCategories: (NSArray *) _categories
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (categories, _categories);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) categories
|
|
|
|
{
|
|
|
|
return categories;
|
|
|
|
}
|
|
|
|
|
2009-07-15 21:28:20 +02:00
|
|
|
- (void) setCategory: (NSString *) newCategory
|
2007-08-21 18:01:28 +02:00
|
|
|
{
|
|
|
|
ASSIGN (category, newCategory);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) category
|
|
|
|
{
|
|
|
|
return category;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) hasCategory
|
|
|
|
{
|
|
|
|
return [category length] > 0;
|
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
- (NSArray *) repeatList
|
|
|
|
{
|
|
|
|
static NSArray *repeatItems = nil;
|
|
|
|
|
|
|
|
if (!repeatItems)
|
|
|
|
{
|
|
|
|
repeatItems = [NSArray arrayWithObjects: @"DAILY",
|
|
|
|
@"WEEKLY",
|
|
|
|
@"BI-WEEKLY",
|
|
|
|
@"EVERY WEEKDAY",
|
|
|
|
@"MONTHLY",
|
|
|
|
@"YEARLY",
|
|
|
|
@"-",
|
|
|
|
@"CUSTOM",
|
|
|
|
nil];
|
|
|
|
[repeatItems retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return repeatItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemRepeatText
|
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"-"])
|
|
|
|
text = item;
|
|
|
|
else
|
|
|
|
text = [self labelForKey: [NSString stringWithFormat: @"repeat_%@", item]];
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2009-07-23 22:11:06 +02:00
|
|
|
- (NSString *) repeatLabel
|
|
|
|
{
|
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
if ([self repeat])
|
|
|
|
rc = [self labelForKey: [NSString stringWithFormat: @"repeat_%@", [self repeat]]];
|
|
|
|
else
|
|
|
|
rc = [self labelForKey: @"repeat_NEVER"];
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
- (NSArray *) reminderList
|
|
|
|
{
|
|
|
|
return reminderItems;
|
|
|
|
}
|
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
- (void) setReminder: (NSString *) theReminder
|
|
|
|
{
|
|
|
|
ASSIGN(reminder, theReminder);
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
- (NSString *) reminder
|
2009-04-21 16:34:22 +02:00
|
|
|
{
|
|
|
|
return reminder;
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
- (void) setReminderQuantity: (NSString *) theReminderQuantity
|
|
|
|
{
|
|
|
|
ASSIGN(reminderQuantity, theReminderQuantity);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) reminderQuantity
|
|
|
|
{
|
|
|
|
return reminderQuantity;
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
- (NSString *) itemReminderText
|
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"-"])
|
|
|
|
text = item;
|
|
|
|
else
|
|
|
|
text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", item]];
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) repeat
|
|
|
|
{
|
|
|
|
return repeat;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setRepeat: (NSString *) newRepeat
|
|
|
|
{
|
|
|
|
ASSIGN(repeat, newRepeat);
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) hasRepeat
|
|
|
|
{
|
|
|
|
return [repeat length] > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemReplyText
|
|
|
|
{
|
|
|
|
NSString *word;
|
|
|
|
|
|
|
|
if ([item intValue] == iCalPersonPartStatAccepted)
|
|
|
|
word = @"ACCEPTED";
|
|
|
|
else if ([item intValue] == iCalPersonPartStatDeclined)
|
|
|
|
word = @"DECLINED";
|
|
|
|
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"partStat_%@", word]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) replyList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects:
|
|
|
|
[NSNumber numberWithInt: iCalPersonPartStatAccepted],
|
|
|
|
[NSNumber numberWithInt: iCalPersonPartStatDeclined], nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSNumber *) reply
|
|
|
|
{
|
|
|
|
iCalPersonPartStat participationStatus;
|
|
|
|
|
|
|
|
participationStatus = [[component findParticipant: [context activeUser]] participationStatus];
|
|
|
|
return [NSNumber numberWithInt: participationStatus];
|
|
|
|
}
|
|
|
|
|
2007-11-13 23:17:40 +01:00
|
|
|
- (NSString *) _permissionForEditing
|
|
|
|
{
|
|
|
|
NSString *perm;
|
|
|
|
|
|
|
|
if ([[self clientObject] isNew])
|
|
|
|
perm = SoPerm_AddDocumentsImagesAndFiles;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([privacy isEqualToString: @"PRIVATE"])
|
|
|
|
perm = SOGoCalendarPerm_ModifyPrivateRecords;
|
|
|
|
else if ([privacy isEqualToString: @"CONFIDENTIAL"])
|
|
|
|
perm = SOGoCalendarPerm_ModifyConfidentialRecords;
|
|
|
|
else
|
|
|
|
perm = SOGoCalendarPerm_ModifyPublicRecords;
|
|
|
|
}
|
|
|
|
|
|
|
|
return perm;
|
|
|
|
}
|
|
|
|
|
2007-04-02 21:27:46 +02:00
|
|
|
- (NSArray *) calendarList
|
|
|
|
{
|
2007-11-21 17:05:07 +01:00
|
|
|
SOGoAppointmentFolder *calendar, *currentCalendar;
|
2007-09-15 00:01:02 +02:00
|
|
|
SOGoAppointmentFolders *calendarParent;
|
2007-04-02 21:27:46 +02:00
|
|
|
NSEnumerator *allCalendars;
|
2007-11-09 20:45:18 +01:00
|
|
|
SoSecurityManager *sm;
|
2007-11-13 18:39:03 +01:00
|
|
|
NSString *perm;
|
2007-04-02 21:27:46 +02:00
|
|
|
|
|
|
|
if (!calendarList)
|
|
|
|
{
|
|
|
|
calendarList = [NSMutableArray new];
|
2007-11-13 23:17:40 +01:00
|
|
|
|
|
|
|
perm = [self _permissionForEditing];
|
|
|
|
calendarParent
|
|
|
|
= [[context activeUser] calendarsFolderInContext: context];
|
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
2007-11-21 17:05:07 +01:00
|
|
|
calendar = [self componentCalendar];
|
2007-09-15 00:01:02 +02:00
|
|
|
allCalendars = [[calendarParent subFolders] objectEnumerator];
|
2007-11-13 23:17:40 +01:00
|
|
|
while ((currentCalendar = [allCalendars nextObject]))
|
2007-11-21 17:05:07 +01:00
|
|
|
if ([calendar isEqual: currentCalendar] ||
|
|
|
|
![sm validatePermission: perm
|
2007-11-13 23:17:40 +01:00
|
|
|
onObject: currentCalendar
|
|
|
|
inContext: context])
|
|
|
|
[calendarList addObject: currentCalendar];
|
2007-04-02 21:27:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return calendarList;
|
|
|
|
}
|
|
|
|
|
2007-11-20 20:15:26 +01:00
|
|
|
- (NSString *) calendarDisplayName
|
|
|
|
{
|
|
|
|
NSString *fDisplayName;
|
|
|
|
SOGoAppointmentFolder *folder;
|
|
|
|
SOGoAppointmentFolders *parentFolder;
|
|
|
|
|
|
|
|
fDisplayName = [item displayName];
|
2008-07-17 23:12:43 +02:00
|
|
|
folder = [self componentCalendar];
|
2007-11-20 20:15:26 +01:00
|
|
|
parentFolder = [folder container];
|
|
|
|
if ([fDisplayName isEqualToString: [parentFolder defaultFolderName]])
|
|
|
|
fDisplayName = [self labelForKey: fDisplayName];
|
|
|
|
|
|
|
|
return fDisplayName;
|
|
|
|
}
|
|
|
|
|
2007-04-02 21:27:46 +02:00
|
|
|
- (NSString *) calendarsFoldersList
|
|
|
|
{
|
|
|
|
NSArray *calendars;
|
|
|
|
|
2007-09-19 22:00:10 +02:00
|
|
|
calendars = [[self calendarList] valueForKey: @"nameInContainer"];
|
2007-04-02 21:27:46 +02:00
|
|
|
|
|
|
|
return [calendars componentsJoinedByString: @","];
|
|
|
|
}
|
|
|
|
|
2008-08-22 08:44:27 +02:00
|
|
|
|
2007-10-24 22:06:53 +02:00
|
|
|
- (SOGoAppointmentFolder *) componentCalendar
|
2007-04-02 21:27:46 +02:00
|
|
|
{
|
2008-08-22 08:44:27 +02:00
|
|
|
return componentCalendar;
|
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (NSString *) componentCalendarName
|
|
|
|
{
|
|
|
|
return [componentCalendar displayName];
|
|
|
|
}
|
|
|
|
|
2008-08-22 08:44:27 +02:00
|
|
|
- (void) setComponentCalendar: (SOGoAppointmentFolder *) _componentCalendar
|
|
|
|
{
|
2008-11-05 22:04:16 +01:00
|
|
|
ASSIGN(componentCalendar, _componentCalendar);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* priorities */
|
|
|
|
|
|
|
|
- (NSArray *) priorities
|
|
|
|
{
|
|
|
|
/* 0 == undefined
|
2007-10-10 20:44:26 +02:00
|
|
|
9 == low
|
|
|
|
5 == medium
|
2006-10-18 16:42:44 +02:00
|
|
|
1 == high
|
|
|
|
*/
|
|
|
|
static NSArray *priorities = nil;
|
|
|
|
|
|
|
|
if (!priorities)
|
|
|
|
{
|
2007-10-10 20:44:26 +02:00
|
|
|
priorities = [NSArray arrayWithObjects: @"9", @"5", @"1", nil];
|
2006-10-18 16:42:44 +02:00
|
|
|
[priorities retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return priorities;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setPriority: (NSString *) _priority
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (priority, _priority);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) priority
|
|
|
|
{
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) hasPriority
|
|
|
|
{
|
|
|
|
return [priority length] > 0;
|
|
|
|
}
|
|
|
|
|
2006-11-03 20:38:08 +01:00
|
|
|
- (NSArray *) privacyClasses
|
|
|
|
{
|
|
|
|
static NSArray *priorities = nil;
|
|
|
|
|
|
|
|
if (!priorities)
|
|
|
|
{
|
2006-11-03 22:18:03 +01:00
|
|
|
priorities = [NSArray arrayWithObjects: @"PUBLIC",
|
|
|
|
@"CONFIDENTIAL", @"PRIVATE", nil];
|
2006-11-03 20:38:08 +01:00
|
|
|
[priorities retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return priorities;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setPrivacy: (NSString *) _privacy
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (privacy, _privacy);
|
2006-11-03 20:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) privacy
|
|
|
|
{
|
|
|
|
return privacy;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) statusTypes
|
|
|
|
{
|
2008-11-20 20:17:59 +01:00
|
|
|
static NSArray *statusTypes = nil;
|
2006-11-03 20:38:08 +01:00
|
|
|
|
2008-11-20 20:17:59 +01:00
|
|
|
if (!statusTypes)
|
2006-11-03 20:38:08 +01:00
|
|
|
{
|
2008-11-20 20:17:59 +01:00
|
|
|
statusTypes = [NSArray arrayWithObjects: @"", @"TENTATIVE", @"CONFIRMED", @"CANCELLED", nil];
|
|
|
|
[statusTypes retain];
|
2006-11-03 20:38:08 +01:00
|
|
|
}
|
|
|
|
|
2008-11-20 20:17:59 +01:00
|
|
|
return statusTypes;
|
2006-11-03 20:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setStatus: (NSString *) _status
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (status, _status);
|
2006-11-03 20:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) status
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
- (void) setRepeatType: (NSString *) theValue
|
|
|
|
{
|
|
|
|
ASSIGN (repeatType, theValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) repeatType
|
|
|
|
{
|
|
|
|
return repeatType;
|
|
|
|
}
|
|
|
|
|
|
|
|
REPEAT(1);
|
|
|
|
REPEAT(2);
|
|
|
|
REPEAT(3);
|
|
|
|
REPEAT(4);
|
|
|
|
REPEAT(5);
|
|
|
|
REPEAT(6);
|
|
|
|
REPEAT(7);
|
|
|
|
RANGE(1);
|
|
|
|
RANGE(2);
|
|
|
|
|
|
|
|
////////////////////////////////// JUNK ////////////////////////////////////////
|
|
|
|
////////////////////////////////// JUNK ////////////////////////////////////////
|
|
|
|
////////////////////////////////// JUNK ////////////////////////////////////////
|
2006-10-18 16:42:44 +02:00
|
|
|
- (NSArray *) cycles
|
|
|
|
{
|
|
|
|
NSBundle *bundle;
|
|
|
|
NSString *path;
|
|
|
|
static NSArray *cycles = nil;
|
|
|
|
|
|
|
|
if (!cycles)
|
|
|
|
{
|
|
|
|
bundle = [NSBundle bundleForClass:[self class]];
|
2007-03-18 16:20:38 +01:00
|
|
|
path = [bundle pathForResource: @"cycles" ofType: @"plist"];
|
2006-10-18 16:42:44 +02:00
|
|
|
NSAssert(path != nil, @"Cannot find cycles.plist!");
|
|
|
|
cycles = [[NSArray arrayWithContentsOfFile:path] retain];
|
|
|
|
NSAssert(cycles != nil, @"Cannot instantiate cycles from cycles.plist!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return cycles;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCycle: (NSDictionary *) _cycle
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (cycle, _cycle);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) cycle
|
|
|
|
{
|
|
|
|
return cycle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasCycle
|
|
|
|
{
|
|
|
|
return ([cycle objectForKey: @"rule"] != nil);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) cycleLabel
|
|
|
|
{
|
|
|
|
NSString *key;
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
key = [(NSDictionary *)item objectForKey: @"label"];
|
2006-10-18 16:42:44 +02:00
|
|
|
|
|
|
|
return [self labelForKey:key];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCycleUntilDate: (NSCalendarDate *) _cycleUntilDate
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
// NSCalendarDate *until;
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
// /* copy hour/minute/second from startDate */
|
|
|
|
// until = [_cycleUntilDate hour: [startDate hourOfDay]
|
|
|
|
// minute: [startDate minuteOfHour]
|
|
|
|
// second: [startDate secondOfMinute]];
|
|
|
|
// [until setTimeZone: [startDate timeZone]];
|
|
|
|
// ASSIGN (cycleUntilDate, until);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) cycleUntilDate
|
|
|
|
{
|
|
|
|
return cycleUntilDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (iCalRecurrenceRule *) rrule
|
|
|
|
{
|
|
|
|
NSString *ruleRep;
|
|
|
|
iCalRecurrenceRule *rule;
|
|
|
|
|
|
|
|
if (![self hasCycle])
|
|
|
|
return nil;
|
2007-03-18 16:20:38 +01:00
|
|
|
ruleRep = [cycle objectForKey: @"rule"];
|
2006-10-18 16:42:44 +02:00
|
|
|
rule = [iCalRecurrenceRule recurrenceRuleWithICalRepresentation:ruleRep];
|
|
|
|
|
|
|
|
if (cycleUntilDate && [self isCycleEndUntil])
|
|
|
|
[rule setUntilDate:cycleUntilDate];
|
|
|
|
|
|
|
|
return rule;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) adjustCycleControlsForRRule: (iCalRecurrenceRule *) _rrule
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
// NSDictionary *c;
|
|
|
|
// NSCalendarDate *until;
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
// c = [self cycleMatchingRRule:_rrule];
|
|
|
|
// [self setCycle:c];
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
// until = [[[_rrule untilDate] copy] autorelease];
|
|
|
|
// if (!until)
|
|
|
|
// until = startDate;
|
|
|
|
// else
|
|
|
|
// [self setIsCycleEndUntil];
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
// [until setTimeZone:[[self clientObject] userTimeZone]];
|
|
|
|
// [self setCycleUntilDate:until];
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This method is necessary, because we have a fixed sets of cycles in the UI.
|
|
|
|
The model is able to represent arbitrary rules, however.
|
|
|
|
There SHOULD be a different UI, similar to iCal.app, to allow modelling
|
|
|
|
of more complex rules.
|
|
|
|
|
|
|
|
This method obviously cannot map all existing rules back to the fixed list
|
|
|
|
in cycles.plist. This should be fixed in a future version when interop
|
|
|
|
becomes more important.
|
|
|
|
*/
|
|
|
|
- (NSDictionary *) cycleMatchingRRule: (iCalRecurrenceRule *) _rrule
|
|
|
|
{
|
|
|
|
NSString *cycleRep;
|
|
|
|
NSArray *cycles;
|
|
|
|
unsigned i, count;
|
|
|
|
|
|
|
|
if (!_rrule)
|
|
|
|
return [[self cycles] objectAtIndex:0];
|
|
|
|
|
|
|
|
cycleRep = [_rrule versitString];
|
|
|
|
cycles = [self cycles];
|
|
|
|
count = [cycles count];
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
NSDictionary *c;
|
|
|
|
NSString *cr;
|
|
|
|
|
|
|
|
c = [cycles objectAtIndex:i];
|
2007-03-18 16:20:38 +01:00
|
|
|
cr = [c objectForKey: @"rule"];
|
2006-10-18 16:42:44 +02:00
|
|
|
if ([cr isEqualToString:cycleRep])
|
|
|
|
return c;
|
|
|
|
}
|
2007-03-18 16:20:38 +01:00
|
|
|
[self warnWithFormat: @"No default cycle for rrule found! -> %@", _rrule];
|
2006-10-18 16:42:44 +02:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cycle "ends" - supposed to be 'never', 'COUNT' or 'UNTIL' */
|
|
|
|
- (NSArray *) cycleEnds
|
|
|
|
{
|
|
|
|
static NSArray *ends = nil;
|
|
|
|
|
|
|
|
if (!ends)
|
|
|
|
{
|
|
|
|
ends = [NSArray arrayWithObjects: @"cycle_end_never",
|
|
|
|
@"cycle_end_until", nil];
|
|
|
|
[ends retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return ends;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCycleEnd: (NSString *) _cycleEnd
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
ASSIGN (cycleEnd, _cycleEnd);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) cycleEnd
|
|
|
|
{
|
|
|
|
return cycleEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isCycleEndUntil
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
return (cycleEnd && [cycleEnd isEqualToString: @"cycle_end_until"]);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setIsCycleEndUntil
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
[self setCycleEnd: @"cycle_end_until"];
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setIsCycleEndNever
|
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
[self setCycleEnd: @"cycle_end_never"];
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
////////////////////////////////// JUNK ////////////////////////////////////////
|
|
|
|
////////////////////////////////// JUNK ////////////////////////////////////////
|
|
|
|
////////////////////////////////// JUNK ////////////////////////////////////////
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
|
|
|
|
/* helpers */
|
|
|
|
- (NSString *) completeURIForMethod: (NSString *) _method
|
|
|
|
{
|
|
|
|
NSString *uri;
|
|
|
|
NSRange r;
|
|
|
|
|
|
|
|
uri = [[[self context] request] uri];
|
|
|
|
|
|
|
|
/* first: identify query parameters */
|
2007-03-18 16:20:38 +01:00
|
|
|
r = [uri rangeOfString: @"?" options:NSBackwardsSearch];
|
2006-10-18 16:42:44 +02:00
|
|
|
if (r.length > 0)
|
|
|
|
uri = [uri substringToIndex:r.location];
|
|
|
|
|
|
|
|
/* next: append trailing slash */
|
2007-03-18 16:20:38 +01:00
|
|
|
if (![uri hasSuffix: @"/"])
|
|
|
|
uri = [uri stringByAppendingString: @"/"];
|
2006-10-18 16:42:44 +02:00
|
|
|
|
|
|
|
/* next: append method */
|
|
|
|
uri = [uri stringByAppendingString:_method];
|
|
|
|
|
|
|
|
/* next: append query parameters */
|
|
|
|
return [self completeHrefForMethod:uri];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isWriteableClientObject
|
|
|
|
{
|
2008-07-17 23:12:43 +02:00
|
|
|
return [[self clientObject]
|
|
|
|
respondsToSelector: @selector(saveContentString:)];
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* access */
|
|
|
|
|
|
|
|
- (BOOL) isMyComponent
|
|
|
|
{
|
2007-05-09 21:23:45 +02:00
|
|
|
return ([[context activeUser] hasEmail: [organizer rfc822Email]]);
|
2006-10-18 16:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) canEditComponent
|
|
|
|
{
|
|
|
|
return [self isMyComponent];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* response generation */
|
|
|
|
|
|
|
|
- (NSString *) initialCycleVisibility
|
|
|
|
{
|
|
|
|
return ([self hasCycle]
|
|
|
|
? @"visibility: visible;"
|
|
|
|
: @"visibility: hidden;");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) initialCycleEndUntilVisibility {
|
|
|
|
return ([self isCycleEndUntil]
|
|
|
|
? @"visibility: visible;"
|
|
|
|
: @"visibility: hidden;");
|
|
|
|
}
|
|
|
|
|
2007-04-17 15:49:23 +02:00
|
|
|
// - (NSString *) iCalParticipantsAndResourcesStringFromQueryParameters
|
|
|
|
// {
|
|
|
|
// NSString *s;
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-04-17 15:49:23 +02:00
|
|
|
// s = [self iCalParticipantsStringFromQueryParameters];
|
|
|
|
// return [s stringByAppendingString:
|
|
|
|
// [self iCalResourcesStringFromQueryParameters]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) iCalParticipantsStringFromQueryParameters
|
|
|
|
// {
|
|
|
|
// static NSString *iCalParticipantString = @"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=\"%@\":MAILTO:%@\r\n";
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-04-17 15:49:23 +02:00
|
|
|
// return [self iCalStringFromQueryParameter: @"ps"
|
|
|
|
// format: iCalParticipantString];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) iCalResourcesStringFromQueryParameters
|
|
|
|
// {
|
|
|
|
// static NSString *iCalResourceString = @"ATTENDEE;ROLE=NON-PARTICIPANT;CN=\"%@\":MAILTO:%@\r\n";
|
|
|
|
|
|
|
|
// return [self iCalStringFromQueryParameter: @"rs"
|
|
|
|
// format: iCalResourceString];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) iCalStringFromQueryParameter: (NSString *) _qp
|
|
|
|
// format: (NSString *) _format
|
|
|
|
// {
|
2008-07-25 19:52:49 +02:00
|
|
|
// LDAPUserManager *um;
|
2007-04-17 15:49:23 +02:00
|
|
|
// NSMutableString *iCalRep;
|
|
|
|
// NSString *s;
|
|
|
|
|
2008-07-25 19:52:49 +02:00
|
|
|
// um = [LDAPUserManager sharedUserManager];
|
2007-04-17 15:49:23 +02:00
|
|
|
// iCalRep = (NSMutableString *)[NSMutableString string];
|
|
|
|
// s = [self queryParameterForKey:_qp];
|
|
|
|
// if(s && [s length] > 0) {
|
|
|
|
// NSArray *es;
|
|
|
|
// unsigned i, count;
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-04-17 15:49:23 +02:00
|
|
|
// es = [s componentsSeparatedByString: @","];
|
|
|
|
// count = [es count];
|
|
|
|
// for(i = 0; i < count; i++) {
|
|
|
|
// NSString *email, *cn;
|
2006-10-18 16:42:44 +02:00
|
|
|
|
2007-04-17 15:49:23 +02:00
|
|
|
// email = [es objectAtIndex:i];
|
|
|
|
// cn = [um getCNForUID:[um getUIDForEmail:email]];
|
|
|
|
// [iCalRep appendFormat:_format, cn, email];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return iCalRep;
|
|
|
|
// }
|
2006-10-18 16:42:44 +02:00
|
|
|
|
|
|
|
- (NSException *) validateObjectForStatusChange
|
|
|
|
{
|
|
|
|
id co;
|
|
|
|
|
|
|
|
co = [self clientObject];
|
2007-04-17 15:49:23 +02:00
|
|
|
if (![co respondsToSelector: @selector(changeParticipationStatus:)])
|
|
|
|
return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
|
2006-10-18 16:42:44 +02:00
|
|
|
reason:
|
|
|
|
@"method cannot be invoked on the specified object"];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* contact editor compatibility */
|
|
|
|
|
2009-07-07 23:17:43 +02:00
|
|
|
/*- (NSString *) urlButtonClasses
|
2006-10-23 23:34:56 +02:00
|
|
|
{
|
|
|
|
NSString *classes;
|
|
|
|
|
|
|
|
if ([url length])
|
|
|
|
classes = @"button";
|
|
|
|
else
|
|
|
|
classes = @"button _disabled";
|
|
|
|
|
|
|
|
return classes;
|
2009-07-07 23:17:43 +02:00
|
|
|
}*/
|
2006-10-23 23:34:56 +02:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) _handleAttendeesEdition
|
2006-11-07 19:15:29 +01:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
NSArray *names, *emails;
|
|
|
|
NSMutableArray *newAttendees;
|
|
|
|
unsigned int count, max;
|
|
|
|
NSString *currentEmail;
|
|
|
|
iCalPerson *currentAttendee;
|
2006-11-07 19:15:29 +01:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
newAttendees = [NSMutableArray new];
|
2007-03-19 15:33:33 +01:00
|
|
|
if ([attendeesNames length] > 0)
|
2006-11-07 19:15:29 +01:00
|
|
|
{
|
2007-03-19 15:33:33 +01:00
|
|
|
names = [attendeesNames componentsSeparatedByString: @","];
|
|
|
|
emails = [attendeesEmails componentsSeparatedByString: @","];
|
|
|
|
max = [emails count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
currentEmail = [emails objectAtIndex: count];
|
|
|
|
currentAttendee = [component findParticipantWithEmail: currentEmail];
|
|
|
|
if (!currentAttendee)
|
|
|
|
{
|
|
|
|
currentAttendee = [iCalPerson elementWithTag: @"attendee"];
|
|
|
|
[currentAttendee setCn: [names objectAtIndex: count]];
|
|
|
|
[currentAttendee setEmail: currentEmail];
|
|
|
|
[currentAttendee setRole: @"REQ-PARTICIPANT"];
|
2007-11-18 11:16:25 +01:00
|
|
|
[currentAttendee setRsvp: @"TRUE"];
|
2007-03-19 15:33:33 +01:00
|
|
|
[currentAttendee
|
|
|
|
setParticipationStatus: iCalPersonPartStatNeedsAction];
|
|
|
|
}
|
|
|
|
[newAttendees addObject: currentAttendee];
|
|
|
|
}
|
2006-11-07 20:24:36 +01:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
[component setAttendees: newAttendees];
|
|
|
|
[newAttendees release];
|
2006-11-07 20:24:36 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:33:33 +01:00
|
|
|
- (void) _handleOrganizer
|
|
|
|
{
|
|
|
|
NSString *organizerEmail;
|
2007-11-19 22:07:54 +01:00
|
|
|
NSString *owner, *login;
|
2007-12-07 23:40:21 +01:00
|
|
|
BOOL isOwner, hasOrganizer, hasAttendees;
|
2007-03-19 15:33:33 +01:00
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
//owner = [[self clientObject] ownerInContext: context];
|
|
|
|
owner = [componentCalendar ownerInContext: context];
|
2007-12-07 23:40:21 +01:00
|
|
|
login = [[context activeUser] login];
|
|
|
|
isOwner = [owner isEqualToString: login];
|
|
|
|
hasAttendees = ([[component attendees] count] > 0);
|
2007-03-19 15:33:33 +01:00
|
|
|
organizerEmail = [[component organizer] email];
|
2007-12-07 23:40:21 +01:00
|
|
|
hasOrganizer = ([organizerEmail length] > 0);
|
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
#if 1
|
|
|
|
ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]);
|
|
|
|
[component setOrganizer: organizer];
|
|
|
|
|
|
|
|
if (hasAttendees)
|
|
|
|
{
|
|
|
|
SOGoUser *user;
|
|
|
|
id identity;
|
|
|
|
|
|
|
|
user = [SOGoUser userWithLogin: owner roles: nil];
|
|
|
|
identity = [user defaultIdentity];
|
|
|
|
[organizer setCn: [identity objectForKey: @"fullName"]];
|
|
|
|
[organizer setEmail: [identity objectForKey: @"email"]];
|
|
|
|
|
|
|
|
if (!isOwner)
|
|
|
|
{
|
|
|
|
NSString *currentEmail;
|
|
|
|
|
|
|
|
currentEmail = [[[context activeUser] allEmails] objectAtIndex: 0];
|
|
|
|
[organizer addAttribute: @"SENT-BY"
|
|
|
|
value: [NSString stringWithFormat: @"\"MAILTO:%@\"", currentEmail]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2007-12-07 23:40:21 +01:00
|
|
|
if (hasOrganizer)
|
2007-03-19 15:33:33 +01:00
|
|
|
{
|
2007-12-07 23:40:21 +01:00
|
|
|
if (isOwner && !hasAttendees)
|
2007-03-19 15:33:33 +01:00
|
|
|
{
|
|
|
|
ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]);
|
|
|
|
[component setOrganizer: organizer];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-07 23:40:21 +01:00
|
|
|
if (!isOwner || hasAttendees)
|
2007-03-19 15:33:33 +01:00
|
|
|
{
|
|
|
|
ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]);
|
2007-12-07 23:40:21 +01:00
|
|
|
[organizer setCn: [organizerIdentity objectForKey: @"fullName"]];
|
|
|
|
[organizer setEmail: [organizerIdentity objectForKey: @"email"]];
|
2007-03-19 15:33:33 +01:00
|
|
|
[component setOrganizer: organizer];
|
|
|
|
}
|
|
|
|
}
|
2008-11-05 22:04:16 +01:00
|
|
|
#endif
|
2007-03-19 15:33:33 +01:00
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
- (void) _handleCustomRRule: (iCalRecurrenceRule *) theRule
|
|
|
|
|
|
|
|
{
|
|
|
|
int type, range;
|
|
|
|
|
|
|
|
// We decode the range
|
|
|
|
range = [[self range1] intValue];
|
|
|
|
|
|
|
|
// Create X appointments
|
|
|
|
if (range == 1)
|
|
|
|
{
|
|
|
|
[theRule setRepeatCount: [[self range2] intValue]];
|
|
|
|
}
|
|
|
|
// Repeat until date
|
|
|
|
else if (range == 2)
|
|
|
|
{
|
2009-01-07 19:32:24 +01:00
|
|
|
NSCalendarDate *date;
|
|
|
|
SOGoUser *user;
|
2009-01-07 22:01:16 +01:00
|
|
|
|
2009-01-07 19:32:24 +01:00
|
|
|
user = [context activeUser];
|
|
|
|
date = [NSCalendarDate dateWithString: [self range2]
|
2009-01-07 22:01:16 +01:00
|
|
|
calendarFormat: dateFormat
|
|
|
|
locale: [[WOApplication application] localeForLanguageNamed: [user language]]];
|
2009-01-07 19:32:24 +01:00
|
|
|
[theRule setUntilDate: date];
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
// No end date.
|
|
|
|
else
|
|
|
|
{
|
2008-01-16 18:07:46 +01:00
|
|
|
// Do nothing?
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// We decode the type and the rest accordingly.
|
|
|
|
type = [[self repeatType] intValue];
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
// DAILY:
|
|
|
|
//
|
|
|
|
// repeat1 holds the value of the radio button:
|
|
|
|
// 0 -> Every X days
|
|
|
|
// 1 -> Every weekday
|
|
|
|
//
|
|
|
|
// repeat2 holds the value of X when repeat1 equals 0
|
|
|
|
//
|
|
|
|
case 0:
|
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
if ([[self repeat2] intValue] > 0)
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
[theRule setFrequency: iCalRecurrenceFrequenceDaily];
|
|
|
|
|
|
|
|
if ([[self repeat1] intValue] == 0)
|
|
|
|
{
|
|
|
|
[theRule setInterval: [self repeat2]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[theRule setByDayMask: (iCalWeekDayMonday
|
|
|
|
|iCalWeekDayTuesday
|
|
|
|
|iCalWeekDayWednesday
|
|
|
|
|iCalWeekDayThursday
|
|
|
|
|iCalWeekDayFriday)];
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// WEEKLY
|
|
|
|
//
|
|
|
|
// repeat1 holds the value of "Every X week(s)"
|
|
|
|
//
|
|
|
|
// repeat2 holds which days are part of the recurrence rule
|
|
|
|
// 1 -> Monday
|
|
|
|
// 2 -> Tuesday .. and so on.
|
|
|
|
// The list is separated by commas, like: 1,3,4
|
|
|
|
case 1:
|
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
if ([[self repeat1] intValue] > 0)
|
|
|
|
{
|
|
|
|
NSArray *v;
|
|
|
|
int c, mask;
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2009-03-24 21:50:31 +01:00
|
|
|
[theRule setFrequency: iCalRecurrenceFrequenceWeekly];
|
|
|
|
[theRule setInterval: [self repeat1]];
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2009-03-24 21:50:31 +01:00
|
|
|
v = [[self repeat2] componentsSeparatedByString: @","];
|
|
|
|
c = [v count];
|
|
|
|
mask = 0;
|
2008-01-28 16:32:24 +01:00
|
|
|
|
2009-03-24 21:50:31 +01:00
|
|
|
while (c--)
|
|
|
|
mask |= 1 << ([[v objectAtIndex: c] intValue]);
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2009-03-24 21:50:31 +01:00
|
|
|
[theRule setByDayMask: mask];
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// MONTHLY
|
|
|
|
//
|
|
|
|
// repeat1 holds the value of "Every X month(s)"
|
|
|
|
//
|
|
|
|
// repeat2 holds the value of the radio-button "The" / "Recur on day(s)"
|
|
|
|
// 0 -> The
|
|
|
|
// 1 -> Recur on day(s)
|
|
|
|
//
|
|
|
|
// repeat3 holds the value of the first popup
|
|
|
|
// 0 -> First
|
|
|
|
// 1 -> Second ... and so on.
|
|
|
|
//
|
|
|
|
// repeat4 holds the value of the second popop
|
|
|
|
// 0 -> Sunday
|
|
|
|
// 1 -> Monday ... and so on.
|
|
|
|
// 7 -> Day of the month
|
|
|
|
//
|
|
|
|
// repeat5 holds the selected days when "Recur on day(s)"
|
|
|
|
// is chosen. The value starts at 1.
|
|
|
|
//
|
|
|
|
case 2:
|
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
if ([[self repeat1] intValue] > 0)
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
[theRule setFrequency: iCalRecurrenceFrequenceMonthly];
|
|
|
|
[theRule setInterval: [self repeat1]];
|
|
|
|
|
|
|
|
// We recur on specific days...
|
|
|
|
if ([[self repeat2] intValue] == 1
|
|
|
|
&& [[self repeat5] intValue] > 0)
|
|
|
|
{
|
|
|
|
[theRule setNamedValue: @"bymonthday" to: [self repeat5]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// YEARLY
|
|
|
|
//
|
|
|
|
// repeat1 holds the value of "Every X year(s)"
|
|
|
|
//
|
|
|
|
// repeat2 holds the value of the radio-button "Every" / "Every .. of .."
|
|
|
|
// 0 -> Every
|
|
|
|
// 1 -> Every .. of ..
|
|
|
|
//
|
|
|
|
// repeat3 holds the value of the DAY parameter
|
|
|
|
// repeat4 holds the value of the MONTH parameter (0 -> January, 1 -> February ... )
|
|
|
|
// ex: 3 February
|
|
|
|
//
|
|
|
|
// repeat5 holds the value of the OCCURENCE parameter (0 -> First, 1 -> Second ..)
|
|
|
|
// repeat6 holds the value of the DAY parameter (0 -> Sunday, 1 -> Monday, etc..)
|
|
|
|
// repeat7 holds the value of the MONTH parameter (0 -> January, 1 -> February ... )
|
|
|
|
//
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
if ([[self repeat1] intValue] > 0)
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
2009-03-24 21:50:31 +01:00
|
|
|
[theRule setFrequency: iCalRecurrenceFrequenceYearly];
|
|
|
|
[theRule setInterval: [self repeat1]];
|
|
|
|
|
|
|
|
// We recur Every .. of ..
|
|
|
|
if ([[self repeat2] intValue] == 1)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([[self repeat3] intValue] > 0
|
|
|
|
&& [[self repeat4] intValue] > 0)
|
|
|
|
{
|
|
|
|
[theRule setNamedValue: @"bymonthday"
|
|
|
|
to: [self repeat3]];
|
|
|
|
[theRule setNamedValue: @"bymonth"
|
|
|
|
to: [NSString stringWithFormat: @"%d", ([[self repeat4] intValue]+1)]];
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
- (void) takeValuesFromRequest: (WORequest *) _rq
|
|
|
|
inContext: (WOContext *) _ctx
|
2006-11-07 20:24:36 +01:00
|
|
|
{
|
2007-03-27 20:18:06 +02:00
|
|
|
SOGoCalendarComponent *clientObject;
|
2008-01-14 14:57:28 +01:00
|
|
|
iCalRecurrenceRule *rule;
|
|
|
|
NSCalendarDate *now;
|
2007-03-18 16:20:38 +01:00
|
|
|
|
|
|
|
[super takeValuesFromRequest: _rq inContext: _ctx];
|
2006-11-07 20:24:36 +01:00
|
|
|
|
2007-03-18 16:20:38 +01:00
|
|
|
now = [NSCalendarDate calendarDate];
|
|
|
|
[component setSummary: title];
|
|
|
|
[component setLocation: location];
|
|
|
|
[component setComment: comment];
|
2009-07-07 23:17:43 +02:00
|
|
|
[component setAttach: attachUrl];
|
2007-04-26 03:16:19 +02:00
|
|
|
[component setAccessClass: privacy];
|
2009-07-15 21:28:20 +02:00
|
|
|
[component setCategories: category];
|
2007-03-19 15:33:33 +01:00
|
|
|
[self _handleAttendeesEdition];
|
|
|
|
[self _handleOrganizer];
|
2007-03-27 20:18:06 +02:00
|
|
|
clientObject = [self clientObject];
|
|
|
|
if ([clientObject isNew])
|
2006-11-07 20:24:36 +01:00
|
|
|
{
|
2007-03-18 16:20:38 +01:00
|
|
|
[component setCreated: now];
|
|
|
|
[component setTimeStampAsDate: now];
|
2006-11-07 19:15:29 +01:00
|
|
|
}
|
2007-10-10 20:44:26 +02:00
|
|
|
[component setPriority: priority];
|
2007-03-18 16:20:38 +01:00
|
|
|
[component setLastModified: now];
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2009-04-21 16:34:22 +02:00
|
|
|
if (!reminder || [reminder caseInsensitiveCompare: @"-"] == NSOrderedSame)
|
|
|
|
// No alarm selected -- if there was an unsupported alarm defined in
|
|
|
|
// the event, it will be deleted.
|
|
|
|
[component removeAllAlarms];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iCalTrigger *aTrigger;
|
|
|
|
iCalAlarm *anAlarm;
|
|
|
|
NSString *aValue;
|
|
|
|
unsigned int index;
|
|
|
|
|
|
|
|
index = [reminderItems indexOfObject: reminder];
|
|
|
|
aValue = [reminderValues objectAtIndex: index];
|
|
|
|
|
|
|
|
aTrigger = [iCalTrigger elementWithTag: @"TRIGGER"];
|
|
|
|
[aTrigger setValueType: @"DURATION"];
|
|
|
|
|
|
|
|
anAlarm = [iCalAlarm new];
|
|
|
|
[anAlarm setAction: @"DISPLAY"];
|
|
|
|
[anAlarm setTrigger: aTrigger];
|
|
|
|
|
|
|
|
if ([aValue length]) {
|
|
|
|
// Predefined alarm
|
|
|
|
[aTrigger setValue: aValue];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Custom alarm
|
|
|
|
if ([reminderReference caseInsensitiveCompare: @"BEFORE"] == NSOrderedSame)
|
|
|
|
aValue = [NSString stringWithString: @"-P"];
|
|
|
|
else
|
|
|
|
aValue = [NSString stringWithString: @"P"];
|
|
|
|
|
|
|
|
if ([reminderUnit caseInsensitiveCompare: @"MINUTES"] == NSOrderedSame ||
|
|
|
|
[reminderUnit caseInsensitiveCompare: @"HOURS"] == NSOrderedSame)
|
|
|
|
aValue = [aValue stringByAppendingString: @"T"];
|
|
|
|
|
|
|
|
aValue = [aValue stringByAppendingFormat: @"%i%@",
|
|
|
|
[reminderQuantity intValue],
|
|
|
|
[reminderUnit substringToIndex: 1]];
|
|
|
|
[aTrigger setValue: aValue];
|
|
|
|
[aTrigger setRelationType: reminderRelation];
|
|
|
|
}
|
|
|
|
[component removeAllAlarms];
|
|
|
|
[component addToAlarms: anAlarm];
|
|
|
|
|
|
|
|
[anAlarm release];
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
if (![self isChildOccurence])
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
2008-07-17 23:12:43 +02:00
|
|
|
// We remove any repeat rules
|
|
|
|
if (!repeat && [component hasRecurrenceRules])
|
|
|
|
[component removeAllRecurrenceRules];
|
|
|
|
else if ([repeat caseInsensitiveCompare: @"-"] != NSOrderedSame)
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
2008-07-17 23:12:43 +02:00
|
|
|
rule = [iCalRecurrenceRule new];
|
|
|
|
|
2008-03-25 21:43:29 +01:00
|
|
|
[rule setInterval: @"1"];
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
if ([repeat caseInsensitiveCompare: @"BI-WEEKLY"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
[rule setFrequency: iCalRecurrenceFrequenceWeekly];
|
|
|
|
[rule setInterval: @"2"];
|
|
|
|
}
|
|
|
|
else if ([repeat caseInsensitiveCompare: @"EVERY WEEKDAY"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
[rule setByDayMask: (iCalWeekDayMonday
|
|
|
|
|iCalWeekDayTuesday
|
|
|
|
|iCalWeekDayWednesday
|
|
|
|
|iCalWeekDayThursday
|
|
|
|
|iCalWeekDayFriday)];
|
|
|
|
[rule setFrequency: iCalRecurrenceFrequenceDaily];
|
|
|
|
}
|
|
|
|
else if ([repeat caseInsensitiveCompare: @"MONTHLY"] == NSOrderedSame
|
|
|
|
|| [repeat caseInsensitiveCompare: @"DAILY"] == NSOrderedSame
|
|
|
|
|| [repeat caseInsensitiveCompare: @"WEEKLY"] == NSOrderedSame
|
|
|
|
|| [repeat caseInsensitiveCompare: @"YEARLY"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
[rule setInterval: @"1"];
|
|
|
|
[rule setFrequency:
|
|
|
|
(iCalRecurrenceFrequency) [rule valueForFrequency: repeat]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We have a CUSTOM recurrence. Let's decode what kind of custome recurrence
|
|
|
|
// we have and set that.
|
|
|
|
[self _handleCustomRRule: rule];
|
|
|
|
}
|
|
|
|
|
|
|
|
[component setRecurrenceRules: [NSArray arrayWithObject: rule]];
|
|
|
|
[rule release];
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
2006-11-07 19:15:29 +01:00
|
|
|
}
|
|
|
|
|
2007-11-19 17:37:20 +01:00
|
|
|
#warning the following methods probably share some code...
|
|
|
|
- (NSString *) _toolbarForOwner: (SOGoUser *) ownerUser
|
2008-08-09 17:19:10 +02:00
|
|
|
andClientObject: (SOGoContentObject
|
|
|
|
<SOGoComponentOccurence> *) clientObject
|
2007-05-03 18:13:51 +02:00
|
|
|
{
|
2008-11-26 17:26:32 +01:00
|
|
|
NSString *toolbarFilename;
|
|
|
|
BOOL isOrganizer;
|
|
|
|
|
|
|
|
// We determine if we're the organizer of the component beeing modified.
|
|
|
|
// If we created an event on behalf of someone else -userIsOrganizer will
|
|
|
|
// return us YES. This is OK because we're in the SENT-BY. But, Alice
|
|
|
|
// should be able to accept/decline an invitation if she created the event
|
|
|
|
// in Bob's calendar and added herself in the attendee list.
|
|
|
|
isOrganizer = [component userIsOrganizer: ownerUser];
|
|
|
|
|
|
|
|
if (isOrganizer)
|
2009-07-27 14:48:27 +02:00
|
|
|
isOrganizer = ![ownerUser hasEmail: [[component organizer] sentBy]];
|
2007-06-01 23:01:44 +02:00
|
|
|
|
2007-11-19 17:37:20 +01:00
|
|
|
if ([[component attendees] count]
|
|
|
|
&& [component userIsParticipant: ownerUser]
|
2009-05-22 23:01:47 +02:00
|
|
|
&& !isOrganizer
|
|
|
|
// Lightning does not manage participation status within tasks,
|
|
|
|
// so we also ignore the participation status of tasks in the
|
|
|
|
// web interface.
|
|
|
|
&& ![[component tag] isEqualToString: @"VTODO"])
|
2009-07-27 14:48:27 +02:00
|
|
|
toolbarFilename = @"SOGoEmpty.toolbar";
|
2007-11-19 17:37:20 +01:00
|
|
|
else
|
2007-06-05 20:07:08 +02:00
|
|
|
{
|
2007-11-19 22:07:54 +01:00
|
|
|
if ([clientObject isKindOfClass: [SOGoAppointmentObject class]])
|
2009-07-27 14:48:27 +02:00
|
|
|
toolbarFilename = @"SOGoAppointmentObject.toolbar";
|
2007-06-05 20:07:08 +02:00
|
|
|
else
|
2009-07-27 14:48:27 +02:00
|
|
|
toolbarFilename = @"SOGoTaskObject.toolbar";
|
2007-06-05 20:07:08 +02:00
|
|
|
}
|
2007-11-19 17:37:20 +01:00
|
|
|
|
|
|
|
return toolbarFilename;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) _toolbarForDelegate: (SOGoUser *) ownerUser
|
2008-08-09 17:19:10 +02:00
|
|
|
andClientObject: (SOGoContentObject
|
|
|
|
<SOGoComponentOccurence> *) clientObject
|
2007-11-19 17:37:20 +01:00
|
|
|
{
|
|
|
|
SoSecurityManager *sm;
|
|
|
|
NSString *toolbarFilename, *adminToolbar;
|
2007-12-06 23:54:01 +01:00
|
|
|
SOGoUser *currentUser;
|
2007-11-19 17:37:20 +01:00
|
|
|
|
2007-11-19 22:07:54 +01:00
|
|
|
if ([clientObject isKindOfClass: [SOGoAppointmentObject class]])
|
2007-11-19 17:37:20 +01:00
|
|
|
adminToolbar = @"SOGoAppointmentObject.toolbar";
|
2007-06-01 23:01:44 +02:00
|
|
|
else
|
2007-11-19 17:37:20 +01:00
|
|
|
adminToolbar = @"SOGoTaskObject.toolbar";
|
|
|
|
|
2007-12-21 22:38:58 +01:00
|
|
|
currentUser = [context activeUser];
|
2007-11-19 17:37:20 +01:00
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
2008-08-09 17:19:10 +02:00
|
|
|
|
|
|
|
if (![sm validatePermission: SOGoCalendarPerm_ModifyComponent
|
2009-07-27 14:48:27 +02:00
|
|
|
onObject: clientObject
|
|
|
|
inContext: context])
|
2008-08-09 17:19:10 +02:00
|
|
|
toolbarFilename = [self _toolbarForOwner: ownerUser
|
2009-07-27 14:48:27 +02:00
|
|
|
andClientObject: clientObject];
|
2007-11-19 17:37:20 +01:00
|
|
|
else
|
2009-07-27 14:48:27 +02:00
|
|
|
toolbarFilename = @"SOGoEmpty.toolbar";
|
2007-11-19 17:37:20 +01:00
|
|
|
|
|
|
|
return toolbarFilename;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) toolbar
|
|
|
|
{
|
2008-08-09 17:19:10 +02:00
|
|
|
SOGoContentObject <SOGoComponentOccurence> *clientObject;
|
2007-11-19 17:37:20 +01:00
|
|
|
NSString *toolbarFilename;
|
|
|
|
SOGoUser *ownerUser;
|
|
|
|
|
|
|
|
clientObject = [self clientObject];
|
|
|
|
ownerUser = [SOGoUser userWithLogin: [clientObject ownerInContext: context]
|
|
|
|
roles: nil];
|
|
|
|
|
|
|
|
if ([ownerUser isEqual: [context activeUser]])
|
2007-11-19 22:07:54 +01:00
|
|
|
toolbarFilename = [self _toolbarForOwner: ownerUser
|
|
|
|
andClientObject: clientObject];
|
2007-11-19 17:37:20 +01:00
|
|
|
else
|
2007-11-19 22:07:54 +01:00
|
|
|
toolbarFilename = [self _toolbarForDelegate: ownerUser
|
|
|
|
andClientObject: clientObject];
|
2007-11-19 17:37:20 +01:00
|
|
|
|
2007-05-03 18:13:51 +02:00
|
|
|
|
|
|
|
return toolbarFilename;
|
|
|
|
}
|
|
|
|
|
2009-07-23 22:11:06 +02:00
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (int) ownerIsAttendee: (SOGoUser *) ownerUser
|
2009-07-23 22:11:06 +02:00
|
|
|
andClientObject: (SOGoContentObject
|
|
|
|
<SOGoComponentOccurence> *) clientObject
|
|
|
|
{
|
2009-07-27 14:48:27 +02:00
|
|
|
BOOL isOrganizer;
|
|
|
|
int rc = 0;
|
2009-07-23 22:11:06 +02:00
|
|
|
|
|
|
|
isOrganizer = [component userIsOrganizer: ownerUser];
|
|
|
|
if (isOrganizer)
|
|
|
|
isOrganizer = ![ownerUser hasEmail: [[component organizer] sentBy]];
|
|
|
|
|
|
|
|
if ([[component attendees] count]
|
|
|
|
&& [component userIsParticipant: ownerUser]
|
|
|
|
&& !isOrganizer
|
|
|
|
&& ![[component tag] isEqualToString: @"VTODO"])
|
2009-07-27 14:48:27 +02:00
|
|
|
rc = 1;
|
2009-07-23 22:11:06 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (int) delegateIsAttendee: (SOGoUser *) ownerUser
|
2009-07-23 22:11:06 +02:00
|
|
|
andClientObject: (SOGoContentObject
|
|
|
|
<SOGoComponentOccurence> *) clientObject
|
|
|
|
{
|
|
|
|
SoSecurityManager *sm;
|
|
|
|
SOGoUser *currentUser;
|
2009-07-27 14:48:27 +02:00
|
|
|
int rc = 0;
|
2009-07-23 22:11:06 +02:00
|
|
|
|
|
|
|
currentUser = [context activeUser];
|
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
|
|
|
|
|
|
|
if (![sm validatePermission: SOGoCalendarPerm_ModifyComponent
|
|
|
|
onObject: clientObject
|
|
|
|
inContext: context])
|
|
|
|
rc = [self ownerIsAttendee: ownerUser
|
|
|
|
andClientObject: clientObject];
|
|
|
|
else if (![sm validatePermission: SOGoCalendarPerm_RespondToComponent
|
|
|
|
onObject: clientObject
|
|
|
|
inContext: context]
|
|
|
|
&& [[component attendees] count]
|
|
|
|
&& [component userIsParticipant: ownerUser]
|
|
|
|
&& ![component userIsOrganizer: ownerUser])
|
2009-07-27 14:48:27 +02:00
|
|
|
rc = 1;
|
2009-07-23 22:11:06 +02:00
|
|
|
else
|
2009-07-27 14:48:27 +02:00
|
|
|
rc = 2; // not invited, just RO
|
2009-07-23 22:11:06 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (int) getEventRWType
|
2009-07-23 22:11:06 +02:00
|
|
|
{
|
|
|
|
SOGoContentObject <SOGoComponentOccurence> *clientObject;
|
|
|
|
SOGoUser *ownerUser;
|
2009-07-27 14:48:27 +02:00
|
|
|
int rc = 0;
|
2009-07-23 22:11:06 +02:00
|
|
|
|
|
|
|
clientObject = [self clientObject];
|
|
|
|
ownerUser = [SOGoUser userWithLogin: [clientObject ownerInContext: context]
|
|
|
|
roles: nil];
|
|
|
|
|
|
|
|
if ([ownerUser isEqual: [context activeUser]])
|
|
|
|
rc = [self ownerIsAttendee: ownerUser
|
|
|
|
andClientObject: clientObject];
|
|
|
|
else
|
|
|
|
rc = [self delegateIsAttendee: ownerUser
|
|
|
|
andClientObject: clientObject];
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) eventIsReadOnly
|
2009-07-23 22:11:06 +02:00
|
|
|
{
|
2009-07-27 14:48:27 +02:00
|
|
|
return [self getEventRWType] != 0;
|
|
|
|
}
|
2009-07-23 22:11:06 +02:00
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (BOOL) userIsAttendee
|
|
|
|
{
|
|
|
|
return [self getEventRWType] == 1;
|
2009-07-23 22:11:06 +02:00
|
|
|
}
|
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (NSCalendarDate *) getDateFor: (NSString *) when
|
2009-07-23 22:11:06 +02:00
|
|
|
{
|
2009-07-27 14:48:27 +02:00
|
|
|
NSCalendarDate *startDate, *endDate, *firstDate, *rc;
|
2009-07-23 22:11:06 +02:00
|
|
|
NSTimeZone *timeZone;
|
|
|
|
iCalEvent *master;
|
|
|
|
signed int daylightOffset;
|
|
|
|
|
|
|
|
startDate = [component startDate];
|
|
|
|
daylightOffset = 0;
|
|
|
|
|
|
|
|
if ([component isKindOfClass: [SOGoAppointmentOccurence class]])
|
|
|
|
{
|
|
|
|
master = (iCalEvent*)[[component parent] firstChildWithTag: @"vevent"];
|
|
|
|
firstDate = [master startDate];
|
|
|
|
timeZone = [[context activeUser] timeZone];
|
|
|
|
|
|
|
|
if ([timeZone isDaylightSavingTimeForDate: startDate] != [timeZone isDaylightSavingTimeForDate: firstDate])
|
|
|
|
{
|
|
|
|
daylightOffset = (signed int)[timeZone secondsFromGMTForDate: firstDate]
|
|
|
|
- (signed int)[timeZone secondsFromGMTForDate: startDate];
|
|
|
|
startDate = [startDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 14:48:27 +02:00
|
|
|
[startDate setTimeZone: [[context activeUser] timeZone]];
|
2009-07-23 22:11:06 +02:00
|
|
|
endDate = [[component endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
|
|
|
|
[endDate setTimeZone: [[context activeUser] timeZone]];
|
2009-07-27 14:48:27 +02:00
|
|
|
|
|
|
|
if ([when isEqualToString: @"start"])
|
|
|
|
rc = startDate;
|
|
|
|
else
|
|
|
|
rc = endDate;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2009-07-23 22:11:06 +02:00
|
|
|
|
2009-07-27 14:48:27 +02:00
|
|
|
- (NSString *) startDateString
|
|
|
|
{
|
|
|
|
return [[self getDateFor: @"start"] description];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) endDateString
|
|
|
|
{
|
|
|
|
return [[self getDateFor: @"end"] description];
|
2009-07-23 22:11:06 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 16:42:44 +02:00
|
|
|
@end
|