See ChangeLog

Monotone-Parent: b3a24e425f02d22903e826a50c1e2421ea43be6f
Monotone-Revision: 968254dd9df1cf87e5269ec6f7f31e31acc794bc

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2009-05-06T21:57:21
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Francis Lachapelle 2009-05-06 21:57:21 +00:00
parent e812288063
commit ab786b6889
6 changed files with 108 additions and 134 deletions

View File

@ -1,3 +1,15 @@
2009-05-06 Francis Lachapelle <flachapelle@inverse.ca>
* SoObjects/SOGo/SOGoGCSFolder.m ([SOGoGCSFolder
-removeAclsForUsers:atObjectPath:]): verify if user is a group and
prefix the UID with "@" if so.
* SoObjects/Appointments/SOGoCalendarComponent.m
([SOGoCalendarComponent -expandGroupsInEvent:]): new method from
the code that was in [SOGoAppointmentObject -_handleAddedUsers:]
and [SOGoAppointmentObject -_PUTAction:] that expands the groups
among the attendees of the passed event.
2009-05-05 Francis Lachapelle <flachapelle@inverse.ca>
* SoObjects/SOGo/SOGoUser.m ([SOGoUser

View File

@ -2399,6 +2399,9 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
return result;
}
//
// This method returns the personal calendar of a specific user.
//
- (SOGoAppointmentFolder *) lookupCalendarFolderForUID: (NSString *) uid
{
SOGoFolder *currentContainer;

View File

@ -203,6 +203,7 @@
if (!object)
{
// Create the event in the user's personal calendar.
folder = [container lookupCalendarFolderForUID: uid];
object = [SOGoAppointmentObject objectWithName: nameInContainer
inContainer: folder];
@ -396,87 +397,22 @@
toAttendees: updateAttendees];
}
//
// Returns "YES" if a group was decomposed during attendees addition.
//
- (BOOL) _handleAddedUsers: (NSArray *) attendees
- (void) _handleAddedUsers: (NSArray *) attendees
fromEvent: (iCalEvent *) newEvent
{
NSMutableArray *array, *attendeesFromGroups;
NSEnumerator *enumerator;
iCalPerson *currentAttendee;
NSString *currentUID;
BOOL b;
int i;
array = [NSMutableArray arrayWithArray: [newEvent attendees]];
attendeesFromGroups = [NSMutableArray array];
RETAIN(attendees);
b = NO;
enumerator = [attendees objectEnumerator];
while ((currentAttendee = [enumerator nextObject]))
{
SOGoGroup *group;
group = [SOGoGroup groupWithEmail: [currentAttendee rfc822Email]];
if (group)
{
iCalPerson *person;
NSArray *members;
SOGoUser *user;
// We did decompose a group...
[array removeObject: currentAttendee];
b = YES;
members = [group members];
for (i = 0; i < [members count]; i++)
{
user = [members objectAtIndex: i];
// If the organizer is part of the group, we skip it from
// the addition to the attendees' list
if ([user hasEmail: [[newEvent organizer] rfc822Email]])
continue;
person = [self iCalPersonWithUID: [user login]];
[person setTag: @"ATTENDEE"];
[person setParticipationStatus: iCalPersonPartStatNeedsAction];
[person setRsvp: @"TRUE"];
[person setRole: @"REQ-PARTICIPANT"];
[attendeesFromGroups addObject: [user login]];
if (![array containsObject: person])
[array addObject: person];
}
}
else
{
currentUID = [currentAttendee uid];
if (currentUID)
[self _addOrUpdateEvent: newEvent
forUID: currentUID
owner: owner];
}
}
if (b)
{
NSLog(@"New attendees: %@", array);
[newEvent setAttendees: array];
for (i = 0; i < [attendeesFromGroups count]; i++)
currentUID = [currentAttendee uid];
if (currentUID)
[self _addOrUpdateEvent: newEvent
forUID: [attendeesFromGroups objectAtIndex: i]
forUID: currentUID
owner: owner];
}
RELEASE(attendees);
return b;
}
//
@ -541,14 +477,7 @@
originalAttendees = [NSArray arrayWithArray: [newEvent attendees]];
// Send an invitation to new attendees
if ([self _handleAddedUsers: attendees fromEvent: newEvent])
{
// We need to compute our new set for the invitation template
// if we decomposed groups.
attendees = [NSMutableArray arrayWithArray: [newEvent attendees]];
[(NSMutableArray *)attendees removeObjectsInArray: originalAttendees];
}
[self _handleAddedUsers: attendees fromEvent: newEvent];
[self sendEMailUsingTemplateNamed: @"Invitation"
forObject: [newEvent itipEntryWithMethod: @"request"]
previousObject: oldEvent
@ -567,6 +496,8 @@
[[newEvent parent] setMethod: @""];
ownerUser = [SOGoUser userWithLogin: owner roles: nil];
[self expandGroupsInEvent: newEvent];
// We first save the event. It is important to this initially
// as the event's UID might get modified in SOGoCalendarComponent: -saveComponent:
[super saveComponent: newEvent];
@ -579,13 +510,7 @@
attendees = [newEvent attendeesWithoutUser: ownerUser];
if ([attendees count])
{
if ([self _handleAddedUsers: attendees fromEvent: newEvent])
{
// We refetch the list of attendees and save again the
// event as a group was decomposed
attendees = [newEvent attendeesWithoutUser: ownerUser];
[super saveComponent: newEvent];
}
[self _handleAddedUsers: attendees fromEvent: newEvent];
[self sendEMailUsingTemplateNamed: @"Invitation"
forObject: [newEvent itipEntryWithMethod: @"request"]
previousObject: nil
@ -1317,12 +1242,8 @@
//
- (id) PUTAction: (WOContext *) _ctx
{
iCalPerson *currentAttendee;
NSEnumerator *enumerator;
iCalCalendar *calendar;
NSMutableArray *array;
NSArray *allEvents;
SOGoGroup *group;
iCalEvent *event;
WORequest *rq;
@ -1350,46 +1271,8 @@
for (i = 0; i < [allEvents count]; i++)
{
event = [allEvents objectAtIndex: i];
array = [NSMutableArray arrayWithArray: [event attendees]];
enumerator = [[event attendees] objectEnumerator];
while ((currentAttendee = [enumerator nextObject]))
{
group = [SOGoGroup groupWithEmail: [currentAttendee rfc822Email]];
if (group)
{
iCalPerson *person;
NSArray *members;
SOGoUser *user;
// We did decompose a group...
[array removeObject: currentAttendee];
b = YES;
members = [group members];
for (i = 0; i < [members count]; i++)
{
user = [members objectAtIndex: i];
// If the organizer is part of the group, we skip it from
// the addition to the attendees' list
if ([user hasEmail: [[event organizer] rfc822Email]])
continue;
person = [self iCalPersonWithUID: [user login]];
[person setTag: @"ATTENDEE"];
[person setParticipationStatus: iCalPersonPartStatNeedsAction];
[person setRsvp: @"TRUE"];
[person setRole: @"REQ-PARTICIPANT"];
if (![array containsObject: person])
[array addObject: person];
}
}
}
[event setAttendees: array];
if ([self expandGroupsInEvent: event])
b = YES;
}
//NSLog(@"Content from calendar:secure: %@", [calendar versitString]);

View File

@ -31,6 +31,7 @@
@class NSString;
@class iCalCalendar;
@class iCalEvent;
@class iCalPerson;
@class iCalRepeatableEntityObject;
@ -52,6 +53,8 @@
secure: (BOOL) secure;
- (id) component: (BOOL) create secure: (BOOL) secure;
- (BOOL) expandGroupsInEvent: (iCalEvent *) theEvent;
// - (NSException *) primarySaveContentString: (NSString *) _iCalString;
// - (NSException *) primaryDelete;

View File

@ -45,6 +45,7 @@
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SoObjects/SOGo/SOGoMailer.h>
#import <SoObjects/SOGo/SOGoGroup.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/WORequest+SOGo.h>
@ -196,8 +197,7 @@ static BOOL sendEMailNotifications = NO;
return iCalString;
}
static inline BOOL
_occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
{
unsigned int seconds, recSeconds;
@ -407,6 +407,64 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
firstChildWithTag: [self componentTag]];
}
//
// Returs "YES" if a a group was decomposed among attendees.
//
- (BOOL) expandGroupsInEvent: (iCalEvent *) theEvent
{
NSMutableArray *allAttendees;
NSEnumerator *enumerator;
NSString *organizerEmail;
iCalPerson *currentAttendee;
SOGoGroup *group;
BOOL doesIncludeGroup;
unsigned int i;
organizerEmail = [[theEvent organizer] rfc822Email];
doesIncludeGroup = NO;
allAttendees = [NSMutableArray arrayWithArray: [theEvent attendees]];
enumerator = [[theEvent attendees] objectEnumerator];
while ((currentAttendee = [enumerator nextObject]))
{
group = [SOGoGroup groupWithEmail: [currentAttendee rfc822Email]];
if (group)
{
iCalPerson *person;
NSArray *members;
SOGoUser *user;
// We did decompose a group...
[allAttendees removeObject: currentAttendee];
members = [group members];
for (i = 0; i < [members count]; i++)
{
user = [members objectAtIndex: i];
doesIncludeGroup = YES;
// If the organizer is part of the group, we skip it from
// the addition to the attendees' list
if ([user hasEmail: organizerEmail])
continue;
person = [self iCalPersonWithUID: [user login]];
[person setTag: @"ATTENDEE"];
[person setParticipationStatus: [currentAttendee participationStatus]];
[person setRsvp: [currentAttendee rsvp]];
[person setRole: [currentAttendee role]];
if (![allAttendees containsObject: person])
[allAttendees addObject: person];
}
}
}
if (doesIncludeGroup)
[theEvent setAttendees: allAttendees];
return doesIncludeGroup;
}
- (void) _updateRecurrenceIDsWithEvent: (iCalRepeatableEntityObject*) newEvent
{
iCalRepeatableEntityObject *oldMaster, *currentComponent;

View File

@ -397,7 +397,6 @@ static NSArray *childRecordFields = nil;
- (BOOL) create
{
NSException *result;
result = [[self folderManager] createFolderOfType: [self folderType]
withName: displayName
atPath: ocsPath];
@ -886,16 +885,32 @@ static NSArray *childRecordFields = nil;
forObjectAtPath: (NSArray *) objectPathArray
{
EOQualifier *qualifier;
NSString *uids, *qs, *objectPath;
NSString *uid, *uids, *qs, *objectPath;
NSMutableArray *usersAndGroups;
NSMutableDictionary *aclsForObject;
SOGoGroup *group;
unsigned int i;
if ([users count] > 0)
{
usersAndGroups = [NSMutableArray arrayWithArray: users];
for (i = 0; i < [usersAndGroups count]; i++)
{
uid = [usersAndGroups objectAtIndex: i];
if (![uid hasPrefix: @"@"])
{
// Prefix the UID with the character "@" when dealing with a group
group = [SOGoGroup groupWithIdentifier: uid];
if (group)
[usersAndGroups replaceObjectAtIndex: i
withObject: [NSString stringWithFormat: @"@%@", uid]];
}
}
objectPath = [objectPathArray componentsJoinedByString: @"/"];
aclsForObject = [aclCache objectForKey: objectPath];
if (aclsForObject)
[aclsForObject removeObjectsForKeys: users];
uids = [users componentsJoinedByString: @"') OR (c_uid = '"];
[aclsForObject removeObjectsForKeys: usersAndGroups];
uids = [usersAndGroups componentsJoinedByString: @"') OR (c_uid = '"];
qs = [NSString
stringWithFormat: @"(c_object = '/%@') AND ((c_uid = '%@'))",
objectPath, uids];