diff --git a/ChangeLog b/ChangeLog index fbb7b7bf0..795b0ab57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-08-11 Francis Lachapelle + + * UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor + -_handleOrganizer]): remove organizer when the event has no attendee. + ([UIxComponentEditor -_toolbarForOwner:andClientObject:]): return + the proper toolbar when editing the occurrence of a repeating event. + + * SoObjects/Appointments/SOGoAppointmentObject.m + ([SOGoAppointmentObject -saveComponent:]): when removing a single + attendee from an event, the organizer is no longer defined; + therefore, we must check if the owner is the organizer of the + previous version of the event, not the new event. + 2009-08-10 Ludovic Marcotte * SoObjects/SOGo/LDAPUserManager.m diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 0f6ac3bfa..d92a7b9f6 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -274,6 +274,13 @@ } else { + // TODO : if [theEvent recurrenceId], only update this occurrence + // in attendee's calendar + + // TODO : when updating the master event, handle exception dates + // in attendee's calendar (add exception dates and remove matching + // occurrences) -- see _updateRecurrenceIDsWithEvent: + iCalString = [[theEvent parent] versitString]; } @@ -508,46 +515,44 @@ // as the event's UID might get modified in SOGoCalendarComponent: -saveComponent: [super saveComponent: newEvent]; - if ([newEvent userIsOrganizer: ownerUser]) + if ([self isNew]) { - if ([self isNew]) + // New event -- send invitation to all attendees + attendees = [newEvent attendeesWithoutUser: ownerUser]; + if ([attendees count]) { - // New event -- send invitation to all attendees - attendees = [newEvent attendeesWithoutUser: ownerUser]; - if ([attendees count]) - { - [self _handleAddedUsers: attendees fromEvent: newEvent]; - [self sendEMailUsingTemplateNamed: @"Invitation" - forObject: [newEvent itipEntryWithMethod: @"request"] - previousObject: nil - toAttendees: attendees]; - } - - if (![[newEvent attendees] count]) - [[newEvent uniqueChildWithTag: @"organizer"] setValue: 0 - to: @""]; + [self _handleAddedUsers: attendees fromEvent: newEvent]; + [self sendEMailUsingTemplateNamed: @"Invitation" + forObject: [newEvent itipEntryWithMethod: @"request"] + previousObject: nil + toAttendees: attendees]; } + } + else + { + // Event is modified -- sent update status to all attendees + // and modify their calendars. + recurrenceId = [newEvent recurrenceId]; + if (recurrenceId == nil) + oldEvent = [self component: NO secure: NO]; else { - // Event is modified -- sent update status to all attendees - // and modify their calendars. - recurrenceId = [newEvent recurrenceId]; - if (recurrenceId == nil) - oldEvent = [self component: NO secure: NO]; - else - { - // If recurrenceId is defined, find the specified occurence - // within the repeating vEvent. - recurrenceTime = [NSString stringWithFormat: @"%f", [recurrenceId timeIntervalSince1970]]; - oldEvent = (iCalEvent*)[self lookupOccurence: recurrenceTime]; - if (oldEvent == nil) - // If no occurence found, create one - oldEvent = (iCalEvent*)[self newOccurenceWithID: recurrenceTime]; - } + // If recurrenceId is defined, find the specified occurence + // within the repeating vEvent. + recurrenceTime = [NSString stringWithFormat: @"%f", [recurrenceId timeIntervalSince1970]]; + oldEvent = (iCalEvent*)[self lookupOccurence: recurrenceTime]; + if (oldEvent == nil) + // If no occurence found, create one + oldEvent = (iCalEvent*)[self newOccurenceWithID: recurrenceTime]; + } + + if ([[[oldEvent parent] firstChildWithTag: @"vevent"] userIsOrganizer: ownerUser]) + { + // The owner is the organizer of the event; handle the modifications + [self _handleUpdatedEvent: newEvent fromOldEvent: oldEvent]; // The sequence has possibly been increased -- resave the event. - // This will also take care of a decomposed group. [super saveComponent: newEvent]; } } diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 3e6fa16b5..a26545287 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -1535,25 +1535,23 @@ RANGE(2); { NSString *organizerEmail; NSString *owner, *login; - BOOL isOwner, hasOrganizer, hasAttendees; + BOOL isOwner; //owner = [[self clientObject] ownerInContext: context]; owner = [componentCalendar ownerInContext: context]; login = [[context activeUser] login]; isOwner = [owner isEqualToString: login]; hasAttendees = [self hasAttendees]; - organizerEmail = [[component organizer] email]; - hasOrganizer = ([organizerEmail length] > 0); #if 1 - ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]); - [component setOrganizer: organizer]; - if (hasAttendees) { SOGoUser *user; id identity; + ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]); + [component setOrganizer: organizer]; + user = [SOGoUser userWithLogin: owner roles: nil]; identity = [user defaultIdentity]; [organizer setCn: [identity objectForKey: @"fullName"]]; @@ -1568,7 +1566,15 @@ RANGE(2); value: [NSString stringWithFormat: @"\"MAILTO:%@\"", currentEmail]]; } } + else + { + organizer = nil; + } + [component setOrganizer: organizer]; #else + BOOL hasOrganizer, hasAttendees; + organizerEmail = [[component organizer] email]; + hasOrganizer = ([organizerEmail length] > 0); if (hasOrganizer) { if (isOwner && !hasAttendees) @@ -1924,7 +1930,8 @@ RANGE(2); toolbarFilename = @"SOGoEmpty.toolbar"; else { - if ([clientObject isKindOfClass: [SOGoAppointmentObject class]]) + if ([clientObject isKindOfClass: [SOGoAppointmentObject class]] + || [clientObject isKindOfClass: [SOGoAppointmentOccurence class]]) toolbarFilename = @"SOGoAppointmentObject.toolbar"; else toolbarFilename = @"SOGoTaskObject.toolbar";