From 3a9c28f0eaae825ec36479ad1ac28a060da62f0a Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 23 Mar 2016 13:41:08 -0400 Subject: [PATCH] (fix) handle default classification for tasks (fixes #3541) --- .../Appointments/SOGoAppointmentObject.m | 33 +------------------ .../Appointments/SOGoCalendarComponent.h | 2 ++ .../Appointments/SOGoCalendarComponent.m | 32 ++++++++++++++++++ SoObjects/Appointments/SOGoTaskObject.m | 15 +++++++++ 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 20ba63efd9..bcd85d6b76 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -1759,37 +1759,6 @@ - (void) _adjustTransparencyInRequestCalendar: (iCalCalendar *) rqCalendar } } -- (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]]; - } - } - } -} - // // iOS devices (and potentially others) send event invitations with no PARTSTAT defined. // This confuses DAV clients like Thunderbird, or event SOGo web. The RFC says: @@ -2006,7 +1975,7 @@ - (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar } [self _adjustEventsInRequestCalendar: calendar]; - [self _adjustClassificationInRequestCalendar: calendar]; + [self adjustClassificationInRequestCalendar: calendar]; [self _adjustPartStatInRequestCalendar: calendar]; } diff --git a/SoObjects/Appointments/SOGoCalendarComponent.h b/SoObjects/Appointments/SOGoCalendarComponent.h index 1595a1c75f..adcf3be897 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.h +++ b/SoObjects/Appointments/SOGoCalendarComponent.h @@ -94,6 +94,8 @@ - (void) snoozeAlarm: (unsigned int) minutes; +- (void) adjustClassificationInRequestCalendar: (iCalCalendar *) rqCalendar; + @end #endif /* SOGOCALENDARCOMPONENT_H */ diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index e40be13a48..7478d1239a 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -1445,4 +1445,36 @@ - (id) PUTAction: (WOContext *) localContext // return values; // } +- (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]]; + } + } + } +} + + @end diff --git a/SoObjects/Appointments/SOGoTaskObject.m b/SoObjects/Appointments/SOGoTaskObject.m index c3efc4e5c8..f31ba3c21f 100644 --- a/SoObjects/Appointments/SOGoTaskObject.m +++ b/SoObjects/Appointments/SOGoTaskObject.m @@ -21,6 +21,8 @@ #import +#import +#import #import #import #import @@ -105,4 +107,17 @@ - (void) prepareDeleteOccurence: (iCalToDo *) occurence } +- (id) PUTAction: (WOContext *) _ctx +{ + iCalCalendar *rqCalendar; + WORequest *rq; + + rq = [_ctx request]; + rqCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]]; + [self adjustClassificationInRequestCalendar: rqCalendar]; + [rq setContent: [[rqCalendar versitString] dataUsingEncoding: [rq contentEncoding]]]; + + return [super PUTAction: _ctx]; +} + @end /* SOGoTaskObject */