From 98970b7b9b5936d888a86f7d3b3824d33e6217bf Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 28 Jul 2010 20:19:08 +0000 Subject: [PATCH] See ChangeLog. Monotone-Parent: 29cd46d91b0c0d1156ea93feaa77eb114a1dc1bc Monotone-Revision: c1fbc1eec0e204f82627f44220958a6f0f63ffe9 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-07-28T20:19:08 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 12 ++ UI/Scheduler/UIxComponentEditor.h | 3 +- UI/Scheduler/UIxComponentEditor.m | 151 +++++++++++++----- .../SchedulerUI/UIxComponentEditor.wox | 6 +- UI/WebServerResources/UIxAttendeesEditor.js | 2 +- UI/WebServerResources/UIxComponentEditor.js | 18 +++ 6 files changed, 145 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdad3e4a6..42add674f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-07-28 Francis Lachapelle + + * UI/WebServerResources/UIxComponentEditor.js (getCalendarOwner): + new function that returns the event organizer or the calendar + owner in case of an event with no organizer yet. + + * UI/Scheduler/UIxComponentEditor.m (-organizerProfile): was + jsonOrganizer. Now caches the resulting dictionary in an ivar. + (-calendarOwnerList): new method called from the wox template and + use to display the event organizer in the edition window of the + attendees. + 2010-07-27 Francis Lachapelle * UI/WebServerResources/SOGoAutoCompletion.js diff --git a/UI/Scheduler/UIxComponentEditor.h b/UI/Scheduler/UIxComponentEditor.h index 2f366b2bd..692a19112 100644 --- a/UI/Scheduler/UIxComponentEditor.h +++ b/UI/Scheduler/UIxComponentEditor.h @@ -1,6 +1,6 @@ /* UIxComponentEditor.h - this file is part of SOGo * - * Copyright (C) 2006-2009 Inverse inc. + * Copyright (C) 2006-2010 Inverse inc. * * Author: Wolfgang Sourdeau * @@ -44,6 +44,7 @@ NSMutableArray *calendarList; //NSMutableArray *organizerList; //NSDictionary *organizerIdentity; + NSDictionary *organizerProfile; /* individual values */ NSCalendarDate *cycleUntilDate; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 3057feb67..7e799ffa2 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -169,6 +169,7 @@ iRANGE(2); componentOwner = @""; organizer = nil; //organizerIdentity = nil; + organizerProfile = nil; ownerAsAttendee = nil; attendee = nil; jsonAttendees = nil; @@ -202,6 +203,7 @@ iRANGE(2); [location release]; [organizer release]; //[organizerIdentity release]; + [organizerProfile release]; [ownerAsAttendee release]; [comment release]; [priority release]; @@ -812,63 +814,76 @@ iRANGE(2); return [jsonAttendees jsonRepresentation]; } -- (NSString *) jsonOrganizer +- (NSDictionary *) organizerProfile { - NSMutableDictionary *jsonOrganizer; + NSMutableDictionary *profile; NSDictionary *ownerIdentity; NSString *uid, *name, *email, *partstat, *role; SOGoUserManager *um; SOGoCalendarComponent *co; SOGoUser *ownerUser; - jsonOrganizer = [NSMutableDictionary dictionary]; - email = [organizer rfc822Email]; - role = nil; - partstat = nil; - - if ([email length]) + if (organizerProfile == nil) { - um = [SOGoUserManager sharedUserManager]; + profile = [NSMutableDictionary dictionary]; + email = [organizer rfc822Email]; + role = nil; + partstat = nil; - name = [organizer cn]; - uid = [um getUIDForEmail: email]; + if ([email length]) + { + um = [SOGoUserManager sharedUserManager]; + + name = [organizer cn]; + uid = [um getUIDForEmail: email]; + + partstat = [[organizer partStat] lowercaseString]; + role = [[organizer role] lowercaseString]; + } + else + { + // No organizer defined in vEvent; use calendar owner + co = [self clientObject]; + uid = [[co container] ownerInContext: context]; + ownerUser = [SOGoUser userWithLogin: uid roles: nil]; + ownerIdentity = [ownerUser defaultIdentity]; + + name = [ownerIdentity objectForKey: @"fullName"]; + email = [ownerIdentity objectForKey: @"email"]; + } - partstat = [[organizer partStat] lowercaseString]; - role = [[organizer role] lowercaseString]; - } - else - { - // No organizer defined in vEvent - co = [self clientObject]; - uid = [[co container] ownerInContext: context]; - ownerUser = [SOGoUser userWithLogin: uid roles: nil]; - ownerIdentity = [ownerUser defaultIdentity]; + if (uid != nil) + [profile setObject: uid + forKey: @"uid"]; + else + uid = email; - name = [ownerIdentity objectForKey: @"fullName"]; - email = [ownerIdentity objectForKey: @"email"]; + [profile setObject: name + forKey: @"name"]; + + [profile setObject: email + forKey: @"email"]; + + if (partstat == nil || ![partstat length]) + partstat = @"accepted"; + [profile setObject: partstat + forKey: @"partstat"]; + + if (role == nil || ![role length]) + role = @"chair"; + [profile setObject: role + forKey: @"role"]; + + organizerProfile = [NSDictionary dictionaryWithObject: profile forKey: uid]; + [organizerProfile retain]; } - if (uid != nil) - [jsonOrganizer setObject: uid - forKey: @"uid"]; + return organizerProfile; +} - [jsonOrganizer setObject: name - forKey: @"name"]; - - [jsonOrganizer setObject: email - forKey: @"email"]; - - if (partstat == nil || ![partstat length]) - partstat = @"accepted"; - [jsonOrganizer setObject: partstat - forKey: @"partstat"]; - - if (role == nil || ![role length]) - role = @"chair"; - [jsonOrganizer setObject: role - forKey: @"role"]; - - return [jsonOrganizer jsonRepresentation]; +- (NSString *) jsonOrganizer +{ + return [[[[self organizerProfile] allValues] lastObject] jsonRepresentation]; } - (void) setLocation: (NSString *) _value @@ -1136,6 +1151,56 @@ iRANGE(2); return calendarList; } +/** + * This method is called from the wox template and uses to display the event + * organizer in the edition window of the attendees. + * Returns an array of the two elements : + * - array of calendar owners + * - dictionary of owners profiles + */ +- (NSArray *) calendarOwnerList +{ + NSArray *calendars; + NSMutableArray *owners; + NSDictionary *currentOwnerIdentity; + NSMutableDictionary *profiles, *currentOwnerProfile; + NSString *currentOwner; + SOGoAppointmentFolder *currentCalendar; + SOGoUser *currentUser; + unsigned i; + + calendars = [self calendarList]; + owners = [NSMutableArray arrayWithCapacity: [calendars count]]; + profiles = [NSMutableDictionary dictionaryWithDictionary: [self organizerProfile]]; + + for (i = 0; i < [calendars count]; i++) + { + currentCalendar = [calendars objectAtIndex: i]; + currentOwner = [currentCalendar ownerInContext: context]; + [owners addObject: currentOwner]; + + if ([profiles objectForKey: currentOwner] == nil) + { + currentUser = [SOGoUser userWithLogin: currentOwner roles: nil]; + currentOwnerIdentity = [currentUser defaultIdentity]; + + currentOwnerProfile = [NSMutableDictionary dictionary]; + [currentOwnerProfile setObject: [currentOwnerIdentity objectForKey: @"fullName"] + forKey: @"name"]; + [currentOwnerProfile setObject: [currentOwnerIdentity objectForKey: @"email"] + forKey: @"email"]; + [currentOwnerProfile setObject: @"accepted" + forKey: @"partstat"]; + [currentOwnerProfile setObject: @"chair" + forKey: @"role"]; + + [profiles setObject: currentOwnerProfile forKey: currentOwner]; + } + } + + return [NSArray arrayWithObjects: owners, profiles, nil]; +} + - (NSString *) calendarDisplayName { NSString *fDisplayName; diff --git a/UI/Templates/SchedulerUI/UIxComponentEditor.wox b/UI/Templates/SchedulerUI/UIxComponentEditor.wox index b597b9b03..351d0b163 100644 --- a/UI/Templates/SchedulerUI/UIxComponentEditor.wox +++ b/UI/Templates/SchedulerUI/UIxComponentEditor.wox @@ -21,8 +21,10 @@ const:negate="YES">false; var attendees = ; var ownerLogin = ''; - var organizer = ; - + var organizer = ;var owners = ;