Skip to content

Commit

Permalink
(fix) handle default classification for tasks (fixes #3541)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Mar 23, 2016
1 parent 0291b49 commit 3a9c28f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 32 deletions.
33 changes: 1 addition & 32 deletions SoObjects/Appointments/SOGoAppointmentObject.m
Expand Up @@ -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:
Expand Down Expand Up @@ -2006,7 +1975,7 @@ - (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar
}

[self _adjustEventsInRequestCalendar: calendar];
[self _adjustClassificationInRequestCalendar: calendar];
[self adjustClassificationInRequestCalendar: calendar];
[self _adjustPartStatInRequestCalendar: calendar];
}

Expand Down
2 changes: 2 additions & 0 deletions SoObjects/Appointments/SOGoCalendarComponent.h
Expand Up @@ -94,6 +94,8 @@

- (void) snoozeAlarm: (unsigned int) minutes;

- (void) adjustClassificationInRequestCalendar: (iCalCalendar *) rqCalendar;

@end

#endif /* SOGOCALENDARCOMPONENT_H */
32 changes: 32 additions & 0 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Expand Up @@ -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
15 changes: 15 additions & 0 deletions SoObjects/Appointments/SOGoTaskObject.m
Expand Up @@ -21,6 +21,8 @@

#import <Foundation/NSCalendarDate.h>

#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGCards/iCalCalendar.h>
Expand Down Expand Up @@ -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 */

0 comments on commit 3a9c28f

Please sign in to comment.