From 02b3de6465c85e254f265cedb28a0e96aeef6f31 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 15 Sep 2014 09:32:36 -0400 Subject: [PATCH] Fix for bug #2326 --- NEWS | 1 + .../Appointments/SOGoAppointmentObject.m | 50 ++++++++++++++++--- UI/Scheduler/UIxComponentEditor.m | 16 +++--- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index fe78bb0cf..208096897 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ New features Enchancements - alarms can now be snoozed for 1 day - better iCal compability regarding alarms (#1920) + - force default classification over CalDAV if none is set (#2326) Bug fixes - diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 80c6700f3..655fb36c8 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2013 Inverse inc. + Copyright (C) 2007-2014 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG This file is part of SOGo @@ -49,6 +49,7 @@ #import #import #import +#import #import #import #import @@ -1668,9 +1669,41 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent } } +- (void) _adjustClassificationInRequestCalendar: (iCalCalendar *) rqCalendar +{ + SOGoUserDefaults *userDefaults; + NSString *accessClass; + NSArray *allObjects; + id entity; + + int i; + + userDefaults = [[context activeUser] userDefaults]; + allObjects = [rqCalendar allObjects]; + + for (i = 0; i < [allObjects count]; i++) + { + entity = [allObjects objectAtIndex: i]; + + if ([entity respondsToSelector: @selector(accessClass)]) + { + accessClass = [entity accessClass]; + + if (!accessClass || [accessClass length] == 0) + { + if ([entity isKindOfClass: [iCalEvent class]]) + [entity setAccessClass: [userDefaults calendarEventsDefaultClassification]]; + else if ([entity isKindOfClass: [iCalToDo class]]) + [entity setAccessClass: [userDefaults calendarTasksDefaultClassification]]; + } + } + } +} + /** * Verify vCalendar for any inconsistency or missing attributes. * Currently only check if the events have an end date or a duration. + * We also check for the default transparency parameters. * @param rq the HTTP PUT request */ - (void) _adjustEventsInRequestCalendar: (iCalCalendar *) rqCalendar @@ -1694,6 +1727,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent [event setDuration: @"PT1H"]; [self warnWithFormat: @"Invalid event: no end date; setting duration to %@", [event duration]]; } + + } } @@ -1816,6 +1851,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent } [self _adjustEventsInRequestCalendar: calendar]; + [self _adjustClassificationInRequestCalendar: calendar]; } // @@ -2111,10 +2147,10 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent WORequest *rq; WOResponse *response; iCalCalendar *rqCalendar; - + rq = [_ctx request]; rqCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]]; - + if (![self isNew]) { // @@ -2126,10 +2162,10 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent if (ex) return ex; } - - ex = [self updateContentWithCalendar: rqCalendar fromRequest: rq]; - if (ex) - response = (WOResponse *) ex; + + ex = [self updateContentWithCalendar: rqCalendar fromRequest: rq]; + if (ex) + response = (WOResponse *) ex; else { response = [_ctx response]; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 9dc9f2159..77a4d032a 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -1463,16 +1463,16 @@ iRANGE(2); - (NSArray *) classificationClasses { - static NSArray *priorities = nil; - - if (!priorities) + static NSArray *classes = nil; + + if (!classes) { - priorities = [NSArray arrayWithObjects: @"PUBLIC", - @"CONFIDENTIAL", @"PRIVATE", nil]; - [priorities retain]; + classes = [NSArray arrayWithObjects: @"PUBLIC", + @"CONFIDENTIAL", @"PRIVATE", nil]; + [classes retain]; } - - return priorities; + + return classes; } - (void) setClassification: (NSString *) _classification