From 021c061d291602d630ab6ca586fefcd463a1ae5b Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 26 Nov 2008 16:26:32 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 1fc6240dbb88ca9e470be6d2679ee8e3e10e4f4f Monotone-Revision: b9443420fc607bc2c0d8c6a5cff48fda3c68f7e6 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-11-26T16:26:32 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 ++++++++ .../Appointments/SOGoAppointmentObject.m | 3 ++- SoObjects/SOGo/SOGoGCSFolder.m | 4 ++- UI/Scheduler/UIxAppointmentEditor.m | 25 +++++++++++++++++++ UI/Scheduler/UIxComponentEditor.m | 17 +++++++++++-- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c7cc8e24..d00170021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-11-26 Ludovic Marcotte + + * SoObjects/SOGo/SOGoGCSFolder.m + We correctly wrap ACL additions around a + database transaction. + * Updated the code wrt acting on behalf of + someone else to speed up things and also to + honor the participation status of the one acting + on behalf of someone else. + 2008-11-26 Ludovic Marcotte * SoObjects/SOGo/SOGoGCSFolder.m diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 9af4d6846..acd7b61a2 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -345,6 +345,7 @@ [[newEvent parent] setMethod: @""]; ownerUser = [SOGoUser userWithLogin: owner roles: nil]; + if ([newEvent userIsOrganizer: ownerUser]) { oldEvent = [self component: NO secure: NO]; @@ -352,7 +353,7 @@ [self _handleUpdatedEvent: newEvent fromOldEvent: oldEvent]; else { - attendees = [newEvent attendeesWithoutUser: [context activeUser]]; + attendees = [newEvent attendeesWithoutUser: ownerUser]; if ([attendees count]) { [self _handleAddedUsers: attendees fromEvent: newEvent]; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index eb2a67f9f..2bc01800a 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -855,6 +855,7 @@ static NSArray *childRecordFields = nil; folder = [self ocsFolder]; channel = [folder acquireAclChannel]; + [[channel adaptorContext] beginTransaction]; userRoles = [roles objectEnumerator]; while ((currentRole = [userRoles nextObject])) { @@ -863,9 +864,10 @@ static NSArray *childRecordFields = nil; @" VALUES ('/%@', '%@', '%@')", [folder aclTableName], objectPath, uid, currentRole]; - [channel evaluateExpressionX: SQL]; + [channel evaluateExpressionX: SQL]; } + [[channel adaptorContext] commitTransaction]; [folder releaseChannel: channel]; } diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index c22c62ec5..20ca10821 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -292,16 +292,41 @@ return result; } +// +// This method needs to carefully handle the following cases : +// +// A- Alice creates an event in her calendar +// B- Alice creates an event in Bob's calendar (and invites herself or not) +// C- Alice moves an event to an other calendar +// - (id ) saveAction { SOGoAppointmentFolder *thisFolder; SOGoAppointmentObject *co; SoSecurityManager *sm; NSException *ex; + NSString *aOwner; + // See A. co = [self clientObject]; + + if (componentCalendar) + { + aOwner = [componentCalendar ownerInContext: context]; + + // See B. + if (![aOwner isEqualToString: [[context activeUser] login]]) + { + co = [componentCalendar lookupName: [co nameInContainer] + inContext: context + acquire: NO]; + } + } + + // We save the component [co saveComponent: event]; + // See C. if (componentCalendar) { sm = [SoSecurityManager sharedSecurityManager]; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 598022cca..6e26bd00c 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -1608,12 +1608,25 @@ RANGE(2); andClientObject: (SOGoContentObject *) clientObject { - NSString *toolbarFilename; iCalPersonPartStat participationStatus; + NSString *toolbarFilename; + BOOL isOrganizer; + + // We determine if we're the organizer of the component beeing modified. + // If we created an event on behalf of someone else -userIsOrganizer will + // return us YES. This is OK because we're in the SENT-BY. But, Alice + // should be able to accept/decline an invitation if she created the event + // in Bob's calendar and added herself in the attendee list. + isOrganizer = [component userIsOrganizer: ownerUser]; + + if (isOrganizer) + { + isOrganizer = ![ownerUser hasEmail: [[component organizer] sentBy]]; + } if ([[component attendees] count] && [component userIsParticipant: ownerUser] - && ![component userIsOrganizer: ownerUser]) + && !isOrganizer) { participationStatus = [[component findParticipant: ownerUser] participationStatus];