From b75d761539aec708a2ba9d0c3d5e9a77bee40e87 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 18 Jul 2008 19:25:26 +0000 Subject: [PATCH] Monotone-Parent: ed1968caab1223af1ac0a41cf3fd4504a3dfa473 Monotone-Revision: 4d2697a35bcf482dfa9095d58087ffb8469eada5 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-07-18T19:25:26 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 43 ++++ SoObjects/SOGo/SOGoUser.h | 11 +- SoObjects/SOGo/SOGoUser.m | 155 +++++++++++- .../Dutch.lproj/Localizable.strings | 2 +- .../English.lproj/Localizable.strings | 3 +- .../French.lproj/Localizable.strings | 3 +- .../German.lproj/Localizable.strings | 3 +- .../Italian.lproj/Localizable.strings | 3 +- .../Spanish.lproj/Localizable.strings | 5 +- UI/PreferencesUI/UIxPreferences.m | 7 +- UI/Scheduler/UIxAppointmentEditor.m | 16 +- UI/Scheduler/UIxAttendeesEditor.m | 11 + UI/Scheduler/UIxCalDateSelector.m | 5 + UI/Scheduler/UIxCalDayTable.h | 8 +- UI/Scheduler/UIxCalDayTable.m | 66 +++-- UI/Scheduler/UIxCalMainView.m | 5 + UI/Scheduler/UIxCalMonthView.m | 36 ++- UI/Scheduler/UIxCalWeekView.m | 23 +- UI/Scheduler/UIxTaskEditor.m | 23 +- UI/Templates/PreferencesUI/UIxPreferences.wox | 27 +-- .../SchedulerUI/UIxAttendeesEditor.wox | 4 + .../SchedulerUI/UIxCalDateSelector.wox | 1 + UI/Templates/SchedulerUI/UIxCalDayTable.wox | 27 +-- UI/Templates/SchedulerUI/UIxCalMainView.wox | 3 + UI/Templates/SchedulerUI/UIxCalMonthView.wox | 4 +- .../JavascriptAPIExtensions.js | 229 ++++++++---------- UI/WebServerResources/SchedulerUI.css | 32 ++- UI/WebServerResources/UIxAttendeesEditor.js | 27 +-- UI/WebServerResources/generic.js | 2 - 29 files changed, 512 insertions(+), 272 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15e3adc47..e8b090503 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2008-07-18 Wolfgang Sourdeau + + * UI/Scheduler/UIxCalWeekView.m ([UIxCalWeekView -startDate]): + same as below. + + * UI/Scheduler/UIxCalMonthView.m ([UIxCalMonthView + -weeksToDisplay]): use the user's first day of week to chose the + day to start the series. + ([UIxCalMonthView -dayCellClasses]): take the user's first day of + week into account. + ([UIxCalMonthView -endDate]): same as above. + + * UI/Scheduler/UIxCalMainView.m ([UIxCalMainView + -firstDayOfWeek]): new template accessor. + + * UI/Scheduler/UIxCalDayTable.m ([UIxCalDayTable + -currentHourLineClass]): new template accessor. + ([UIxCalDayTable -clickableHourCellClass]): add the class + 'outOfDay' when the current hour is out of the user's day start + and end hour ranges. + + * UI/Scheduler/UIxCalDateSelector.m ([UIxCalDateSelector + -firstDayOfWeek]): new template accessor. + + * UI/Scheduler/UIxAttendeesEditor.m ([UIxAttendeesEditor -dayStartHour]) + ([UIxAttendeesEditor -dayEndHour]): new template accessors. + + * UI/Scheduler/UIxTaskEditor.m ([UIxTaskEditor -newStartDate]), + UI/Scheduler/UIxAppointmentEditor.m ([UIxAppointmentEditor + -newStartDate]): take the user-configured day start hour into account. + + * UI/PreferencesUI/UIxPreferences.m ([UIxPreferences + -firstWeekList]): no longer list the option that enables the + hiding of week numbers. + + * SoObjects/SOGo/SOGoUser.m ([SOGoUser -firstDayOfWeek]) + ([SOGoUser -firstDayOfWeekForDate:date]) + ([SOGoUser -dayOfWeekForDate:date], [SOGoUser -dayStartHour]) + ([SOGoUser -dayEndHour]) + ([SOGoUser -firstWeekOfYearForDate:date]) + ([SOGoUser -weekNumberForDate:date]): new methods that help take + the calendar-related user preferences into account. + 2008-07-17 Wolfgang Sourdeau * UI/Scheduler/UIxCalMonthView.m ([UIxCalMonthView diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index 54f53073d..c417b1a41 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -50,7 +50,6 @@ @class SOGoDateFormatter; @class SOGoUserFolder; -extern NSString *SOGoWeekStartHideWeekNumbers; extern NSString *SOGoWeekStartJanuary1; extern NSString *SOGoWeekStartFirst4DayWeek; extern NSString *SOGoWeekStartFirstFullWeek; @@ -119,6 +118,16 @@ extern NSString *SOGoWeekStartFirstFullWeek; - (NSTimeZone *) timeZone; - (NSTimeZone *) serverTimeZone; +- (unsigned int) firstDayOfWeek; +- (NSCalendarDate *) firstDayOfWeekForDate: (NSCalendarDate *) date; +- (unsigned int) dayOfWeekForDate: (NSCalendarDate *) date; + +- (unsigned int) dayStartHour; +- (unsigned int) dayEndHour; + +- (NSCalendarDate *) firstWeekOfYearForDate: (NSCalendarDate *) date; +- (unsigned int) weekNumberForDate: (NSCalendarDate *) date; + - (NSArray *) mailAccounts; - (NSDictionary *) accountWithName: (NSString *) accountName; - (NSArray *) allIdentities; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 7cfe4aa9e..5376e1562 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -20,6 +20,7 @@ */ #import +#import #import #import #import @@ -30,6 +31,7 @@ #import #import #import +#import #import #import @@ -50,8 +52,10 @@ static NSString *defaultLanguage = nil; static NSArray *superUsernames = nil; static NSURL *AgenorProfileURL = nil; static BOOL acceptAnyUser = NO; +static int sogoFirstDayOfWeek = -1; +static int defaultDayStartTime = -1; +static int defaultDayEndTime = -1; -NSString *SOGoWeekStartHideWeekNumbers = @"HideWeekNumbers"; NSString *SOGoWeekStartJanuary1 = @"January1"; NSString *SOGoWeekStartFirst4DayWeek = @"First4DayWeek"; NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; @@ -73,6 +77,19 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; @implementation SOGoUser +static int +_timeValue (NSString *key) +{ + int time; + + if (key && [key length] > 1) + time = [[key substringToIndex: 2] intValue]; + else + time = -1; + + return time; +} + + (void) initialize { NSString *tzName; @@ -88,6 +105,23 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; serverTimeZone = [NSTimeZone timeZoneWithName: tzName]; [serverTimeZone retain]; } + if (sogoFirstDayOfWeek == -1) + sogoFirstDayOfWeek = [ud integerForKey: @"SOGoFirstDayOfWeek"]; + if (defaultDayStartTime == -1) + { + defaultDayStartTime + = _timeValue ([ud stringForKey: @"SOGoDayStartTime"]); + if (defaultDayStartTime == -1) + defaultDayStartTime = 8; + } + if (defaultDayEndTime == -1) + { + defaultDayEndTime + = _timeValue ([ud stringForKey: @"SOGoDayEndTime"]); + if (defaultDayEndTime == -1) + defaultDayEndTime = 18; + } + if (!AgenorProfileURL) { profileURL = [ud stringForKey: @"AgenorProfileURL"]; @@ -105,7 +139,6 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; @" value set to 'localhost'"]; fallbackIMAP4Server = @"localhost"; } - if (!defaultLanguage) { ASSIGN (defaultLanguage, [ud stringForKey: @"SOGoDefaultLanguage"]); @@ -451,6 +484,124 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; return serverTimeZone; } +- (unsigned int) firstDayOfWeek +{ + unsigned int firstDayOfWeek; + NSNumber *value; + + value = [[self userDefaults] objectForKey: @"WeekStartDay"]; + if (value) + firstDayOfWeek = [value unsignedIntValue]; + else + firstDayOfWeek = sogoFirstDayOfWeek; + + return firstDayOfWeek; +} + +- (NSCalendarDate *) firstDayOfWeekForDate: (NSCalendarDate *) date +{ + int offset; + NSCalendarDate *firstDay; + + offset = ([self firstDayOfWeek] - [date dayOfWeek]); + if (offset > 0) + offset -= 7; + + firstDay = [date addTimeInterval: offset * 86400]; + + return firstDay; +} + +- (unsigned int) dayOfWeekForDate: (NSCalendarDate *) date +{ + unsigned int offset, baseDayOfWeek, dayOfWeek; + + offset = [self firstDayOfWeek]; + baseDayOfWeek = [date dayOfWeek]; + if (offset > baseDayOfWeek) + baseDayOfWeek += 7; + + dayOfWeek = baseDayOfWeek - offset; + + return dayOfWeek; +} + +- (unsigned int) dayStartHour +{ + int limit; + + limit = _timeValue ([[self userDefaults] stringForKey: @"DayStartTime"]); + if (limit == -1) + limit = defaultDayStartTime; + + return limit; +} + +- (unsigned int) dayEndHour +{ + int limit; + + limit = _timeValue ([[self userDefaults] stringForKey: @"DayEndTime"]); + if (limit == -1) + limit = defaultDayEndTime; + + return limit; +} + +- (NSCalendarDate *) firstWeekOfYearForDate: (NSCalendarDate *) date +{ + NSString *firstWeekRule; + NSCalendarDate *januaryFirst, *firstWeek; + unsigned int dayOfWeek; + + firstWeekRule = [userDefaults objectForKey: @"FirstWeek"]; + + januaryFirst = [NSCalendarDate dateWithYear: [date yearOfCommonEra] + month: 1 day: 1 hour: 0 minute: 0 second: 0 + timeZone: [date timeZone]]; + if ([firstWeekRule isEqualToString: SOGoWeekStartFirst4DayWeek]) + { + dayOfWeek = [self dayOfWeekForDate: januaryFirst]; + if (dayOfWeek < 4) + firstWeek = [self firstDayOfWeekForDate: januaryFirst]; + else + firstWeek = [self firstDayOfWeekForDate: [januaryFirst + dateByAddingYears: 0 + months: 0 + days: 7]]; + } + else if ([firstWeekRule isEqualToString: SOGoWeekStartFirstFullWeek]) + { + dayOfWeek = [self dayOfWeekForDate: januaryFirst]; + if (dayOfWeek == 0) + firstWeek = [self firstDayOfWeekForDate: januaryFirst]; + else + firstWeek = [self firstDayOfWeekForDate: [januaryFirst + dateByAddingYears: 0 + months: 0 + days: 7]]; + } + else + firstWeek = [self firstDayOfWeekForDate: januaryFirst]; + + return firstWeek; +} + +- (unsigned int) weekNumberForDate: (NSCalendarDate *) date +{ + NSCalendarDate *firstWeek; + unsigned int weekNumber; + + firstWeek = [self firstWeekOfYearForDate: date]; + if ([firstWeek earlierDate: date] == firstWeek) + weekNumber = ([date timeIntervalSinceDate: firstWeek] + / (86400 * 7) + 1); + else + weekNumber = 0; + + return weekNumber; +} + /* mail */ - (void) _prepareDefaultMailAccounts { diff --git a/UI/PreferencesUI/Dutch.lproj/Localizable.strings b/UI/PreferencesUI/Dutch.lproj/Localizable.strings index a1a72ac85..4ecf884bf 100644 --- a/UI/PreferencesUI/Dutch.lproj/Localizable.strings +++ b/UI/PreferencesUI/Dutch.lproj/Localizable.strings @@ -47,7 +47,6 @@ "Play a sound when a reminder comes due" = "Geluidafspelen bij herinnering"; "Default reminder :" = "Standaard herinnering:"; -"firstWeekOfYear_HideWeekNumbers" = "Weeknummers verbergen"; "firstWeekOfYear_January1" = "Begint op 1 januari"; "firstWeekOfYear_First4DayWeek" = "Eerste week met 4 dagen"; "firstWeekOfYear_FirstFullWeek" = "Eerste volledige week"; @@ -82,6 +81,7 @@ "Default identity:" = "Standaardidentiteit:"; "Manage identities..." = "Identiteiten beheren..."; +"Signature" = "Signature"; /* password */ "New password:" = "Nieuw wachtwoord:"; diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index 58b42bb03..17f07d788 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -50,7 +50,6 @@ = "Play a sound when a reminder comes due"; "Default reminder :" = "Default reminder :"; -"firstWeekOfYear_HideWeekNumbers" = "Do not display week numbers"; "firstWeekOfYear_January1" = "Starts on january 1"; "firstWeekOfYear_First4DayWeek" = "First 4-day week"; "firstWeekOfYear_FirstFullWeek" = "First full week"; @@ -85,7 +84,7 @@ "Default identity:" = "Default identity:"; "Manage identities..." = "Manage identities..."; -"Signature:" = "Signature:"; +"Signature" = "Signature"; /* password */ "New password:" = "New password:"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index 685021029..1d50be6e5 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -47,7 +47,6 @@ "Play a sound when a reminder comes due" = "Émettre un signal sonore à l'échéance du rappel"; "Default reminder :" = "Rappel par défaut :"; -"firstWeekOfYear_HideWeekNumbers" = "Ne pas afficher le numéro des semaines"; "firstWeekOfYear_January1" = "Commence le 1er janvier"; "firstWeekOfYear_First4DayWeek" = "Première semaine de 4 jours"; "firstWeekOfYear_FirstFullWeek" = "Première semaine entière"; @@ -83,7 +82,7 @@ /* Identities */ "Default identity:" = "Identité par défaut :"; "Manage identities..." = "Gérer les identitiés..."; -"Signature:" = "Signature :"; +"Signature" = "Signature"; /* password */ "New password:" = "Nouveau mot de passe :"; diff --git a/UI/PreferencesUI/German.lproj/Localizable.strings b/UI/PreferencesUI/German.lproj/Localizable.strings index 6fa6c2bd9..b7598c625 100644 --- a/UI/PreferencesUI/German.lproj/Localizable.strings +++ b/UI/PreferencesUI/German.lproj/Localizable.strings @@ -47,7 +47,6 @@ "Play a sound when a reminder comes due" = "Akustisches Signal zur Terminerinnerung"; "Default reminder :" = "Standard Terminerinnerung:"; -"firstWeekOfYear_HideWeekNumbers" = "Keine Wochennummern anzeigen"; "firstWeekOfYear_January1" = "Beginnt am 1.Januar"; "firstWeekOfYear_First4DayWeek" = "Erste 4 Tage Woche"; "firstWeekOfYear_FirstFullWeek" = "Erste ganze Woche"; @@ -82,7 +81,7 @@ "Default identity:" = "Standard Identität:"; "Manage identities..." = "Identitäten verwalten..."; -"Signature:" = "Unterschrift:"; +"Signature" = "Unterschrift"; /* password */ "New password:" = "Neues Passwort:"; diff --git a/UI/PreferencesUI/Italian.lproj/Localizable.strings b/UI/PreferencesUI/Italian.lproj/Localizable.strings index d2cc3ab1f..9e290c8e4 100644 --- a/UI/PreferencesUI/Italian.lproj/Localizable.strings +++ b/UI/PreferencesUI/Italian.lproj/Localizable.strings @@ -48,7 +48,6 @@ "Play a sound when a reminder comes due" = "Riproduci un suono quando un promemoria è attivo"; "Default reminder :" = "Promemoria predefinito:"; -"firstWeekOfYear_HideWeekNumbers" = "Non visualizzare i numeri della settimana"; "firstWeekOfYear_January1" = "Inizia l'1 gennaio"; "firstWeekOfYear_First4DayWeek" = "Prima settimana di 4 giorni"; "firstWeekOfYear_FirstFullWeek" = "Prima settimana completa"; @@ -83,7 +82,7 @@ "Default identity:" = "Identità principale:"; "Manage identities..." = "Gestisci identità..."; -"Signature:" = "Firma:"; +"Signature" = "Firma"; /* password */ "New password:" = "Nuova password:"; diff --git a/UI/PreferencesUI/Spanish.lproj/Localizable.strings b/UI/PreferencesUI/Spanish.lproj/Localizable.strings index be4bed6a0..ad11fc7f4 100644 --- a/UI/PreferencesUI/Spanish.lproj/Localizable.strings +++ b/UI/PreferencesUI/Spanish.lproj/Localizable.strings @@ -59,7 +59,6 @@ = "Señal acústica para los recordatorios"; "Default reminder :" = "Recordatorio por omisión: "; -"firstWeekOfYear_HideWeekNumbers" = "No mostrar número de semana"; "firstWeekOfYear_January1" = "Empieza el 1 de enero"; "firstWeekOfYear_First4DayWeek" = "Primera semana de 4 días"; "firstWeekOfYear_FirstFullWeek" = "Primera semana completa"; @@ -94,11 +93,9 @@ "Default identity:" = "Identidad por defecto:"; "Manage identities..." = "Gestionar identidades..."; -"Signature:" = "Firma:"; +"Signature" = "Firma"; /* password */ "New password:" = "Contraseña nueva:"; "Confirmation:" = "Confirmar contraseña nueva:"; /* ??? */ "Change" = "Cambiar"; - -"Signature" = "Firma"; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 37af5acb6..f0a0ff120 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -347,10 +347,11 @@ static BOOL shouldDisplayPasswordChange = NO; - (NSArray *) firstWeekList { - return [NSArray arrayWithObjects: SOGoWeekStartHideWeekNumbers, - SOGoWeekStartJanuary1, + return [NSArray arrayWithObjects: + SOGoWeekStartJanuary1, SOGoWeekStartFirst4DayWeek, - SOGoWeekStartFirstFullWeek, nil]; + SOGoWeekStartFirstFullWeek, + nil]; } - (NSString *) itemFirstWeekText diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index ec2dd99ef..205df2a56 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -137,7 +137,9 @@ { NSCalendarDate *newStartDate, *now; NSTimeZone *timeZone; + SOGoUser *user; int hour; + unsigned int uStart, uEnd; newStartDate = [self selectedDate]; if (![[self queryParameterForKey: @"hm"] length]) @@ -145,18 +147,22 @@ now = [NSCalendarDate calendarDate]; timeZone = [[context activeUser] timeZone]; [now setTimeZone: timeZone]; + + user = [context activeUser]; + uStart = [user dayStartHour]; if ([now isDateOnSameDay: newStartDate]) { + uEnd = [user dayEndHour]; hour = [now hourOfDay]; - if (hour < 8) - newStartDate = [now hour: 8 minute: 0]; - else if (hour > 18) - newStartDate = [[now tomorrow] hour: 8 minute: 0]; + if (hour < uStart) + newStartDate = [now hour: uStart minute: 0]; + else if (hour > uEnd) + newStartDate = [[now tomorrow] hour: uStart minute: 0]; else newStartDate = now; } else - newStartDate = [newStartDate hour: 8 minute: 0]; + newStartDate = [newStartDate hour: uStart minute: 0]; } return newStartDate; diff --git a/UI/Scheduler/UIxAttendeesEditor.m b/UI/Scheduler/UIxAttendeesEditor.m index b8b0c0ebc..05178c26b 100644 --- a/UI/Scheduler/UIxAttendeesEditor.m +++ b/UI/Scheduler/UIxAttendeesEditor.m @@ -23,6 +23,7 @@ #import #import +#import #import #import "UIxAttendeesEditor.h" @@ -76,4 +77,14 @@ return [self labelForKey: [NSString stringWithFormat: @"zoom_%@", item]]; } +- (unsigned int) dayStartHour +{ + return [[context activeUser] dayStartHour]; +} + +- (unsigned int) dayEndHour +{ + return [[context activeUser] dayEndHour]; +} + @end diff --git a/UI/Scheduler/UIxCalDateSelector.m b/UI/Scheduler/UIxCalDateSelector.m index 0541b600b..2f69a291e 100644 --- a/UI/Scheduler/UIxCalDateSelector.m +++ b/UI/Scheduler/UIxCalDateSelector.m @@ -93,6 +93,11 @@ return [[self selectedDate] firstDayOfMonth]; } +- (unsigned int) firstDayOfWeek +{ + return [[context activeUser] firstDayOfWeek]; +} + /* labels */ - (NSString *) headerMonthValue diff --git a/UI/Scheduler/UIxCalDayTable.h b/UI/Scheduler/UIxCalDayTable.h index cc5598e45..0af884c11 100644 --- a/UI/Scheduler/UIxCalDayTable.h +++ b/UI/Scheduler/UIxCalDayTable.h @@ -28,12 +28,14 @@ @class NSArray; @class NSCalendarDay; @class NSDictionary; +@class NSNumber; @class NSString; + @class SOGoDateFormatter; @interface UIxCalDayTable : UIxCalView { - int numberOfDays; + unsigned int numberOfDays; NSCalendarDate *startDate; NSCalendarDate *currentTableDay; NSString *currentTableHour; @@ -43,8 +45,8 @@ SOGoDateFormatter *dateFormatter; } -- (void) setNumberOfDays: (NSString *) aNumber; -- (NSString *) numberOfDays; +- (void) setNumberOfDays: (NSNumber *) aNumber; +- (NSNumber *) numberOfDays; - (void) setStartDate: (NSCalendarDate *) aStartDate; - (NSCalendarDate *) startDate; diff --git a/UI/Scheduler/UIxCalDayTable.m b/UI/Scheduler/UIxCalDayTable.m index 3c5a35e6f..46479de95 100644 --- a/UI/Scheduler/UIxCalDayTable.m +++ b/UI/Scheduler/UIxCalDayTable.m @@ -26,6 +26,7 @@ #import #import #import +#import #import #import @@ -67,21 +68,21 @@ [super dealloc]; } -- (void) setNumberOfDays: (NSString *) aNumber +- (void) setNumberOfDays: (NSNumber *) aNumber { numberOfDays = [aNumber intValue]; [daysToDisplay release]; daysToDisplay = nil; } -- (NSString *) numberOfDays +- (NSNumber *) numberOfDays { - return [NSString stringWithFormat: @"%d", numberOfDays]; + return [NSNumber numberWithUnsignedInt: numberOfDays]; } - (void) setStartDate: (NSCalendarDate *) aStartDate { - startDate = aStartDate; + startDate = [aStartDate beginOfDay]; [daysToDisplay release]; daysToDisplay = nil; } @@ -89,9 +90,9 @@ - (NSCalendarDate *) startDate { if (!startDate) - startDate = [super startDate]; + startDate = [[super startDate] beginOfDay]; - return [startDate beginOfDay]; + return startDate; } - (NSCalendarDate *) endDate @@ -111,23 +112,25 @@ if (!hoursToDisplay) { + hoursToDisplay = [NSMutableArray new]; currentHour = [self dayStartHour]; lastHour = [self dayEndHour]; - hoursToDisplay = [NSMutableArray new]; - while (currentHour < lastHour) { - [hoursToDisplay - addObject: [NSString stringWithFormat: @"%d", currentHour]]; + [hoursToDisplay addObject: [NSNumber numberWithInt: currentHour]]; currentHour++; } - [hoursToDisplay - addObject: [NSString stringWithFormat: @"%d", currentHour]]; + [hoursToDisplay addObject: [NSNumber numberWithInt: currentHour]]; } return hoursToDisplay; } +- (NSString *) currentHourLineClass +{ + return [NSString stringWithFormat: @"hourLine hourLine%d", [currentTableHour intValue]]; +} + - (NSArray *) daysToDisplay { NSCalendarDate *currentDate; @@ -138,12 +141,11 @@ daysToDisplay = [NSMutableArray new]; currentDate = [[self startDate] hour: [self dayStartHour] minute: 0]; - [daysToDisplay addObject: currentDate]; - for (count = 1; count < numberOfDays; count++) - [daysToDisplay addObject: [currentDate dateByAddingYears: 0 - months: 0 - days: count]]; - + for (count = 0; count < numberOfDays; count++) + { + [daysToDisplay addObject: currentDate]; + currentDate = [currentDate tomorrow]; + } } return daysToDisplay; @@ -282,15 +284,17 @@ - (NSString *) dayClasses { NSMutableString *classes; - int dayOfWeek; + unsigned int currentDayNbr, realDayOfWeek; + + currentDayNbr = ([currentTableDay timeIntervalSinceDate: [self startDate]] + / 86400); + realDayOfWeek = [currentTableDay dayOfWeek]; - classes = [NSMutableString new]; - [classes autorelease]; - [classes appendFormat: @"day day%d", [currentTableDay dayOfWeek]]; + classes = [NSMutableString string]; + [classes appendFormat: @"day day%d", currentDayNbr]; if (numberOfDays > 1) { - dayOfWeek = [currentTableDay dayOfWeek]; - if (dayOfWeek == 0 || dayOfWeek == 6) + if (realDayOfWeek == 0 || realDayOfWeek == 6) [classes appendString: @" weekEndDay"]; if ([currentTableDay isToday]) [classes appendString: @" dayOfToday"]; @@ -303,7 +307,19 @@ - (NSString *) clickableHourCellClass { - return [NSString stringWithFormat: @"clickableHourCell clickableHourCell%@", currentTableHour]; + NSMutableString *cellClass; + int hour; + SOGoUser *user; + + cellClass = [NSMutableString string]; + hour = [currentTableHour intValue]; + user = [context activeUser]; + [cellClass appendFormat: @"clickableHourCell clickableHourCell%d", hour]; + if (hour < [user dayStartHour] + || hour > [user dayEndHour]) + [cellClass appendString: @" outOfDay"]; + + return cellClass; } @end diff --git a/UI/Scheduler/UIxCalMainView.m b/UI/Scheduler/UIxCalMainView.m index 1ffa77a92..c8ed1dbc5 100644 --- a/UI/Scheduler/UIxCalMainView.m +++ b/UI/Scheduler/UIxCalMainView.m @@ -172,4 +172,9 @@ static NSMutableArray *yearMenuItems = nil; return [self responseWithStatus: 204]; } +- (unsigned int) firstDayOfWeek +{ + return [[context activeUser] firstDayOfWeek]; +} + @end diff --git a/UI/Scheduler/UIxCalMonthView.m b/UI/Scheduler/UIxCalMonthView.m index bcfb7d10d..1872340a1 100644 --- a/UI/Scheduler/UIxCalMonthView.m +++ b/UI/Scheduler/UIxCalMonthView.m @@ -29,6 +29,7 @@ #import #import +#import #import "UIxCalMonthView.h" @@ -75,7 +76,8 @@ NSCalendarDate *currentDate; headerDaysToDisplay = [NSMutableArray arrayWithCapacity: 7]; - currentDate = [[self selectedDate] mondayOfWeek]; + currentDate + = [[context activeUser] firstDayOfWeekForDate: [self selectedDate]]; for (counter = 0; counter < 7; counter++) { [headerDaysToDisplay addObject: currentDate]; @@ -95,7 +97,9 @@ if (!weeksToDisplay) { selectedDate = [self selectedDate]; - firstOfAllDays = [[selectedDate firstDayOfMonth] mondayOfWeek]; + firstOfAllDays + = [[context activeUser] firstDayOfWeekForDate: + [selectedDate firstDayOfMonth]]; lastDayOfMonth = [selectedDate lastDayOfMonth]; firstToLast = ([lastDayOfMonth timeIntervalSinceDate: firstOfAllDays] / 86400); @@ -127,10 +131,11 @@ - (NSDictionary *) _dateQueryParametersWithOffset: (int) monthsOffset { - NSCalendarDate *date; + NSCalendarDate *date, *firstDay; - date = [[self selectedDate] dateByAddingYears: 0 months: monthsOffset - days: 0 hours: 0 minutes: 0 seconds: 0]; + firstDay = [[self selectedDate] firstDayOfMonth]; + date = [firstDay dateByAddingYears: 0 months: monthsOffset + days: 0 hours: 0 minutes: 0 seconds: 0]; return [self queryParametersBySettingSelectedDate: date]; } @@ -233,8 +238,11 @@ - (NSString *) headerDayCellClasses { - return [NSString stringWithFormat: @"headerDay day%d", - [currentTableDay dayOfWeek]]; + unsigned int dayOfWeek; + + dayOfWeek = [[context activeUser] dayOfWeekForDate: currentTableDay]; + + return [NSString stringWithFormat: @"headerDay day%d", dayOfWeek]; } - (NSString *) dayHeaderNumber @@ -261,18 +269,19 @@ { NSMutableString *classes; NSCalendarDate *selectedDate; - int dayOfWeek, numberOfWeeks; + unsigned int realDayOfWeek, dayOfWeek, numberOfWeeks; classes = [NSMutableString string]; - dayOfWeek = [currentTableDay dayOfWeek]; + dayOfWeek = [[context activeUser] dayOfWeekForDate: currentTableDay]; + realDayOfWeek = [currentTableDay dayOfWeek]; numberOfWeeks = [weeksToDisplay count]; [classes appendFormat: @"day weekOf%d week%dof%d day%d", numberOfWeeks, [weeksToDisplay indexOfObject: currentWeek], numberOfWeeks, dayOfWeek]; - if (dayOfWeek == 0 || dayOfWeek == 6) + if (realDayOfWeek == 0 || realDayOfWeek == 6) [classes appendString: @" weekEndDay"]; selectedDate = [self selectedDate]; if (![[currentTableDay firstDayOfMonth] @@ -292,16 +301,17 @@ firstDayOfMonth = [[self selectedDate] firstDayOfMonth]; - return [firstDayOfMonth mondayOfWeek]; + return [[context activeUser] firstDayOfWeekForDate: firstDayOfMonth]; } - (NSCalendarDate *) endDate { - NSCalendarDate *lastDayOfMonth; + NSCalendarDate *lastDayOfMonth, *firstDay; lastDayOfMonth = [[self selectedDate] lastDayOfMonth]; + firstDay = [[context activeUser] firstDayOfWeekForDate: lastDayOfMonth]; - return [[lastDayOfMonth mondayOfWeek] dateByAddingYears: 0 months: 0 days: 6]; + return [firstDay dateByAddingYears: 0 months: 0 days: 6]; } @end diff --git a/UI/Scheduler/UIxCalWeekView.m b/UI/Scheduler/UIxCalWeekView.m index ff06cc7b9..b87aeab2b 100644 --- a/UI/Scheduler/UIxCalWeekView.m +++ b/UI/Scheduler/UIxCalWeekView.m @@ -25,9 +25,11 @@ #import #import +#import + #import -#import +#import #include "UIxCalWeekView.h" @@ -35,14 +37,18 @@ - (NSCalendarDate *) startDate { - return [[[super startDate] mondayOfWeek] beginOfDay]; + NSCalendarDate *date; + + date = [[context activeUser] firstDayOfWeekForDate: [super startDate]]; + + return [date beginOfDay]; } - (NSCalendarDate *) endDate { unsigned offset; - if([self shouldDisplayWeekend]) + if ([self shouldDisplayWeekend]) offset = 7; else offset = 5; @@ -83,12 +89,17 @@ { NSCalendarDate *date; NSString *format; + unsigned int weekNbr; + SOGoUser *user; - date = [[self startDate] dateByAddingYears: 0 months: 0 days: (offset * 7) - hours:0 minutes: 0 seconds: 0]; + user = [context activeUser]; + date = [[self startDate] dateByAddingYears: 0 months: 0 + days: (offset * 7) + 6 + hours: 0 minutes: 0 seconds: 0]; + weekNbr = [user weekNumberForDate: date]; format = [self labelForKey: @"Week %d"]; - return [NSString stringWithFormat: format, [date weekOfYear]]; + return [NSString stringWithFormat: format, weekNbr]; } - (NSString *) weekBeforeLastWeekName diff --git a/UI/Scheduler/UIxTaskEditor.m b/UI/Scheduler/UIxTaskEditor.m index df27bf130..693223d30 100644 --- a/UI/Scheduler/UIxTaskEditor.m +++ b/UI/Scheduler/UIxTaskEditor.m @@ -215,28 +215,33 @@ - (NSCalendarDate *) newStartDate { NSCalendarDate *newStartDate, *now; - int hour; NSTimeZone *timeZone; - - timeZone = [[context activeUser] timeZone]; + SOGoUser *user; + int hour; + unsigned int uStart, uEnd; newStartDate = [self selectedDate]; - if ([[self queryParameterForKey: @"hm"] length] == 0) + if (![[self queryParameterForKey: @"hm"] length]) { now = [NSCalendarDate calendarDate]; + timeZone = [[context activeUser] timeZone]; [now setTimeZone: timeZone]; + + user = [context activeUser]; + uStart = [user dayStartHour]; if ([now isDateOnSameDay: newStartDate]) { + uEnd = [user dayEndHour]; hour = [now hourOfDay]; - if (hour < 8) - newStartDate = [now hour: 8 minute: 0]; - else if (hour > 18) - newStartDate = [[now tomorrow] hour: 8 minute: 0]; + if (hour < uStart) + newStartDate = [now hour: uStart minute: 0]; + else if (hour > uEnd) + newStartDate = [[now tomorrow] hour: uStart minute: 0]; else newStartDate = now; } else - newStartDate = [newStartDate hour: 8 minute: 0]; + newStartDate = [newStartDate hour: uStart minute: 0]; } return newStartDate; diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index fde540e73..b2d5de094 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -23,7 +23,7 @@
  • + label:value="Signature"/>
  • @@ -67,18 +67,18 @@
    -
    -
    -
    - + + + + + + + + + + + +
    @@ -108,7 +108,6 @@ list="identitiesList" displayString="itemIdentityText">
    --> -