From 592363915453bbd79dca995b7a06fd9a994ff484 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 3 Dec 2019 16:42:36 -0500 Subject: [PATCH] fix(calendar): raise warning when MuiltipleBookings is set to -1 --- .../Appointments/SOGoAppointmentObject.h | 5 +---- .../Appointments/SOGoAppointmentObject.m | 22 ++++++++----------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.h b/SoObjects/Appointments/SOGoAppointmentObject.h index 1cb7483f9..b6edd16b4 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.h +++ b/SoObjects/Appointments/SOGoAppointmentObject.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2018 Inverse inc. + Copyright (C) 2007-2019 Inverse inc. This file is part of SOGo @@ -37,7 +37,6 @@ @interface SOGoAppointmentObject : SOGoCalendarComponent { - BOOL _resourceHasAutoAccepted; } - (NSException *) changeParticipationStatus: (NSString *) status @@ -62,8 +61,6 @@ - (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar fromRequest: (WORequest *) rq; -- (BOOL) resourceHasAutoAccepted; - @end #endif /* __Appointments_SOGoAppointmentObject_H__ */ diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 4cd5e7a6c..77a31ec95 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -627,8 +627,6 @@ NSString *currentUID; SOGoUser *user, *currentUser; - _resourceHasAutoAccepted = NO; - // Build a list of the attendees uids attendees = [NSMutableArray arrayWithCapacity: [theAttendees count]]; enumerator = [theAttendees objectEnumerator]; @@ -763,23 +761,27 @@ if ([fbInfo count]) { + BOOL resourceHasAutoAccepted; SOGoDateFormatter *formatter; + resourceHasAutoAccepted = NO; formatter = [[context activeUser] dateFormatterInContext: context]; if ([user isResource]) { - // If we always force the auto-accept if numberOfSimultaneousBookings <= 0 (ie., no limit + // We always force the auto-accept if numberOfSimultaneousBookings <= 0 (ie., no limit // is imposed) or if numberOfSimultaneousBookings is greater than the number of - // overlapping events + // overlapping events. + // When numberOfSimultaneousBookings is set to -1, only force the auto-accept + // once the conflict has been raised and the action is forced by the user. if ([user numberOfSimultaneousBookings] <= 0 || [user numberOfSimultaneousBookings] > [fbInfo count]) { - if (currentAttendee) + if (currentAttendee && ([user numberOfSimultaneousBookings] >= 0 || forceSave)) { [[currentAttendee attributes] removeObjectForKey: @"RSVP"]; [currentAttendee setParticipationStatus: iCalPersonPartStatAccepted]; - _resourceHasAutoAccepted = YES; + resourceHasAutoAccepted = YES; } } else @@ -812,7 +814,7 @@ // We are dealing with a normal attendee. Lets check if we have conflicts, unless // we are being asked to force the save anyway // - else if (!forceSave) + if (!forceSave && !resourceHasAutoAccepted) { NSMutableDictionary *info; NSMutableArray *conflicts; @@ -866,7 +868,6 @@ // set the resource as one! [[currentAttendee attributes] removeObjectForKey: @"RSVP"]; [currentAttendee setParticipationStatus: iCalPersonPartStatAccepted]; - _resourceHasAutoAccepted = YES; } } @@ -2530,9 +2531,4 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent return response; } -- (BOOL) resourceHasAutoAccepted -{ - return _resourceHasAutoAccepted; -} - @end /* SOGoAppointmentObject */