diff --git a/ChangeLog b/ChangeLog index 9b26ca28c..a81676055 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2007-11-19 Wolfgang Sourdeau + * UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor + -toolbar]): rewrote in a way that ensures that each case is + handled properly. + + * SoObjects/SOGo/SOGoUser.m ([SOGoUser -isEqual:otherUser]): new + override method. + * UI/Scheduler/UIxTaskEditor.m ([-acceptAction]) ([-declineAction]): commented out unused methods. diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 95f32ac96..e81214d5e 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -606,4 +606,10 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; return rolesForObject; } +- (BOOL) isEqual: (id) otherUser +{ + return ([otherUser isKindOfClass: [SoUser class]] + && [login isEqualToString: [otherUser login]]); +} + @end /* SOGoUser */ diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 04e4ee1af..3916100f4 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -41,11 +41,13 @@ #import #import +#import #import #import #import #import #import +#import #import #import #import @@ -904,27 +906,18 @@ [component setLastModified: now]; } -- (NSString *) toolbar +#warning the following methods probably share some code... +- (NSString *) _toolbarForOwner: (SOGoUser *) ownerUser { - SOGoCalendarComponent *clientObject; NSString *toolbarFilename; - iCalPerson *participant; iCalPersonPartStat participationStatus; - SoSecurityManager *sm; - NSString *owner; - sm = [SoSecurityManager sharedSecurityManager]; - clientObject = [self clientObject]; - - owner = [clientObject ownerInContext: context]; - participant = [clientObject findParticipantWithUID: owner]; - - if (participant - && ![sm validatePermission: SOGoCalendarPerm_RespondToComponent - onObject: clientObject - inContext: context]) + if ([[component attendees] count] + && [component userIsParticipant: ownerUser] + && ![component userIsOrganizer: ownerUser]) { - participationStatus = [participant participationStatus]; + participationStatus + = [[component findParticipant: ownerUser] participationStatus]; /* Lightning does not manage participation status within tasks */ if (participationStatus == iCalPersonPartStatAccepted) toolbarFilename = @"SOGoAppointmentObjectDecline.toolbar"; @@ -933,17 +926,85 @@ else toolbarFilename = @"SOGoAppointmentObjectAcceptOrDecline.toolbar"; } - else if (![sm validatePermission: SOGoCalendarPerm_ModifyComponent - onObject: clientObject - inContext: context]) + else { - if ([[clientObject componentTag] isEqualToString: @"vevent"]) + if ([component isKindOfClass: [iCalEvent class]]) toolbarFilename = @"SOGoAppointmentObject.toolbar"; else toolbarFilename = @"SOGoTaskObject.toolbar"; } + + return toolbarFilename; +} + +- (NSString *) _toolbarForDelegate: (SOGoUser *) ownerUser +{ + SOGoCalendarComponent *clientObject; + SoSecurityManager *sm; + NSString *toolbarFilename, *adminToolbar; + iCalPersonPartStat participationStatus; + + clientObject = [self clientObject]; + + if ([component isKindOfClass: [iCalEvent class]]) + adminToolbar = @"SOGoAppointmentObject.toolbar"; else - toolbarFilename = @"SOGoComponentClose.toolbar"; + adminToolbar = @"SOGoTaskObject.toolbar"; + + sm = [SoSecurityManager sharedSecurityManager]; + if ([[component attendees] count]) + { + if ([component userIsOrganizer: ownerUser] + && ![sm validatePermission: SOGoCalendarPerm_ModifyComponent + onObject: clientObject + inContext: context]) + toolbarFilename = adminToolbar; + else if ([component userIsParticipant: ownerUser] + && ![sm validatePermission: SOGoCalendarPerm_RespondToComponent + onObject: clientObject + inContext: context]) + { + participationStatus + = [[component findParticipant: ownerUser] participationStatus]; + /* Lightning does not manage participation status within tasks */ + if (participationStatus == iCalPersonPartStatAccepted) + toolbarFilename = @"SOGoAppointmentObjectDecline.toolbar"; + else if (participationStatus == iCalPersonPartStatDeclined) + toolbarFilename = @"SOGoAppointmentObjectAccept.toolbar"; + else + toolbarFilename = @"SOGoAppointmentObjectAcceptOrDecline.toolbar"; + } + else + toolbarFilename = @"SOGoComponentClose.toolbar"; + } + else + { + if (![sm validatePermission: SOGoCalendarPerm_ModifyComponent + onObject: clientObject + inContext: context]) + toolbarFilename = adminToolbar; + else + toolbarFilename = @"SOGoComponentClose.toolbar"; + } + + return toolbarFilename; +} + +- (NSString *) toolbar +{ + SOGoCalendarComponent *clientObject; + NSString *toolbarFilename; + SOGoUser *ownerUser; + + clientObject = [self clientObject]; + ownerUser = [SOGoUser userWithLogin: [clientObject ownerInContext: context] + roles: nil]; + + if ([ownerUser isEqual: [context activeUser]]) + toolbarFilename = [self _toolbarForOwner: ownerUser]; + else + toolbarFilename = [self _toolbarForDelegate: ownerUser]; + return toolbarFilename; }