From 4e5c865a3f8fae2f3f60c3e01a29e50be312eae3 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 14 Apr 2022 20:39:36 -0400 Subject: [PATCH] feat(calendar): optionally remove attendees that can't be invited If some attendees have prevented others to invite them, offer the organizer to remove them when saving the invitation. --- .../Appointments/SOGoAppointmentObject.m | 15 ++++++++--- .../English.lproj/Localizable.strings | 2 ++ UI/Scheduler/UIxAppointmentEditor.m | 26 +++++++++++++++++++ .../UIxAppointmentEditorTemplate.wox | 18 +++++++++---- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index f0f5376db..829e1a81f 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -531,11 +531,11 @@ iCalPerson *currentAttendee; SOGoUser *user; SOGoUserSettings *us; - NSMutableArray *unavailableAttendees; + NSMutableArray *unavailableAttendees, *unavailableEmails; NSEnumerator *enumerator; NSString *currentUID, *ownerUID; NSMutableString *reason; - NSDictionary *values; + NSDictionary *values, *info; NSMutableDictionary *value, *moduleSettings; id whiteList; @@ -545,6 +545,7 @@ // Build list of the attendees uids unavailableAttendees = [[NSMutableArray alloc] init]; + unavailableEmails = [NSMutableArray array]; enumerator = [theAttendees objectEnumerator]; ownerUID = [[[self context] activeUser] login]; @@ -573,6 +574,7 @@ { values = [NSDictionary dictionaryWithObject:[user cn] forKey:@"Cn"]; [unavailableAttendees addObject:values]; + [unavailableEmails addObject: [currentAttendee rfc822Email]]; } } } @@ -592,7 +594,14 @@ if (i < count-2) [reason appendString:@", "]; } - + + if (count < [theAttendees count]) + { + info = [NSDictionary dictionaryWithObjectsAndKeys: + reason, @"reject", + unavailableEmails, @"unavailableAttendees", nil]; + reason = [NSMutableString stringWithString: [info jsonRepresentation]]; + } [unavailableAttendees release]; return [self exceptionWithHTTPStatus:409 reason: reason]; diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index dae1a0e8e..6b9afae61 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -499,6 +499,8 @@ validate_untilbeforeend = "The recurrence must end after the first occurrence "and" = "and"; "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" = "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; +"Would you like to remove them and send the invitation to the remaining attendees?" += "Would you like to remove them and send the invitation to the remaining attendees?"; /* events list */ "Due" = "Due"; diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index 45718b9b4..92d0d9e5a 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -263,6 +263,24 @@ return ex; } +- (void) _removeAttendees: (NSArray *) emails +{ + NSString *email; + iCalEvent *event; + iCalPerson *attendee; + unsigned int i; + + event = [self event]; + attendee = [[[iCalPerson alloc] init] autorelease]; + + for (i = 0; i < [emails count]; i++) + { + email = [emails objectAtIndex: i]; + [attendee setEmail: email]; + [event removeFromAttendees: attendee]; + } +} + /** * @api {post} /so/:username/Calendar/:calendarId/:appointmentId/rsvpAppointment Set participation state * @apiVersion 1.0.0 @@ -512,6 +530,7 @@ */ - (id ) saveAction { + NSArray *removeAttendees; NSDictionary *params; NSString *jsonResponse; NSException *ex; @@ -545,12 +564,19 @@ { [self setAttributes: params]; forceSave = [[params objectForKey: @"ignoreConflicts"] boolValue]; + removeAttendees = [params objectForKey: @"removeAttendees"]; if ([event hasRecurrenceRules]) ex = [self _adjustRecurrentRules]; if (!ex) { + if (removeAttendees) + { + [co expandGroupsInEvent: event]; + [self _removeAttendees: removeAttendees]; + } + if ([co isNew]) { if (componentCalendar diff --git a/UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox b/UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox index 8af537e22..fd3750063 100644 --- a/UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox +++ b/UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox @@ -366,12 +366,15 @@ - -
{{editor.attendeeConflictError.reject}}
- - close - +
+
+ + close + +
+
@@ -381,6 +384,11 @@ ng-click="editor.edit(eventForm)"> + + +