From 73f46d7bd47e83803d39e4572ab1aaf462ef54b3 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 19 Mar 2007 14:33:33 +0000 Subject: [PATCH] Monotone-Parent: d82fb8d772781e04d5580932b0fd265f31ee1e3b Monotone-Revision: f4e3cbe3387384c78112b9db5195de5649161cac Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-03-19T14:33:33 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 ++++ UI/Scheduler/UIxComponentEditor.m | 67 +++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8893994b..89d0fbce3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-03-19 Wolfgang Sourdeau + + * UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor + -_handleAttendeesEdition]): make sure "attendeesNames" has a + length > 0 before computing the attendees. Otherwise there will be + an invalid empty entry. + 2007-03-18 Wolfgang Sourdeau * UI/Scheduler/UIxAttendeesEditor.m): new component. diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 0094abc5c..03479b991 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -761,29 +761,57 @@ iCalPerson *currentAttendee; newAttendees = [NSMutableArray new]; - names = [attendeesNames componentsSeparatedByString: @","]; - emails = [attendeesEmails componentsSeparatedByString: @","]; - max = [emails count]; - for (count = 0; count < max; count++) + if ([attendeesNames length] > 0) { - 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"]; - [currentAttendee - setParticipationStatus: iCalPersonPartStatNeedsAction]; - } - [newAttendees addObject: currentAttendee]; + 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"]; + [currentAttendee + setParticipationStatus: iCalPersonPartStatNeedsAction]; + } + [newAttendees addObject: currentAttendee]; + } } [component setAttendees: newAttendees]; [newAttendees release]; } +- (void) _handleOrganizer +{ + NSString *organizerEmail; + + organizerEmail = [[component organizer] email]; + if ([organizerEmail length] == 0) + { + if ([[component attendees] count] > 0) + { + ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]); + [organizer setCn: [self cnForUser]]; + [organizer setEmail: [self emailForUser]]; + [component setOrganizer: organizer]; + } + } + else + { + if ([[component attendees] count] == 0) + { + ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]); + [component setOrganizer: organizer]; + } + } +} + - (void) takeValuesFromRequest: (WORequest *) _rq inContext: (WOContext *) _ctx { @@ -796,18 +824,15 @@ [component setLocation: location]; [component setComment: comment]; [component setUrl: url]; + [self _handleAttendeesEdition]; + [self _handleOrganizer]; if ([[self clientObject] isNew]) { - ASSIGN (organizer, [iCalPerson elementWithTag: @"organizer"]); - [organizer setCn: [self cnForUser]]; - [organizer setEmail: [self emailForUser]]; - [component setOrganizer: organizer]; [component setCreated: now]; [component setTimeStampAsDate: now]; [component setPriority: @"0"]; } [component setLastModified: now]; - [self _handleAttendeesEdition]; } @end