From e95056042cb442aba8d33fc9893668574ae1458f Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 3 May 2007 18:49:19 +0000 Subject: [PATCH] Monotone-Parent: 52e60bbc85e658b4d2dc0c8382ee87393d05c34d Monotone-Revision: 5c634952da80242ab54712c3940880241c489739 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-03T18:49:19 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 +++ .../Appointments/SOGoCalendarComponent.h | 8 +- .../Appointments/SOGoCalendarComponent.m | 79 ++++++++----------- 3 files changed, 46 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bb0af74d..bddc874fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2007-05-03 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoCalendarComponent.m + ([SOGoCalendarComponent -isOrganizerOrOwner:user]): new method + replacing "isOrganizer:orOwner:" by taking only one instance of + SOGoUser as parameter. + ([SOGoCalendarComponent -participant:user]): new method replacing + the previous "isParticipant" boolean method by returning the first + participant matching the user passed as parameter. This method is + used so that both the regular email address and the "system email + address" of the user are matched against the participants emails. + * SoObjects/SOGo/AgenorUserManager.m ([AgenorUserManager -getSystemEMailForUID:uid]): new method that returns the email formed with the user's uid and the default mail domain. diff --git a/SoObjects/Appointments/SOGoCalendarComponent.h b/SoObjects/Appointments/SOGoCalendarComponent.h index 1f7299bc4..ef16a375f 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.h +++ b/SoObjects/Appointments/SOGoCalendarComponent.h @@ -29,8 +29,11 @@ @class NSString; @class iCalCalendar; +@class iCalPerson; @class iCalRepeatableEntityObject; +@class SOGoUser; + @interface SOGoCalendarComponent : SOGoContentObject { iCalCalendar *calendar; @@ -57,9 +60,8 @@ andNewObject: (iCalRepeatableEntityObject *) _newObject toAttendees: (NSArray *) _attendees; -- (BOOL) isOrganizer: (NSString *) email - orOwner: (NSString *) login; -- (BOOL) isParticipant: (NSString *) email; +- (BOOL) isOrganizerOrOwner: (SOGoUser *) user; +- (iCalPerson *) participant: (SOGoUser *) user; @end diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index e1a5f5986..abd1d1044 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -201,9 +201,9 @@ static BOOL sendEMailNotifications = NO; - (iCalRepeatableEntityObject *) component: (BOOL) create { - return (iCalRepeatableEntityObject *) - [[self calendar: create] - firstChildWithTag: [self componentTag]]; + return + (iCalRepeatableEntityObject *) [[self calendar: create] + firstChildWithTag: [self componentTag]]; } - (BOOL) isNew @@ -443,42 +443,7 @@ static BOOL sendEMailNotifications = NO; } } -// - (NSArray *) rolesOfUser: (NSString *) login -// { -// AgenorUserManager *um; -// iCalRepeatableEntityObject *component; -// NSMutableArray *sogoRoles; -// NSString *email; -// SOGoUser *user; - -// sogoRoles = [NSMutableArray new]; -// [sogoRoles autorelease]; - -// um = [AgenorUserManager sharedUserManager]; -// email = [um getEmailForUID: login]; - -// component = [self component: NO]; -// if (component) -// { -// if ([component isOrganizer: email]) -// [sogoRoles addObject: SOGoCalendarRole_Organizer]; -// else if ([component isParticipant: email]) -// [sogoRoles addObject: SOGoCalendarRole_Participant]; -// else if ([[container ownerInContext: context] isEqualToString: login]) -// [sogoRoles addObject: SoRole_Owner]; -// } -// else -// { -// user = [SOGoUser userWithLogin: login andRoles: nil]; -// [sogoRoles addObjectsFromArray: [user rolesForObject: container -// inContext: context]]; -// } - -// return sogoRoles; -// } - -- (BOOL) isOrganizer: (NSString *) email - orOwner: (NSString *) login +- (BOOL) isOrganizerOrOwner: (SOGoUser *) user { BOOL isOrganizerOrOwner; iCalRepeatableEntityObject *component; @@ -488,26 +453,44 @@ static BOOL sendEMailNotifications = NO; organizerEmail = [[component organizer] rfc822Email]; if (component && [organizerEmail length] > 0) isOrganizerOrOwner - = ([organizerEmail caseInsensitiveCompare: email] == NSOrderedSame); + = (([organizerEmail caseInsensitiveCompare: [user email]] + == NSOrderedSame) + || ([organizerEmail caseInsensitiveCompare: [user systemEMail]] + == NSOrderedSame)); else isOrganizerOrOwner - = [[container ownerInContext: context] isEqualToString: login]; + = [[container ownerInContext: context] isEqualToString: [user login]]; return isOrganizerOrOwner; } -- (BOOL) isParticipant: (NSString *) email +- (iCalPerson *) participant: (SOGoUser *) user { - BOOL isParticipant; - iCalRepeatableEntityObject *component; + iCalPerson *participant, *currentParticipant; + iCalEntityObject *component; + NSString *email, *systemEmail, *currentEmail; + NSEnumerator *participants; + participant = nil; component = [self component: NO]; if (component) - isParticipant = [component isParticipant: email]; - else - isParticipant = NO; + { + 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]; + } + } - return isParticipant; + return participant; } - (NSArray *) aclsForUser: (NSString *) uid