Mantis 78

Monotone-Parent: 757b3c1280d9af553772340bd7408a4ff375bda6
Monotone-Revision: 244b022b573e6f31bb6d274bcd23e14acd12414b

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-07-23T20:11:06
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
C Robert
2009-07-23 20:11:06 +00:00
parent 816b22defa
commit 949d2af8cc
6 changed files with 355 additions and 55 deletions

View File

@@ -50,6 +50,7 @@
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
#import <SoObjects/Appointments/SOGoAppointmentFolders.h>
#import <SoObjects/Appointments/SOGoAppointmentObject.h>
#import <SoObjects/Appointments/SOGoAppointmentOccurence.h>
#import <SoObjects/Appointments/SOGoTaskObject.h>
#import <SoObjects/SOGo/iCalEntityObject+Utilities.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
@@ -875,6 +876,18 @@ iRANGE(2);
return text;
}
- (NSString *) repeatLabel
{
NSString *rc;
if ([self repeat])
rc = [self labelForKey: [NSString stringWithFormat: @"repeat_%@", [self repeat]]];
else
rc = [self labelForKey: @"repeat_NEVER"];
return rc;
}
- (NSArray *) reminderList
{
return reminderItems;
@@ -1929,4 +1942,134 @@ RANGE(2);
return toolbarFilename;
}
- (BOOL) ownerIsAttendee: (SOGoUser *) ownerUser
andClientObject: (SOGoContentObject
<SOGoComponentOccurence> *) clientObject
{
BOOL isOrganizer, rc = NO;
isOrganizer = [component userIsOrganizer: ownerUser];
if (isOrganizer)
isOrganizer = ![ownerUser hasEmail: [[component organizer] sentBy]];
if ([[component attendees] count]
&& [component userIsParticipant: ownerUser]
&& !isOrganizer
&& ![[component tag] isEqualToString: @"VTODO"])
rc = YES;
return rc;
}
- (BOOL) delegateIsAttendee: (SOGoUser *) ownerUser
andClientObject: (SOGoContentObject
<SOGoComponentOccurence> *) clientObject
{
SoSecurityManager *sm;
SOGoUser *currentUser;
BOOL rc = NO;
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])
rc = YES;
else
rc = YES;
return rc;
}
- (BOOL) eventIsReadOnly
{
SOGoContentObject <SOGoComponentOccurence> *clientObject;
SOGoUser *ownerUser;
BOOL rc = NO;
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;
}
- (NSString *) startDateString
{
NSCalendarDate *startDate;
NSCalendarDate *firstDate;
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];
}
}
[startDate setTimeZone: [[context activeUser] timeZone]];
return [startDate description];
}
- (NSString *) endDateString
{
NSCalendarDate *startDate, *endDate;
NSCalendarDate *firstDate;
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];
}
}
endDate = [[component endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:daylightOffset];
[endDate setTimeZone: [[context activeUser] timeZone]];
return [endDate description];
}
@end