Added invitation delegation support in Web interface. See ChangeLog.

Monotone-Parent: 4d711e074341810486c1842c6a345777cc3664bb
Monotone-Revision: 2fc8598099b516f243935e73039200f1c004784e

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2009-09-10T18:31:20
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle committed 2009-09-10 18:31:20 +00:00
1 parent b63b53fecd
commit 9a9ecb1811
45 files changed
+1296 -836

No files matched your search

-1
View File
@@ -60,7 +60,6 @@ Appointments_COMPONENTS += \
SOGoAptMailDutchDeletion.wo \
SOGoAptMailDutchUpdate.wo \
SOGoAptMailEnglishInvitation.wo \
SOGoAptMailEnglishICalReply.wo \
SOGoAptMailEnglishDeletion.wo \
SOGoAptMailEnglishUpdate.wo \
SOGoAptMailFrenchInvitation.wo \
+159 -24
View File
@@ -35,6 +35,8 @@
#import <NGCards/NSCalendarDate+NGCards.h>
#import <SaxObjC/XMLNamespaces.h>
#import <SOPE/NGCards/NSString+NGCards.h>
#import <SoObjects/SOGo/iCalEntityObject+Utilities.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
@@ -400,8 +402,8 @@
currentUID = [currentAttendee uid];
if (currentUID)
[self _addOrUpdateEvent: newEvent
forUID: currentUID
owner: owner];
forUID: currentUID
owner: owner];
}
[self sendEMailUsingTemplateNamed: @"Update"
@@ -425,8 +427,8 @@
currentUID = [currentAttendee uid];
if (currentUID)
[self _addOrUpdateEvent: newEvent
forUID: currentUID
owner: owner];
forUID: currentUID
owner: owner];
}
}
@@ -483,8 +485,8 @@
currentUID = [currentAttendee uid];
if (currentUID)
[self _addOrUpdateEvent: newEvent
forUID: currentUID
owner: owner];
forUID: currentUID
owner: owner];
}
[self sendReceiptEmailUsingTemplateNamed: @"Update"
@@ -635,7 +637,7 @@
delegateEmail = [otherAttendee delegatedTo];
if ([delegateEmail length])
delegateEmail = [delegateEmail substringFromIndex: 7];
delegateEmail = [delegateEmail rfc822Email];
if ([delegateEmail length])
otherDelegate = [event findParticipantWithEmail: delegateEmail];
else
@@ -664,7 +666,22 @@
}
if (removeDelegate)
[event removeFromAttendees: otherDelegate];
{
while (otherDelegate)
{
[event removeFromAttendees: otherDelegate];
// Verify if the delegate was already delegated
delegateEmail = [otherDelegate delegatedTo];
if ([delegateEmail length])
delegateEmail = [delegateEmail rfc822Email];
if ([delegateEmail length])
otherDelegate = [event findParticipantWithEmail: delegateEmail];
else
otherDelegate = NO;
}
}
if (addDelegate)
[event addToAttendees: delegate];
@@ -721,7 +738,50 @@
ex = nil;
currentStatus = [attendee partStat];
if ([currentStatus caseInsensitiveCompare: newStatus]
iCalPerson *otherAttendee, *otherDelegate;
NSString *delegateEmail;
BOOL addDelegate, removeDelegate;
otherAttendee = attendee;
delegateEmail = [otherAttendee delegatedTo];
if ([delegateEmail length])
delegateEmail = [delegateEmail rfc822Email];
if ([delegateEmail length])
otherDelegate = [event findParticipantWithEmail: delegateEmail];
else
otherDelegate = NO;
/* We handle the addition/deletion of delegated users */
addDelegate = NO;
removeDelegate = NO;
if (delegate)
{
if (otherDelegate)
{
// There was already a delegated
if (![delegate hasSameEmailAddress: otherDelegate])
{
// The delegated has changed
removeDelegate = YES;
addDelegate = YES;
}
}
else
// There was no previous delegated
addDelegate = YES;
}
else
{
if (otherDelegate)
// The user has removed the delegated
removeDelegate = YES;
}
if (addDelegate || removeDelegate
|| [currentStatus caseInsensitiveCompare: newStatus]
!= NSOrderedSame)
{
[attendee setPartStat: newStatus];
@@ -745,7 +805,70 @@
// we don't want to keep the previous SENT-BY attribute there.
[(NSMutableDictionary *)[attendee attributes] removeObjectForKey: @"SENT-BY"];
}
[attendee setDelegatedTo: [delegate email]];
NSString *delegatedUID;
NSMutableArray *delegates;
if (removeDelegate)
{
delegates = [NSMutableArray new];
while (otherDelegate)
{
[delegates addObject: otherDelegate];
delegatedUID = [otherDelegate uid];
if (delegatedUID)
// Delegated attendee is a local user; remove event from his calendar
[self _removeEventFromUID: delegatedUID
owner: [theOwnerUser login]
withRecurrenceId: [event recurrenceId]];
[event removeFromAttendees: otherDelegate];
// Verify if the delegate was already delegated
delegateEmail = [otherDelegate delegatedTo];
if ([delegateEmail length])
delegateEmail = [delegateEmail rfc822Email];
if ([delegateEmail length])
otherDelegate = [event findParticipantWithEmail: delegateEmail];
else
otherDelegate = NO;
}
[self sendEMailUsingTemplateNamed: @"Deletion"
forObject: [event itipEntryWithMethod: @"cancel"]
previousObject: nil
toAttendees: delegates];
[self sendReceiptEmailUsingTemplateNamed: @"Deletion"
forObject: event
to: delegates];
[delegates release];
}
if (addDelegate)
{
delegatedUID = [delegate uid];
delegates = [NSArray arrayWithObject: delegate];
[event addToAttendees: delegate];
if (delegatedUID)
// Delegated attendee is a local user; add event to his calendar
[self _addOrUpdateEvent: event
forUID: delegatedUID
owner: [theOwnerUser login]];
[self sendEMailUsingTemplateNamed: @"Invitation"
forObject: [event itipEntryWithMethod: @"request"]
previousObject: nil
toAttendees: delegates];
[self sendReceiptEmailUsingTemplateNamed: @"Invitation"
forObject: event to: delegates];
}
// We generate the updated iCalendar file and we save it
// in the database.
newContent = [[event parent] versitString];
@@ -794,7 +917,9 @@
{
att = [attendees objectAtIndex: i];
uid = [att uid];
if (uid && att != attendee)
if (uid
&& att != attendee
&& ![uid isEqualToString: delegatedUID])
[self _updateAttendee: attendee
withDelegate: delegate
ownerUser: theOwnerUser
@@ -1097,7 +1222,6 @@
int i;
/* We update the copy of the organizer, only if it's a local user. */
#warning add a check for only local users
uid = [[event organizer] uid];
if (uid)
[self _updateAttendee: attendee
@@ -1200,7 +1324,8 @@
- (NSException *) changeParticipationStatus: (NSString *) status
withDelegate: (iCalPerson *) delegate
{
return [self changeParticipationStatus: status withDelegate: delegate
return [self changeParticipationStatus: status
withDelegate: delegate
forRecurrenceId: nil];
}
@@ -1240,27 +1365,37 @@
if (event)
{
// ownerUser will actually be the owner of the calendar
// where the participation change on the event has
// actually occured. The particpation change will of
// course be on the attendee that is the owner of the
// calendar where the participation change has occured.
// where the participation change on the event occurs. The particpation
// change will be on the attendee corresponding to the ownerUser.
ownerUser = [SOGoUser userWithLogin: owner];
attendee = [event findParticipant: ownerUser];
if (attendee)
ex = [self _handleAttendee: attendee
withDelegate: delegate
ownerUser: ownerUser
statusChange: _status
inEvent: event];
{
if (delegate
&& ![[delegate email] isEqualToString: [attendee delegatedTo]])
{
if ([event isParticipant: [[delegate email] rfc822Email]])
ex = [NSException exceptionWithHTTPStatus: 403
reason: @"delegate is a participant"];
else if ([SOGoGroup groupWithEmail: [[delegate email] rfc822Email]])
ex = [NSException exceptionWithHTTPStatus: 403
reason: @"delegate is a group"];
}
if (ex == nil)
ex = [self _handleAttendee: attendee
withDelegate: delegate
ownerUser: ownerUser
statusChange: _status
inEvent: event];
}
else
ex = [NSException exceptionWithHTTPStatus: 404 // Not Found
reason: @"user does not participate in this "
@"calendar event"];
reason: @"user does not participate in this calendar event"];
}
else
ex = [NSException exceptionWithHTTPStatus: 500 // Server Error
reason: @"unable to parse event record"];
reason: @"unable to parse event record"];
return ex;
}
@@ -1,2 +0,0 @@
<#IsSubject>Event Invitation Reply: <#summary/></#IsSubject>
<#IsBody><#attendee/><#HasSentBy> (sent by <#sentBy/>)</#HasSentBy> has <#HasAccepted>accepted</#HasAccepted><#HasDeclined>declined</#HasDeclined><#HasNotAcceptedNotDeclined>not yet decided upon</#HasNotAcceptedNotDeclined> your event invitation.</#IsBody>
@@ -1,39 +0,0 @@
IsSubject: WOConditional {
condition = isSubject;
}
IsBody: WOConditional {
condition = isSubject;
negate = YES;
}
summary: WOString {
value = summary;
escapeHTML = NO;
}
attendee: WOString {
value = attendeeName;
escapeHTML = NO;
}
HasAccepted: WOConditional {
condition = hasAccepted;
}
HasDeclined: WOConditional {
condition = hasDeclined;
}
HasNotAcceptedNotDeclined: WOConditional {
condition = hasNotAcceptedNotDeclined;
}
HasSentBy: WOConditional {
condition = hasSentBy;
}
sentBy: WOString {
value = sentBy;
escapeHTML = NO;
}
@@ -186,8 +186,13 @@ static NSCharacterSet *wsSet = nil;
- (NSString *) getBody
{
NSString *body;
isSubject = NO;
return [[self generateResponse] contentAsString];
body = [[self generateResponse] contentAsString];
return [body stringByTrimmingCharactersInSet: wsSet];
}
@end
@@ -761,7 +761,7 @@ static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence, NSStr
ownerUser = from;
language = [ownerUser language];
/* create page name */
pageName
pageName
= [NSString stringWithFormat: @"SOGoAptMail%@ICalReply", language];
/* construct message content */
p = [app pageWithName: pageName inContext: context];
@@ -778,13 +778,13 @@ static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence, NSStr
* at all. Mail.app shows the rich content alternative _only_
* so we'll stick with multipart/mixed for the time being.
*/
[headerMap setObject: @"multipart/mixed" forKey: @"content-type"];
[headerMap setObject: @"1.0" forKey: @"MIME-Version"];
[headerMap setObject: [attendee mailAddress] forKey: @"from"];
[headerMap setObject: [recipient mailAddress] forKey: @"to"];
mailDate = [[NSCalendarDate date] rfc822DateString];
[headerMap setObject: mailDate forKey: @"date"];
[headerMap setObject: [p getSubject] forKey: @"subject"];
[headerMap setObject: @"1.0" forKey: @"MIME-Version"];
[headerMap setObject: @"multipart/mixed" forKey: @"content-type"];
msg = [NGMimeMessage messageWithHeader: headerMap];
NSLog (@"sending 'REPLY' from %@ to %@",
@@ -251,6 +251,10 @@
data = @"";
[newRecord setObject: data forKey: @"c_telephonenumber"];
data = [oldRecord objectForKey: @"isGroup"];
if (data)
[newRecord setObject: data forKey: @"isGroup"];
contactInfo = [ud stringForKey: @"SOGoLDAPContactInfoAttribute"];
if ([contactInfo length] > 0) {
data = [oldRecord objectForKey: contactInfo];
+19 -7
View File
@@ -658,14 +658,27 @@ static NSLock *lock;
NSMutableDictionary *contactEntry;
NSEnumerator *attributes;
NSString *currentAttribute, *value;
NSArray *classes;
contactEntry = [NSMutableDictionary dictionary];
[contactEntry setObject: [ldapEntry dn] forKey: @"dn"];
classes = [ldapEntry objectClasses];
if ([ldapEntry objectClasses])
[contactEntry setObject: [ldapEntry objectClasses]
forKey: @"objectClasses"];
attributes = [[self _searchAttributes] objectEnumerator];
if (classes)
{
[contactEntry setObject: classes
forKey: @"objectClasses"];
attributes = [[self _searchAttributes] objectEnumerator];
if ([classes containsObject: @"group"] ||
[classes containsObject: @"groupOfNames"] ||
[classes containsObject: @"groupOfUniqueNames"] ||
[classes containsObject: @"posixGroup"])
{
[contactEntry setObject: [NSNumber numberWithInt: 1]
forKey: @"isGroup"];
}
}
while ((currentAttribute = [attributes nextObject]))
{
value = [[ldapEntry attributeWithName: currentAttribute]
@@ -887,10 +900,12 @@ static NSLock *lock;
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail
{
#warning We should support MailFieldNames
return [self lookupGroupEntryByAttribute: @"mail"
andValue: theEmail];
}
// This method should accept multiple attributes
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
andValue: (NSString *) theValue
{
@@ -911,9 +926,6 @@ static NSLock *lock;
EOQualifier *qualifier;
NSString *s;
// FIXME
// we should support MailFieldNames?
s = [NSString stringWithFormat: @"(%@='%@')",
theAttribute, SafeLDAPCriteria (theValue)];
qualifier = [EOQualifier qualifierWithQualifierFormat: s];
+2 -2
View File
@@ -204,7 +204,7 @@
dn = [dns objectAtIndex: i];
login = [um getLoginForDN: [dn lowercaseString]];
//NSLog(@"member = %@", login);
user = [SOGoUser userWithLogin: login roles: nil];
user = [SOGoUser userWithLogin: login roles: nil];
if (user)
[array addObject: user];
}
@@ -213,7 +213,7 @@
for (i = 0; i < [uids count]; i++)
{
login = [uids objectAtIndex: i];
NSLog(@"member = %@", login);
//NSLog(@"member = %@", login);
user = [SOGoUser userWithLogin: login roles: nil];
if (user)