From a85078a6580ee22648ec8c0d467e4ff4220ad4ce Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 9 May 2007 19:11:32 +0000 Subject: [PATCH] Monotone-Parent: c4326e19647bbfc97b2d64badbd1269165a03c7f Monotone-Revision: 4bd29508cee7b9dae7bb94969e58f21226b4c2cd Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-09T19:11:32 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 ++ .../Appointments/SOGoCalendarComponent.h | 4 + .../Appointments/SOGoCalendarComponent.m | 82 ++++++++++++++----- 3 files changed, 71 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4eb0aeab6..a823558a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2007-05-09 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoCalendarComponent.m + ([SOGoCalendarComponent -iCalPersonWithUID:uid]): new method taken + from the previous module iCalEntityObject+Agenor. + ([SOGoCalendarComponent -getUIDForICalPerson:person]): idem. + ([SOGoCalendarComponent -getUIDsForICalPersons:iCalPersons]): + idem. + * SoObjects/Contacts/SOGoContactLDIFEntry.[hm]: new class module replacing the SOGoContactLDAPEntry module. It was renamed as such because it now receives a dictionary instead of an NGLdapEntry. diff --git a/SoObjects/Appointments/SOGoCalendarComponent.h b/SoObjects/Appointments/SOGoCalendarComponent.h index ef16a375f..50a1cfa2a 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.h +++ b/SoObjects/Appointments/SOGoCalendarComponent.h @@ -63,6 +63,10 @@ - (BOOL) isOrganizerOrOwner: (SOGoUser *) user; - (iCalPerson *) participant: (SOGoUser *) user; +- (iCalPerson *) iCalPersonWithUID: (NSString *) uid; +- (NSString *) getUIDForICalPerson: (iCalPerson *) person; +- (NSArray *) getUIDsForICalPersons: (NSArray *) iCalPersons; + @end #endif /* SOGOCALENDARCOMPONENT_H */ diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index abd1d1044..141c36a94 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -29,7 +29,7 @@ #import #import -#import +#import #import #import #import @@ -126,7 +126,7 @@ static BOOL sendEMailNotifications = NO; tmpCalendar = [iCalCalendar parseSingleFromSource: tmpContent]; tmpComponent = (iCalRepeatableEntityObject *) [tmpCalendar firstChildWithTag: [self componentTag]]; - email = [[context activeUser] email]; + email = [[context activeUser] primaryEmail]; if (!([tmpComponent isOrganizer: email] || [tmpComponent isParticipant: email])) { @@ -251,7 +251,7 @@ static BOOL sendEMailNotifications = NO; baseURL = @"http://localhost/"; [self warnWithFormat:@"Unable to create baseURL from context!"]; } - uid = [[AgenorUserManager sharedUserManager] + uid = [[LDAPUserManager sharedUserManager] getUIDForEmail: [_person rfc822Email]]; return ((uid) @@ -272,7 +272,7 @@ static BOOL sendEMailNotifications = NO; component = [self component: NO]; if (component) { - myEMail = [[context activeUser] email]; + myEMail = [[context activeUser] primaryEmail]; p = [component findParticipantWithEmail: myEMail]; if (p) { @@ -314,7 +314,7 @@ static BOOL sendEMailNotifications = NO; { NSString *uid; - uid = [[AgenorUserManager sharedUserManager] getUIDForEmail: email]; + uid = [[LDAPUserManager sharedUserManager] getUIDForEmail: email]; return [[SOGoUser userWithLogin: uid andRoles: nil] timeZone]; } @@ -452,11 +452,7 @@ static BOOL sendEMailNotifications = NO; component = [self component: NO]; organizerEmail = [[component organizer] rfc822Email]; if (component && [organizerEmail length] > 0) - isOrganizerOrOwner - = (([organizerEmail caseInsensitiveCompare: [user email]] - == NSOrderedSame) - || ([organizerEmail caseInsensitiveCompare: [user systemEMail]] - == NSOrderedSame)); + isOrganizerOrOwner = [user hasEmail: organizerEmail]; else isOrganizerOrOwner = [[container ownerInContext: context] isEqualToString: [user login]]; @@ -468,31 +464,73 @@ static BOOL sendEMailNotifications = NO; { iCalPerson *participant, *currentParticipant; iCalEntityObject *component; - NSString *email, *systemEmail, *currentEmail; NSEnumerator *participants; participant = nil; component = [self component: NO]; if (component) { - email = [[user email] lowercaseString]; - systemEmail = [[user systemEMail] lowercaseString]; participants = [[component participants] objectEnumerator]; currentParticipant = [participants nextObject]; while (currentParticipant && !participant) - { - currentEmail = [[currentParticipant rfc822Email] lowercaseString]; - if ([currentEmail isEqualToString: email] - || [currentEmail isEqualToString: systemEmail]) - participant = currentParticipant; - else - currentParticipant = [participants nextObject]; - } + if ([user hasEmail: [currentParticipant rfc822Email]]) + participant = currentParticipant; + else + currentParticipant = [participants nextObject]; } return participant; } +- (iCalPerson *) iCalPersonWithUID: (NSString *) uid +{ + iCalPerson *person; + LDAPUserManager *um; + NSDictionary *contactInfos; + + um = [LDAPUserManager sharedUserManager]; + contactInfos = [um contactInfosForUserWithUIDorEmail: uid]; + + person = [iCalPerson new]; + [person autorelease]; + [person setCn: [contactInfos objectForKey: @"cn"]]; + [person setEmail: [contactInfos objectForKey: @"c_email"]]; + + return person; +} + +- (NSString *) getUIDForICalPerson: (iCalPerson *) person +{ + LDAPUserManager *um; + + um = [LDAPUserManager sharedUserManager]; + + return [um getUIDForEmail: [person rfc822Email]]; +} + +- (NSArray *) getUIDsForICalPersons: (NSArray *) iCalPersons +{ + iCalPerson *currentPerson; + NSEnumerator *persons; + NSMutableArray *uids; + NSString *email; + LDAPUserManager *um; + + uids = [NSMutableArray array]; + + um = [LDAPUserManager sharedUserManager]; + persons = [iCalPersons objectEnumerator]; + currentPerson = [persons nextObject]; + while (currentPerson) + { + email = [currentPerson rfc822Email]; + [uids addObject: [um getUIDForEmail: email]]; + currentPerson = [persons nextObject]; + } + + return uids; +} + - (NSArray *) aclsForUser: (NSString *) uid { NSMutableArray *roles; @@ -504,7 +542,7 @@ static BOOL sendEMailNotifications = NO; component = [self component: NO]; if (component) { - email = [[AgenorUserManager sharedUserManager] getEmailForUID: uid]; + email = [[LDAPUserManager sharedUserManager] getEmailForUID: uid]; if ([component isOrganizer: email]) [roles addObject: SOGoCalendarRole_Organizer]; if ([component isParticipant: email])