From 1c969c55faad6640893ab598ca6fba314bfab10b Mon Sep 17 00:00:00 2001 From: wolfgang Date: Mon, 2 Apr 2007 21:29:40 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1040 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 20 ++++ OGoContentStore/OCSContactFieldExtractor.m | 31 +++--- OGoContentStore/contact.ocs | 5 + .../sql/generate-folderinfo-sql-for-users.sh | 1 + .../Appointments/SOGoAppointmentFolder.h | 2 + .../Appointments/SOGoAppointmentFolder.m | 69 +++++++++++++- SoObjects/Contacts/SOGoContactGCSFolder.m | 6 +- SoObjects/Contacts/SOGoContactLDAPFolder.m | 1 + UI/Contacts/English.lproj/Localizable.strings | 7 +- UI/Contacts/French.lproj/Localizable.strings | 6 +- UI/Contacts/UIxContactEditor.m | 47 ++++++---- UI/Contacts/UIxContactView.m | 2 +- UI/Scheduler/UIxCalView.h | 94 +++++++++---------- UI/Scheduler/UIxCalView.m | 94 ++----------------- UI/Scheduler/UIxCalendarSelector.h | 2 +- UI/Scheduler/UIxCalendarSelector.m | 33 +++---- UI/Scheduler/UIxComponentEditor.h | 4 +- UI/Scheduler/UIxComponentEditor.m | 83 +++++++++------- UI/Templates/ContactsUI/UIxContactView.wox | 4 +- .../ContactsUI/UIxContactsListView.wox | 21 +++-- UI/WebServerResources/ContactsUI.js | 2 +- UI/WebServerResources/SchedulerUI.js | 10 -- .../UIxAppointmentEditor.css | 3 + UI/WebServerResources/UIxTaskEditor.css | 3 + 24 files changed, 297 insertions(+), 253 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f675d5f..ac1ae32f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2007-04-02 Wolfgang Sourdeau + + * UI/Contacts/UIxContactView.m ([UIxContactView -workUrl]): we + want the "work" url instead of the "home". + + * UI/Contacts/UIxContactEditor.m ([UIxContactEditor + -_saveSnapshot]): save url values from snapshot. + ([UIxContactEditor -initSnapshot]): load url values from snapshot. + + * UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor + -calendarList]): new method replacing "availableCalendars". + + * UI/Scheduler/UIxCalendarSelector.m ([UIxCalendarSelector + -calendarFolders]): we now take the list of subscribed calendar + from the container. + + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder -calendarFoldersInContext:context]): new + method derived from and replacing [UIxCalView calendarFolders]. + 2007-03-30 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount diff --git a/OGoContentStore/OCSContactFieldExtractor.m b/OGoContentStore/OCSContactFieldExtractor.m index 7b53fd06..5ca2024f 100644 --- a/OGoContentStore/OCSContactFieldExtractor.m +++ b/OGoContentStore/OCSContactFieldExtractor.m @@ -42,7 +42,7 @@ static NSString *fieldNames[] = { nil, nil }; -- (NSMutableDictionary *) extractQuickFieldsFromVCard: (NGVCard *) _vCard +- (NSMutableDictionary *) extractQuickFieldsFromVCard: (NGVCard *) vCard { NSMutableDictionary *fields; NSArray *values; @@ -50,15 +50,15 @@ static NSString *fieldNames[] = { NSString *value; unsigned int max; - if (_vCard == nil) + if (vCard == nil) return nil; fields = [NSMutableDictionary dictionaryWithCapacity:16]; - value = [_vCard fn]; + value = [vCard fn]; if (value) [fields setObject: value forKey: @"cn"]; - values = [_vCard n]; + values = [vCard n]; if (values) { max = [values count]; @@ -70,26 +70,25 @@ static NSString *fieldNames[] = { forKey: @"givenName"]; } } - value = [_vCard preferredTel]; + value = [vCard preferredTel]; if (value) [fields setObject: value forKey: @"telephoneNumber"]; - value = [_vCard preferredEMail]; + value = [vCard preferredEMail]; if (value) [fields setObject: value forKey: @"mail"]; - values = [_vCard org]; - if (values) + values = [vCard org]; + max = [values count]; + if (max > 0) { - max = [values count]; - if (max > 0) - { - [fields setObject: [values objectAtIndex: 0] forKey: @"o"]; - if (max > 1) - [fields setObject: [values objectAtIndex: 1] forKey: @"ou"]; - } + [fields setObject: [values objectAtIndex: 0] forKey: @"o"]; + if (max > 1) + [fields setObject: [values objectAtIndex: 1] forKey: @"ou"]; } - adr = [_vCard preferredAdr]; + adr = [vCard preferredAdr]; if (adr) [fields setObject: [adr value: 3] forKey: @"l"]; + value = [[vCard uniqueChildWithTag: @"X-AIM"] value: 0]; + [fields setObject: value forKey: @"screenname"]; return fields; } diff --git a/OGoContentStore/contact.ocs b/OGoContentStore/contact.ocs index 29fa9915..d1372447 100644 --- a/OGoContentStore/contact.ocs +++ b/OGoContentStore/contact.ocs @@ -24,6 +24,11 @@ sqlType = "VARCHAR(256)"; allowsNull = YES; }, + { + columnName = screenname; + sqlType = "VARCHAR(256)"; + allowsNull = YES; + }, { columnName = l; sqlType = "VARCHAR(256)"; diff --git a/OGoContentStore/sql/generate-folderinfo-sql-for-users.sh b/OGoContentStore/sql/generate-folderinfo-sql-for-users.sh index e8ba9c59..0868d191 100755 --- a/OGoContentStore/sql/generate-folderinfo-sql-for-users.sh +++ b/OGoContentStore/sql/generate-folderinfo-sql-for-users.sh @@ -110,6 +110,7 @@ CREATE TABLE SOGo_${USER_TABLE}_contacts_quick ( givenname VARCHAR(256), cn VARCHAR(256), sn VARCHAR(256), + screenname VARCHAR(256), l VARCHAR(256), mail VARCHAR(256), o VARCHAR(256), diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index 48eac1d0..b072bb20 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -106,6 +106,8 @@ - (NSArray *) fetchAllSOGoAppointments; +- (NSArray *) calendarFoldersInContext: (WOContext *) context; + @end #endif /* __Appointments_SOGoAppointmentFolder_H__ */ diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index c511e3fc..80691900 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -72,7 +72,7 @@ static NSNumber *sharedYes = nil; NSStringFromClass([self superclass]), [super version]); lm = [NGLoggerManager defaultLoggerManager]; - logger = [lm loggerForDefaultKey:@"SOGoAppointmentFolderDebugEnabled"]; + logger = [lm loggerForDefaultKey: @"SOGoAppointmentFolderDebugEnabled"]; // securityInfo = [self soClassSecurityInfo]; // [securityInfo declareRole: SOGoRole_Delegate @@ -221,7 +221,8 @@ static NSNumber *sharedYes = nil; filters = [NSMutableArray new]; - children = [[parentNode getElementsByTagName: @"comp-filter"] objectEnumerator]; + children = [[parentNode getElementsByTagName: @"comp-filter"] + objectEnumerator]; node = [children nextObject]; while (node) { @@ -443,7 +444,7 @@ static NSNumber *sharedYes = nil; } if (nameFields == nil) - nameFields = [[NSArray alloc] initWithObjects:@"c_name", nil]; + nameFields = [[NSArray alloc] initWithObjects: @"c_name", nil]; qualifier = [EOQualifier qualifierWithQualifierFormat:@"uid = %@", _u]; records = [_f fetchFields: nameFields matchingQualifier: qualifier]; @@ -1133,6 +1134,68 @@ static NSNumber *sharedYes = nil; return events; } +#warning We only support ONE calendar per user at this time +- (BOOL) _appendSubscribedFolders: (NSDictionary *) subscribedFolders + toFolderList: (NSMutableArray *) calendarFolders +{ + NSEnumerator *keys; + NSString *currentKey; + NSMutableDictionary *currentCalendar; + BOOL firstShouldBeActive; + unsigned int count; + + firstShouldBeActive = YES; + + keys = [[subscribedFolders allKeys] objectEnumerator]; + currentKey = [keys nextObject]; + count = 1; + while (currentKey) + { + currentCalendar = [NSMutableDictionary new]; + [currentCalendar autorelease]; + [currentCalendar + setDictionary: [subscribedFolders objectForKey: currentKey]]; + [currentCalendar setObject: currentKey forKey: @"folder"]; + [calendarFolders addObject: currentCalendar]; + if ([[currentCalendar objectForKey: @"active"] boolValue]) + firstShouldBeActive = NO; + count++; + currentKey = [keys nextObject]; + } + + return firstShouldBeActive; +} + +- (NSArray *) calendarFoldersInContext: (WOContext *) context +{ + NSMutableDictionary *userCalendar, *calendarDict; + NSMutableArray *calendarFolders; + SOGoUser *activeUser; + BOOL firstActive; + + calendarFolders = [NSMutableArray new]; + [calendarFolders autorelease]; + + activeUser = [context activeUser]; + + userCalendar = [NSMutableDictionary new]; + [userCalendar autorelease]; + [userCalendar setObject: @"/" forKey: @"folder"]; + [userCalendar setObject: @"Calendar" forKey: @"displayName"]; + [calendarFolders addObject: userCalendar]; + + calendarDict = [[activeUser userSettings] objectForKey: @"Calendar"]; + firstActive = [[calendarDict objectForKey: @"activateUserFolder"] boolValue]; + firstActive = ([self _appendSubscribedFolders: + [calendarDict objectForKey: @"SubscribedFolders"] + toFolderList: calendarFolders] + || firstActive); + [userCalendar setObject: [NSNumber numberWithBool: firstActive] + forKey: @"active"]; + + return calendarFolders; +} + /* folder type */ - (NSString *) folderType diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.m b/SoObjects/Contacts/SOGoContactGCSFolder.m index 29dbac21..cc15b14a 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.m +++ b/SoObjects/Contacts/SOGoContactGCSFolder.m @@ -27,8 +27,8 @@ #import "SOGoContactGCSFolder.h" #define folderListingFields [NSArray arrayWithObjects: @"c_name", @"cn", \ - @"sn", @"givenname", @"l", \ - @"mail", @"telephonenumber", \ + @"givenname", @"screenname", \ + @"o", @"mail", @"telephonenumber", \ nil] @implementation SOGoContactGCSFolder @@ -155,7 +155,7 @@ fields = folderListingFields; qualifier = [self _qualifierForFilter: filter]; records = [[self ocsFolder] fetchFields: fields - matchingQualifier: qualifier]; + matchingQualifier: qualifier]; if (records) { ordering diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index b14734e8..fb51aa20 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -45,6 +45,7 @@ #define folderListingFields [NSArray arrayWithObjects: @"c_name", @"cn", \ @"displayName", \ @"streetAddress", \ + @"o", \ @"sn", @"givenname", @"l", \ @"mail", @"telephonenumber", \ @"mailNickname", \ diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index c6256673..d94efb27 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -6,8 +6,8 @@ "Common" = "Common"; "Contact editor" = "Contact editor"; "Contact viewer" = "Contact viewer"; -"Copy from Anais" = "Copy from Anais"; -"EMail" = "EMail"; +"Email" = "Email"; +"Screen Name" = "Screen Name"; "Extended" = "Extended"; "Fax" = "Fax"; "Firstname" = "Firstname"; @@ -18,7 +18,8 @@ "MobilePhone" = "MobilePhone"; "Name" = "Name"; "OfficePhone" = "OfficePhone"; -"Organisation" = "Organisation"; +"Organization" = "Organization"; +"Work Phone" = "Work Phone"; "Phone" = "Phone"; "Phones" = "Phones"; "Postal" = "Postal"; diff --git a/UI/Contacts/French.lproj/Localizable.strings b/UI/Contacts/French.lproj/Localizable.strings index 660de024..940de3a5 100644 --- a/UI/Contacts/French.lproj/Localizable.strings +++ b/UI/Contacts/French.lproj/Localizable.strings @@ -16,7 +16,8 @@ "Common" = "Identité"; "Contact editor" = "Éditer le contact"; "Contact viewer" = "Visualiser le contact"; -"EMail" = "Courriel"; +"Email" = "Adresse électronique"; +"Screen Name" = "Pseudo"; "Extended" = "Informations complémentaires"; "Fax" = "Fax"; "Firstname" = "Prénom"; @@ -25,7 +26,8 @@ "Location" = "Lieux"; "MobilePhone" = "Mobile"; "OfficePhone" = "Bureau"; -"Organisation" = "Société"; +"Organization" = "Société"; +"Work Phone" = "Travail"; "Phone" = "Téléphone"; "Postal" = "Professionnelle"; "Save" = "Sauvegarder"; diff --git a/UI/Contacts/UIxContactEditor.m b/UI/Contacts/UIxContactEditor.m index a6da4280..0b6dd7b7 100644 --- a/UI/Contacts/UIxContactEditor.m +++ b/UI/Contacts/UIxContactEditor.m @@ -83,13 +83,14 @@ /* load/store content format */ -- (void)_fixupSnapshot { +- (void) _fixupSnapshot +{ // TODO: perform sanity checking, eg build CN on demand NSString *cn, *gn, *sn; - cn = [snapshot objectForKey:@"cn"]; - gn = [snapshot objectForKey:@"givenName"]; - sn = [snapshot objectForKey:@"sn"]; + cn = [snapshot objectForKey: @"cn"]; + gn = [snapshot objectForKey: @"givenName"]; + sn = [snapshot objectForKey: @"sn"]; if (![sn isNotNull] || [sn length] == 0) sn = nil; @@ -103,12 +104,12 @@ // TODO: need a better name parser here NSRange r; - r = [cn rangeOfString:@" "]; + r = [cn rangeOfString: @" "]; sn = (r.length > 0) ? [cn substringFromIndex:(r.location + r.length)] : cn; } - [snapshot setObject:sn forKey:@"sn"]; + [snapshot setObject:sn forKey: @"sn"]; } if (sn == nil && gn == nil) cn = @"[noname]"; @@ -117,8 +118,8 @@ else if (gn == nil) cn = sn; else - cn = [[gn stringByAppendingString:@" "] stringByAppendingString:sn]; - [snapshot setObject:cn forKey:@"cn"]; + cn = [[gn stringByAppendingString: @" "] stringByAppendingString:sn]; + [snapshot setObject:cn forKey: @"cn"]; } /* helper */ @@ -131,13 +132,13 @@ uri = [[[self context] request] uri]; /* first: identify query parameters */ - r = [uri rangeOfString:@"?" options:NSBackwardsSearch]; + r = [uri rangeOfString: @"?" options:NSBackwardsSearch]; if (r.length > 0) uri = [uri substringToIndex:r.location]; /* next: append trailing slash */ - if (![uri hasSuffix:@"/"]) - uri = [uri stringByAppendingString:@"/"]; + if (![uri hasSuffix: @"/"]) + uri = [uri stringByAppendingString: @"/"]; /* next: append method */ uri = [uri stringByAppendingString:_method]; @@ -373,7 +374,7 @@ [self initSnapshot]; else return [NSException exceptionWithHTTPStatus:404 /* Not Found */ - reason:@"could not open contact"]; + reason: @"could not open contact"]; return self; } @@ -454,6 +455,7 @@ - (void) _saveSnapshot { CardElement *element; + NSArray *units; [card setNWithFamily: [snapshot objectForKey: @"sn"] given: [snapshot objectForKey: @"givenName"] @@ -485,10 +487,20 @@ value: [snapshot objectForKey: @"calFBURL"]]; [card setUniqueChild: element]; + units = [NSArray arrayWithObject: [snapshot objectForKey: @"workService"]]; + [card setOrg: [snapshot objectForKey: @"workCompany"] + units: units]; + [self _savePhoneValues]; [self _saveEmails]; + [[self _elementWithTag: @"url" ofType: @"home"] + setValue: 0 to: [snapshot objectForKey: @"homeURL"]]; + [[self _elementWithTag: @"url" ofType: @"work"] + setValue: 0 to: [snapshot objectForKey: @"workURL"]]; + [[card uniqueChildWithTag: @"x-aim"] - setValue: 0 to: [snapshot objectForKey: @"screenName"]]; + setValue: 0 + to: [snapshot objectForKey: @"screenName"]]; } - (id ) saveAction @@ -542,7 +554,8 @@ [self redirectToLocation: [self relativePathToUserFolderSubPath: url]]; } -- (id)newAction { +- (id) newAction +{ // TODO: this is almost a DUP of UIxAppointmentEditor /* This method creates a unique ID and redirects to the "edit" method on the @@ -563,10 +576,10 @@ if ([objectId length] == 0) return [NSException exceptionWithHTTPStatus:500 /* Internal Error */ - reason:@"could not create a unique ID"]; + reason: @"could not create a unique ID"]; - nextMethod = [NSString stringWithFormat:@"../%@/%@", - objectId, [self editActionName]]; + nextMethod = [NSString stringWithFormat: @"../%@/%@", + objectId, [self editActionName]]; uri = [self _completeURIForMethod:nextMethod]; return [self redirectToLocation:uri]; } diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index f6919bfe..b80dc597 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -410,7 +410,7 @@ - (NSString *) workUrl { - return [self _urlOfType: @"home"]; + return [self _urlOfType: @"work"]; } - (BOOL) hasOtherInfos diff --git a/UI/Scheduler/UIxCalView.h b/UI/Scheduler/UIxCalView.h index 4b2eeb10..9cf7c7bb 100644 --- a/UI/Scheduler/UIxCalView.h +++ b/UI/Scheduler/UIxCalView.h @@ -12,18 +12,23 @@ a SOPE clientObject (which usually is an SOGoAppointmentFolder). */ -@class NSString, NSArray, NSDictionary, NSMutableDictionary, NSCalendarDate, SOGoAptFormatter; +@class NSArray; +@class NSCalendarDate; +@class NSDictionary; +@class NSMutableDictionary; +@class NSString; + +@class SOGoAptFormatter; @class SOGoAppointmentFolder; @interface UIxCalView : UIxComponent { - NSArray *appointments; - NSMutableArray *calendarFolders; + NSArray *appointments; NSMutableDictionary *componentsData; - NSArray *tasks; - NSArray *allDayApts; - id appointment; - NSCalendarDate *currentDay; + NSArray *tasks; + NSArray *allDayApts; + id appointment; + NSCalendarDate *currentDay; SOGoAptFormatter *aptFormatter; SOGoAptFormatter *aptTooltipFormatter; SOGoAptFormatter *privateAptFormatter; @@ -36,10 +41,9 @@ } aptFlags; } - /* config */ -- (void)configureFormatters; +- (void) configureFormatters; /* accessors */ @@ -49,64 +53,60 @@ - (void) setTasks: (NSArray *) _tasks; - (NSArray *) tasks; -- (NSArray *)allDayApts; -- (id)appointment; -- (BOOL)isMyApt; -- (BOOL)canAccessApt; /* protection */ +- (NSArray *) allDayApts; +- (id) appointment; +- (BOOL) isMyApt; +- (BOOL) canAccessApt; /* protection */ -- (BOOL)hasDayInfo; -- (BOOL)hasHoldidayInfo; -- (BOOL)hasAllDayApts; +- (BOOL) hasDayInfo; +- (BOOL) hasHoldidayInfo; +- (BOOL) hasAllDayApts; -- (NSDictionary *)aptTypeDict; -- (NSString *)aptTypeLabel; -- (NSString *)aptTypeIcon; -- (SOGoAptFormatter *)aptFormatter; +- (NSDictionary *) aptTypeDict; +- (NSString *) aptTypeLabel; +- (NSString *) aptTypeIcon; +- (SOGoAptFormatter *) aptFormatter; -- (NSString *)shortTextForApt; -- (NSString *)shortTitleForApt; -- (NSString *)tooltipForApt; -- (NSString *)appointmentViewURL; +- (NSString *) shortTextForApt; +- (NSString *) shortTitleForApt; +- (NSString *) tooltipForApt; +- (NSString *) appointmentViewURL; -- (id)holidayInfo; +- (id) holidayInfo; /* related to current day */ -- (void)setCurrentDay:(NSCalendarDate *)_day; -- (NSCalendarDate *)currentDay; -- (NSString *)currentDayName; /* localized */ +- (void) setCurrentDay: (NSCalendarDate *) _day; +- (NSCalendarDate *) currentDay; +- (NSString *) currentDayName; /* localized */ /* defaults */ -- (BOOL)showFullNames; -- (BOOL)showAMPMDates; -- (unsigned)dayStartHour; -- (unsigned)dayEndHour; -- (BOOL)shouldDisplayWeekend; -- (BOOL)shouldDisplayRejectedAppointments; - -- (NSCalendarDate *)referenceDateForFormatter; +- (BOOL) showFullNames; +- (BOOL) showAMPMDates; +- (unsigned) dayStartHour; +- (unsigned) dayEndHour; +- (BOOL) shouldDisplayWeekend; +- (BOOL) shouldDisplayRejectedAppointments; + +- (NSCalendarDate *) referenceDateForFormatter; -- (NSCalendarDate *)thisMonth; -- (NSCalendarDate *)nextMonth; +- (NSCalendarDate *) thisMonth; +- (NSCalendarDate *) nextMonth; /* fetching */ -- (NSCalendarDate *)startDate; -- (NSCalendarDate *)endDate; +- (NSCalendarDate *) startDate; +- (NSCalendarDate *) endDate; - (NSArray *) fetchCoreAppointmentsInfos; - (NSArray *) fetchCoreTasksInfos; /* date selection */ -- (NSDictionary *)todayQueryParameters; -- (NSDictionary *)currentDayQueryParameters; - -/* calendarUIDs */ - -- (NSString *)formattedCalendarUIDs; +- (NSDictionary *) todayQueryParameters; +- (NSDictionary *) currentDayQueryParameters; /* CSS related */ -- (NSString *)aptStyle; +- (NSString *) aptStyle; /* protected methods */ - (NSDictionary *) _dateQueryParametersWithOffset: (int) daysOffset; diff --git a/UI/Scheduler/UIxCalView.m b/UI/Scheduler/UIxCalView.m index 11047344..726fca51 100644 --- a/UI/Scheduler/UIxCalView.m +++ b/UI/Scheduler/UIxCalView.m @@ -56,7 +56,6 @@ static BOOL shouldDisplayWeekend = NO; = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; [self configureFormatters]; componentsData = [NSMutableDictionary new]; - calendarFolders = nil; } return self; @@ -64,15 +63,14 @@ static BOOL shouldDisplayWeekend = NO; - (void) dealloc { - [calendarFolders release]; [componentsData release]; - [appointments release]; - [allDayApts release]; - [appointment release]; - [currentDay release]; - [aptFormatter release]; - [aptTooltipFormatter release]; - [privateAptFormatter release]; + [appointments release]; + [allDayApts release]; + [appointment release]; + [currentDay release]; + [aptFormatter release]; + [aptTooltipFormatter release]; + [privateAptFormatter release]; [privateAptTooltipFormatter release]; [super dealloc]; } @@ -449,62 +447,6 @@ static BOOL shouldDisplayWeekend = NO; return [[self startDate] tomorrow]; } -#warning We only support ONE calendar per user at this time -- (BOOL) _appendSubscribedFolders: (NSDictionary *) subscribedFolders -{ - NSEnumerator *keys; - NSString *currentKey; - NSMutableDictionary *currentCalendar; - BOOL firstShouldBeActive; - unsigned int count; - - firstShouldBeActive = YES; - - keys = [[subscribedFolders allKeys] objectEnumerator]; - currentKey = [keys nextObject]; - count = 1; - while (currentKey) - { - currentCalendar = [NSMutableDictionary new]; - [currentCalendar autorelease]; - [currentCalendar - setDictionary: [subscribedFolders objectForKey: currentKey]]; - [currentCalendar setObject: currentKey forKey: @"folder"]; - [calendarFolders addObject: currentCalendar]; - if ([[currentCalendar objectForKey: @"active"] boolValue]) - firstShouldBeActive = NO; - count++; - currentKey = [keys nextObject]; - } - - return firstShouldBeActive; -} - -- (void) _setupCalendarFolders -{ - NSMutableDictionary *userCalendar, *calendarDict; - SOGoUser *activeUser; - BOOL firstActive; - - calendarFolders = [NSMutableArray new]; - activeUser = [context activeUser]; - - userCalendar = [NSMutableDictionary new]; - [userCalendar autorelease]; - [userCalendar setObject: @"/" forKey: @"folder"]; - [userCalendar setObject: [self labelForKey: @"Calendar"] - forKey: @"displayName"]; - [calendarFolders addObject: userCalendar]; - - calendarDict = [[activeUser userSettings] objectForKey: @"Calendar"]; - firstActive = [[calendarDict objectForKey: @"activateUserFolder"] boolValue]; - firstActive = ([self _appendSubscribedFolders: - [calendarDict objectForKey: @"SubscribedFolders"]] - || firstActive); - [userCalendar setObject: [NSNumber numberWithBool: firstActive] - forKey: @"active"]; -} - - (SOGoAppointmentFolder *) _aptFolder: (NSString *) folder withClientObject: (SOGoAppointmentFolder *) clientObject { @@ -524,14 +466,6 @@ static BOOL shouldDisplayWeekend = NO; return aptFolder; } -- (NSArray *) calendarFolders -{ - if (!calendarFolders) - [self _setupCalendarFolders]; - - return calendarFolders; -} - - (NSArray *) _activeCalendarFolders { NSMutableArray *activeFolders; @@ -542,12 +476,10 @@ static BOOL shouldDisplayWeekend = NO; activeFolders = [NSMutableArray new]; [activeFolders autorelease]; - if (!calendarFolders) - [self _setupCalendarFolders]; - clientObject = [self clientObject]; - folders = [calendarFolders objectEnumerator]; + folders = [[clientObject calendarFoldersInContext: context] + objectEnumerator]; currentFolderDict = [folders nextObject]; while (currentFolderDict) { @@ -662,14 +594,6 @@ static BOOL shouldDisplayWeekend = NO; return [self queryParametersBySettingSelectedDate: currentDay]; } -/* calendarUIDs */ - -- (NSString *) formattedCalendarUIDs -{ - return [[[self clientObject] calendarUIDs] - componentsJoinedByString: @", "]; -} - /* Actions */ - (NSString *) _userFolderURI diff --git a/UI/Scheduler/UIxCalendarSelector.h b/UI/Scheduler/UIxCalendarSelector.h index 3d15fc77..410ce6db 100644 --- a/UI/Scheduler/UIxCalendarSelector.h +++ b/UI/Scheduler/UIxCalendarSelector.h @@ -32,7 +32,6 @@ @interface UIxCalendarSelector : UIxComponent { - NSMutableArray *calendarFolders; NSMutableDictionary *colors; NSDictionary *currentCalendarFolder; @@ -40,6 +39,7 @@ } - (NSArray *) calendarFolders; + - (void) setCurrentCalendarFolder: (NSDictionary *) newCurrentCalendarFolder; - (NSDictionary *) currentCalendarFolder; diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m index ab6b124a..d28e9484 100644 --- a/UI/Scheduler/UIxCalendarSelector.m +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -31,6 +31,7 @@ #import #import #import +#import #import "UIxCalendarSelector.h" @@ -90,8 +91,7 @@ colorForNumber (unsigned int number) { if ((self = [super init])) { - colors = [NSMutableDictionary new]; - calendarFolders = nil; + colors = nil; currentCalendarFolder = nil; } @@ -100,34 +100,35 @@ colorForNumber (unsigned int number) - (void) dealloc { - [calendarFolders release]; [currentCalendarFolder release]; [colors release]; [super dealloc]; } -- (void) setCalendarFolders: (NSArray *) newCalendarFolders +- (NSArray *) calendarFolders { + NSArray *calendarFolders; NSEnumerator *newFolders; NSDictionary *currentFolder; unsigned int count; - ASSIGN (calendarFolders, newCalendarFolders); - - newFolders = [calendarFolders objectEnumerator]; - currentFolder = [newFolders nextObject]; - count = 0; - while (currentFolder) + calendarFolders + = [[self clientObject] calendarFoldersInContext: context]; + if (!colors) { - [colors setObject: colorForNumber (count) - forKey: [currentFolder objectForKey: @"folder"]]; - count++; + colors = [NSMutableDictionary new]; + count = 0; + newFolders = [calendarFolders objectEnumerator]; currentFolder = [newFolders nextObject]; + while (currentFolder) + { + [colors setObject: colorForNumber (count) + forKey: [currentFolder objectForKey: @"folder"]]; + count++; + currentFolder = [newFolders nextObject]; + } } -} -- (NSArray *) calendarFolders -{ return calendarFolders; } diff --git a/UI/Scheduler/UIxComponentEditor.h b/UI/Scheduler/UIxComponentEditor.h index f6798187..e7c53351 100644 --- a/UI/Scheduler/UIxComponentEditor.h +++ b/UI/Scheduler/UIxComponentEditor.h @@ -41,6 +41,7 @@ id item; NSString *saveURL; + NSMutableArray *calendarList; /* individual values */ NSCalendarDate *cycleUntilDate; @@ -125,9 +126,6 @@ - (void) setIsCycleEndUntil; - (void) setIsCycleEndNever; -- (NSString *) componentOwner; -- (NSArray *) availableCalendars; - /* access */ - (BOOL) isMyComponent; - (BOOL) canEditComponent; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 1b8c8d7d..11258889 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -42,6 +42,7 @@ #import #import #import +#import #import #import @@ -62,6 +63,7 @@ organizer = nil; attendeesNames = nil; attendeesEmails = nil; + calendarList = nil; } return self; @@ -82,6 +84,7 @@ [url release]; [attendeesNames release]; [attendeesEmails release]; + [calendarList release]; [super dealloc]; } @@ -293,7 +296,51 @@ - (NSString *) itemCategoryText { - return [self labelForKey: [NSString stringWithFormat: @"category_%@", item]]; + return [self labelForKey: + [NSString stringWithFormat: @"category_%@", item]]; +} + +- (NSArray *) calendarList +{ + SOGoAppointmentFolder *folder; + NSEnumerator *allCalendars; + NSDictionary *currentCalendar; + + if (!calendarList) + { + calendarList = [NSMutableArray new]; + folder = [[self clientObject] container]; + allCalendars + = [[folder calendarFoldersInContext: context] objectEnumerator]; + currentCalendar = [allCalendars nextObject]; + while (currentCalendar) + { + if ([[currentCalendar objectForKey: @"active"] boolValue]) + [calendarList addObject: currentCalendar]; + currentCalendar = [allCalendars nextObject]; + } + } + + return calendarList; +} + +- (NSString *) itemCalendarText +{ + return item; +} + +- (NSString *) calendarsFoldersList +{ + NSArray *calendars; + + calendars = [[self calendarList] valueForKey: @"folder"]; + + return [calendars componentsJoinedByString: @","]; +} + +- (NSString *) componentCalendar +{ + return @"/"; } /* priorities */ @@ -706,40 +753,6 @@ /* contact editor compatibility */ -- (NSArray *) availableCalendars -{ - NSEnumerator *rawContacts; - NSString *list, *currentId; - NSMutableArray *calendars; - SOGoUser *user; - - calendars = [NSMutableArray array]; - - user = [context activeUser]; - list = [[user userDefaults] stringForKey: @"calendaruids"]; - if ([list length] == 0) - list = [self shortUserNameForDisplay]; - - rawContacts - = [[list componentsSeparatedByString: @","] objectEnumerator]; - currentId = [rawContacts nextObject]; - while (currentId) - { - if ([currentId hasPrefix: @"-"]) - [calendars addObject: [currentId substringFromIndex: 1]]; - else - [calendars addObject: currentId]; - currentId = [rawContacts nextObject]; - } - - return calendars; -} - -- (NSString *) componentOwner -{ - return componentOwner; -} - - (NSString *) urlButtonClasses { NSString *classes; diff --git a/UI/Templates/ContactsUI/UIxContactView.wox b/UI/Templates/ContactsUI/UIxContactView.wox index e7094c44..adfdbeac 100644 --- a/UI/Templates/ContactsUI/UIxContactView.wox +++ b/UI/Templates/ContactsUI/UIxContactView.wox @@ -27,9 +27,9 @@ >

- + - + + + + @@ -45,10 +48,12 @@ onclick="return onContactRowClick(event, this);" ondblclick="return onContactRowDblClick(event, this);" oncontextmenu="return onContactContextMenu(event, this);"> - - - - + + + + + diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index caee6cdb..f63a3d6a 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -377,7 +377,7 @@ function onFolderSelectionChange() { function onSearchFormSubmit() { var searchValue = $("searchValue"); - openContactsFolder(URLForFolderID(currentContactFolder), + openContactsFolder(currentContactFolder, "search=" + searchValue.value); return false; diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 856077e5..2c069d7e 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -956,16 +956,6 @@ function addContact(tag, fullContactName, contactId, contactName, contactEmail) return false; } -function onChangeCalendar(list) { - var form = document.forms.editform; - log ("before: " + form.getAttribute("action")); - var urlElems = form.getAttribute("action").split("/"); - urlElems[urlElems.length-4] - = list.childNodesWithTag("option")[list.value].innerHTML; - form.setAttribute("action", urlElems.join("/")); - log ("after: " + form.getAttribute("action")); -} - function validateBrowseURL(input) { var button = $("browseURLBtn"); diff --git a/UI/WebServerResources/UIxAppointmentEditor.css b/UI/WebServerResources/UIxAppointmentEditor.css index 5e12f260..383f1ef6 100644 --- a/UI/WebServerResources/UIxAppointmentEditor.css +++ b/UI/WebServerResources/UIxAppointmentEditor.css @@ -89,6 +89,9 @@ TEXTAREA right: 1em; padding-bottom: 0em; } +SELECT#calendarList +{ width: 7em; } + A#changeUrlButton { margin-left: 1em; } diff --git a/UI/WebServerResources/UIxTaskEditor.css b/UI/WebServerResources/UIxTaskEditor.css index e80c430e..579f492c 100644 --- a/UI/WebServerResources/UIxTaskEditor.css +++ b/UI/WebServerResources/UIxTaskEditor.css @@ -61,6 +61,9 @@ TEXTAREA right: 1em; padding-bottom: 0em; } +SELECT#calendarList +{ width: 7em; } + A#changeUrlButton { margin-left: 1em; } -- 2.39.5