From e3be0dd8d2346b19a2fd825b57c326415fedead2 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 7 Nov 2006 19:24:36 +0000 Subject: [PATCH] Monotone-Parent: ef81b9d9e2e16755688f926ca3a982aa4c9bf513 Monotone-Revision: cd3467d9325955f5de25492e730817938dea9c3c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-11-07T19:24:36 Monotone-Branch: ca.inverse.sogo --- UI/Scheduler/UIxComponentEditor.h | 3 +- UI/Scheduler/UIxComponentEditor.m | 77 +++++++++++++++++-------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/UI/Scheduler/UIxComponentEditor.h b/UI/Scheduler/UIxComponentEditor.h index c315d0a44..b240e9e9c 100644 --- a/UI/Scheduler/UIxComponentEditor.h +++ b/UI/Scheduler/UIxComponentEditor.h @@ -59,6 +59,8 @@ NSDictionary *cycle; NSString *cycleEnd; NSString *componentOwner; + + BOOL componentLoaded; } - (NSArray *) categoryItems; @@ -140,7 +142,6 @@ /* access */ - (BOOL) isMyComponent; -- (BOOL) canAccessComponent; - (BOOL) canEditComponent; /* helpers */ diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index b80ad4d9a..d5f63f1b7 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -59,6 +59,7 @@ [self setCheckForConflicts: NO]; [self setIsCycleEndNever]; componentOwner = @""; + componentLoaded = NO; } return self; @@ -572,11 +573,6 @@ return ([[organizer rfc822Email] isEqualToString: [self emailForUser]]); } -- (BOOL) canAccessComponent -{ - return [self isMyComponent]; -} - - (BOOL) canEditComponent { return [self isMyComponent]; @@ -633,7 +629,8 @@ co = [self clientObject]; componentOwner = [co ownerInContext: nil]; - + componentLoaded = YES; + startDate = [component startDate]; // if ((startDate = [component startDate]) == nil) // startDate = [[NSCalendarDate date] hour:11 minute:0]; @@ -811,43 +808,55 @@ return classes; } -- (NSString *) toolbar +- (NSString *) _toolbarForCalObject: (iCalEntityObject *) calObject { NSString *filename, *myEmail; - iCalEntityObject *calObject; iCalPersonPartStat myParticipationStatus; - id co; - BOOL isEditable; - co = [self clientObject]; - isEditable = YES; - if ([co isKindOfClass: [SOGoAppointmentObject class]]) - calObject = (iCalEntityObject *) [co event]; - else if ([co isKindOfClass: [SOGoTaskObject class]]) - calObject = (iCalEntityObject *) [co task]; + myEmail = [[[self context] activeUser] email]; + if ([self canEditComponent]) + filename = @"SOGoAppointmentObject.toolbar"; else - isEditable = NO; - if (isEditable) { - myEmail = [[[self context] activeUser] email]; - if ([self canEditComponent]) - filename = @"SOGoAppointmentObject.toolbar"; - else + if ([calObject isParticipant: myEmail]) { - if ([calObject isParticipant: myEmail]) - { - myParticipationStatus - = [[calObject findParticipantWithEmail: myEmail] participationStatus]; - if (myParticipationStatus == iCalPersonPartStatAccepted) - filename = @"SOGoAppointmentObjectDecline.toolbar"; - else if (myParticipationStatus == iCalPersonPartStatDeclined) - filename = @"SOGoAppointmentObjectAccept.toolbar"; - else - filename = @"SOGoAppointmentObjectAcceptOrDecline.toolbar"; - } + myParticipationStatus + = [[calObject findParticipantWithEmail: myEmail] participationStatus]; + if (myParticipationStatus == iCalPersonPartStatAccepted) + filename = @"SOGoAppointmentObjectDecline.toolbar"; + else if (myParticipationStatus == iCalPersonPartStatDeclined) + filename = @"SOGoAppointmentObjectAccept.toolbar"; else - filename = @""; + filename = @"SOGoAppointmentObjectAcceptOrDecline.toolbar"; } + else + filename = @""; + } + + return filename; +} + +- (NSString *) toolbar +{ + NSString *filename; + iCalEntityObject *calObject; + id co; + + if (componentLoaded) + { + co = [self clientObject]; + if ([co isKindOfClass: [SOGoAppointmentObject class]]) + { + calObject = (iCalEntityObject *) [co event]; + filename = [self _toolbarForCalObject: calObject]; + } + else if ([co isKindOfClass: [SOGoTaskObject class]]) + { + calObject = (iCalEntityObject *) [co task]; + filename = [self _toolbarForCalObject: calObject]; + } + else + filename = @""; } else filename = @"";