Allow user to choose which weekdays to display

Closes #1841
This commit is contained in:
Francis Lachapelle
2016-05-06 14:22:52 -04:00
parent 3c6da09ff8
commit c5eeadf041
29 changed files with 393 additions and 146 deletions
+1
View File
@@ -42,6 +42,7 @@
NSMutableArray *daysToDisplay, *calendarsToDisplay, *hoursToDisplay;
NSMutableDictionary *currentCalendar;
unsigned int numberOfDays;
unsigned int *daysNumbersToDisplay;
}
- (void) setNumberOfDays: (NSNumber *) aNumber;
+38 -26
View File
@@ -1,8 +1,6 @@
/* UIxCalDayTable.m - this file is part of SOGo
*
* Copyright (C) 2006-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Copyright (C) 2006-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +24,8 @@
#import <NGExtensions/NSCalendarDate+misc.h>
#import <SOPE/NGCards/iCalRecurrenceRule.h>
#import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/SOGoDateFormatter.h>
#import <SOGo/SOGoUser.h>
@@ -61,7 +61,7 @@
currentCalendar = nil;
currentTableDay = nil;
currentTableHour = nil;
weekDays = [locale objectForKey: NSShortWeekDayNameArray];
weekDays = [locale objectForKey: NSWeekDayNameArray];
[weekDays retain];
dateFormatter = [user dateFormatterInContext: context];
[dateFormatter retain];
@@ -81,6 +81,7 @@
[hoursToDisplay release];
[dateFormatter release];
[timeFormat release];
free(daysNumbersToDisplay);
[super dealloc];
}
@@ -135,7 +136,7 @@
- (NSArray *) hoursToDisplay
{
unsigned int currentHour, lastHour;
if (!hoursToDisplay)
{
hoursToDisplay = [NSMutableArray new];
@@ -157,24 +158,36 @@
return [NSString stringWithFormat: @"hour%d", [currentTableHour intValue]];
}
/**
* Return an array of NSCalendarDate instances matching the requested time period
* and the week days enabled in the user's defaults.
*/
- (NSArray *) daysToDisplay
{
NSCalendarDate *currentDate;
int count;
NSString *weekDay;
int count, enabledCount;
if (!daysToDisplay)
{
daysToDisplay = [NSMutableArray new];
daysNumbersToDisplay = malloc (numberOfDays * sizeof (unsigned int));
currentDate = [[self startDate] hour: [self dayStartHour]
minute: 0];
for (count = 0; count < numberOfDays; count++)
for (count = 0, enabledCount = 0; count < numberOfDays; count++)
{
[daysToDisplay addObject: currentDate];
weekDay = iCalWeekDayString[[currentDate dayOfWeek]];
if ([enabledWeekDays count] == 0 || [enabledWeekDays containsObject: weekDay])
{
[daysToDisplay addObject: currentDate];
daysNumbersToDisplay[enabledCount] = count;
enabledCount++;
}
currentDate = [currentDate tomorrow];
}
}
return daysToDisplay;
}
@@ -218,7 +231,7 @@
}
}
}
return calendarsToDisplay;
}
@@ -276,7 +289,9 @@
- (int) currentDayNumber
{
return [daysToDisplay indexOfObject: currentTableDay];
int i = [daysToDisplay indexOfObject: currentTableDay];
return daysNumbersToDisplay[i];
}
- (NSNumber *) currentAppointmentHour
@@ -354,7 +369,7 @@
// {
// newMutableAppointment
// = [NSMutableDictionary dictionaryWithDictionary: anAppointment];
// if (startIsEarlier)
// [newMutableAppointment setObject: start
// forKey: @"startDate"];
@@ -430,13 +445,13 @@
// - (NSString *) daysViewClasses
// {
// NSString *daysView;
// if ([currentView isEqualToString:@"multicolumndayview"])
// daysView = @"daysView daysViewForMultipleDays";
// else
// daysView = [NSString stringWithFormat: @"daysView daysViewFor%dDays", numberOfDays];
// return daysView;
//}
@@ -448,14 +463,11 @@
- (NSString *) dayClasses
{
NSMutableString *classes;
unsigned int currentDayNbr, realDayOfWeek;
classes = [NSMutableString string];
currentDayNbr = [daysToDisplay indexOfObject: currentTableDay];
unsigned int realDayOfWeek;
classes = [NSMutableString stringWithString: @"day"];
realDayOfWeek = [currentTableDay dayOfWeek];
[classes appendFormat: @"day day%d", currentDayNbr];
if (numberOfDays > 1)
{
if (realDayOfWeek == 0 || realDayOfWeek == 6)
@@ -463,7 +475,7 @@
if ([currentTableDay isToday])
[classes appendString: @" dayOfToday"];
}
return classes;
}
@@ -487,7 +499,7 @@
{
if ([currentView isEqualToString:@"multicolumndayview"])
return YES;
return NO;
}
@@ -495,7 +507,7 @@
{
if ([currentView isEqualToString:@"dayview"] || [currentView isEqualToString:@"weekview"])
return YES;
return NO;
}
+17 -20
View File
@@ -1,30 +1,27 @@
/*
Copyright (C) 2004 SKYRIX Software AG
Copyright (C) 2006-2016 Inverse inc.
This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
SOGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
License along with SOGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#import <Foundation/NSDictionary.h>
#import <NGExtensions/NSCalendarDate+misc.h>
#import "UIxCalDayView.h"
// @interface UIxCalDayView (PrivateAPI)
@@ -66,7 +63,7 @@
// {
// NSCalendarDate *dateStart, *dateEnd, *aptStart, *aptEnd;
// NGCalendarDateRange *dateRange, *aptRange;
// dateStart = self->currentDate;
// dateEnd = [dateStart dateByAddingYears:0 months:0 days:0
// hours:1 minutes:0 seconds:0];
@@ -104,7 +101,7 @@
// if ([d isDateOnSameDay:max])
// max = (NSCalendarDate *)[d laterDate:max];
// }
// return [self _getDatesFrom:min to:max];
// }
@@ -119,7 +116,7 @@
// dates = [[NSMutableArray alloc] initWithCapacity:count];
// for(i = 0; i < count; i++) {
// NSCalendarDate *date;
// date = [_from hour:offset + i minute:0];
// [dates addObject:date];
// }
@@ -135,12 +132,12 @@
- (NSDictionary *) prevDayQueryParameters
{
return [self _dateQueryParametersWithOffset: -1];
return [self _dateQueryParametersWithOffset: [self _nextValidOffset: -1]];
}
- (NSDictionary *) nextDayQueryParameters
{
return [self _dateQueryParametersWithOffset: 1];
return [self _dateQueryParametersWithOffset: [self _nextValidOffset: +1]];
}
- (NSDictionary *) dayAfterNextDayQueryParameters
@@ -153,7 +150,7 @@
NSMutableDictionary *qp;
NSString *hmString;
NSCalendarDate *date;
date = [self selectedDate];
hmString = [NSString stringWithFormat:@"%.2d%.2d",
(int)[date hourOfDay], (int)[date minuteOfHour]];
@@ -177,7 +174,7 @@
// NSArray *apts;
// NSMutableArray *filtered;
// unsigned i, count;
// if (self->allDayApts)
// return self->allDayApts;
@@ -188,7 +185,7 @@
// for (i = 0; i < count; i++) {
// id apt;
// NSNumber *bv;
// apt = [apts objectAtIndex:i];
// bv = [apt valueForKey:@"isallday"];
// if ([bv boolValue]) {
@@ -203,7 +200,7 @@
// }
// }
// }
// ASSIGN(self->allDayApts, filtered);
// [filtered release];
// return self->allDayApts;
@@ -219,8 +216,8 @@
NSCalendarDate *date;
date = [[self selectedDate] dateByAddingYears: 0
months: 0
days: offset];
months: 0
days: offset];
return [self localizedNameForDayOfWeek: [date dayOfWeek]];
}
@@ -232,7 +229,7 @@
- (NSString *) yesterdayName
{
return [self _dayNameWithOffsetFromToday: -1];
return [self _dayNameWithOffsetFromToday: [self _nextValidOffset: -1]];
}
- (NSString *) currentDayName
@@ -242,7 +239,7 @@
- (NSString *) tomorrowName
{
return [self _dayNameWithOffsetFromToday: 1];
return [self _dayNameWithOffsetFromToday: [self _nextValidOffset: +1]];
}
- (NSString *) dayAfterTomorrowName
+1
View File
@@ -35,6 +35,7 @@
@interface UIxCalListingActions : SOGoDirectAction
{
NSArray *enabledWeekDays;
NSMutableDictionary *componentsData;
NSCalendarDate *startDate;
NSCalendarDate *endDate;
+72 -12
View File
@@ -35,6 +35,8 @@
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
#import <SOPE/NGCards/iCalRecurrenceRule.h>
#import <SOGo/SOGoDateFormatter.h>
#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoUser.h>
@@ -114,6 +116,7 @@ static NSArray *tasksFields = nil;
ASSIGN (userTimeZone, [[user userDefaults] timeZone]);
dayBasedView = NO;
currentView = nil;
ASSIGN (enabledWeekDays, [[user userDefaults] calendarWeekdays]);
}
return self;
@@ -125,6 +128,7 @@ static NSArray *tasksFields = nil;
[request release];
[componentsData release];
[userTimeZone release];
[enabledWeekDays release];
[super dealloc];
}
@@ -350,7 +354,7 @@ static NSArray *tasksFields = nil;
NSMutableDictionary *newInfo;
NSMutableArray *infos, *quickInfos, *allInfos, *quickInfosName;
NSNull *marker;
NSString *owner, *role, *calendarName, *iCalString, *recurrenceTime, *categories;
NSString *owner, *role, *calendarName, *iCalString, *recurrenceTime, *categories, *weekDay;
NSRange match;
iCalCalendar *calendar;
iCalEntityObject *master;
@@ -451,6 +455,11 @@ static NSArray *tasksFields = nil;
while ((newInfo = [currentInfos nextObject]))
{
// Skip components that appear on disabled weekdays
weekDay = iCalWeekDayString[[[newInfo objectForKey: @"startDate"] dayOfWeek]];
if ([enabledWeekDays count] && ![enabledWeekDays containsObject: weekDay])
continue;
if ([fields containsObject: @"viewable"])
{
if ([owner isEqualToString: userLogin])
@@ -770,26 +779,35 @@ static NSArray *tasksFields = nil;
*/
- (WOResponse *) eventsListAction
{
BOOL isAllDay;
NSArray *oldEvent;
NSCalendarDate *date;
NSDictionary *data;
NSEnumerator *events;
NSMutableArray *fields, *newEvents, *newEvent;
NSString *sort, *ascending, *weekDay;
unsigned int interval;
BOOL isAllDay;
NSString *sort, *ascending;
[self _setupContext];
[self saveFilterValue: @"EventsFilterState"];
[self saveSortValue: @"EventsSortingState"];
newEvents = [NSMutableArray array];
events = [[self _fetchFields: eventsFields
forComponentOfType: @"vevent"] objectEnumerator];
while ((oldEvent = [events nextObject]))
{
interval = [[oldEvent objectAtIndex: eventStartDateIndex] intValue];
date = [NSCalendarDate dateWithTimeIntervalSince1970: interval];
[date setTimeZone: userTimeZone];
// Skip components that appear on disabled weekdays
weekDay = iCalWeekDayString[[date dayOfWeek]];
if ([enabledWeekDays count] && ![enabledWeekDays containsObject: weekDay])
continue;
newEvent = [NSMutableArray arrayWithArray: oldEvent];
isAllDay = [[oldEvent objectAtIndex: eventIsAllDayIndex] boolValue];
interval = [[oldEvent objectAtIndex: eventStartDateIndex] intValue];
[newEvent addObject: [self _formattedDateForSeconds: interval
forAllDay: isAllDay]];
interval = [[oldEvent objectAtIndex: eventEndDateIndex] intValue];
@@ -967,8 +985,7 @@ static inline NSString* _userStateInEvent (NSArray *event)
offset = 0;
}
else
offset = ((currentStart - startSecs)
/ dayLength);
offset = ((currentStart - startSecs) / dayLength);
if (offset >= [blocks count])
[self errorWithFormat: @"event '%@' has a computed offset that"
@" overflows the amount of blocks (skipped)",
@@ -1309,15 +1326,16 @@ _computeBlocksPosition (NSArray *blocks)
{
int count, max;
NSArray *events, *event, *calendars;
NSCalendarDate *currentDate;
NSDictionary *eventsBlocks, *calendar;
NSMutableArray *allDayBlocks, *blocks, *currentDay, *eventsForCalendar, *eventsByCalendars;
NSMutableArray *allDayBlocks, *blocks, *days, *currentDay, *eventsForCalendar, *eventsByCalendars;
NSNumber *eventNbr;
NSString *calendarName, *calendarId;
BOOL isAllDay;
int i, j;
[self _setupContext];
events = [self _fetchFields: eventsFields forComponentOfType: @"vevent"];
if ([currentView isEqualToString: @"multicolumndayview"])
@@ -1329,6 +1347,7 @@ _computeBlocksPosition (NSArray *blocks)
calendar = [calendars objectAtIndex:i];
calendarName = [calendar objectForKey: @"name"];
calendarId = [calendar objectForKey: @"id"];
days = [NSMutableArray array];
eventsForCalendar = [NSMutableArray array];
[self _prepareEventBlocks: &blocks withAllDays: &allDayBlocks];
for (j = 0; j < [events count]; j++) {
@@ -1343,7 +1362,8 @@ _computeBlocksPosition (NSArray *blocks)
eventsFields, @"eventsFields",
eventsForCalendar, @"events",
allDayBlocks, @"allDayBlocks",
blocks, @"blocks", nil];
blocks, @"blocks",
days, @"days", nil];
max = [eventsForCalendar count];
for (count = 0; count < max; count++)
{
@@ -1355,12 +1375,20 @@ _computeBlocksPosition (NSArray *blocks)
else
[self _fillBlocks: blocks withEvent: event withNumber: eventNbr];
}
currentDate = [[startDate copy] autorelease];
[currentDate setTimeZone: userTimeZone];
max = [blocks count];
for (count = 0; count < max; count++)
{
currentDay = [blocks objectAtIndex: count];
[currentDay sortUsingSelector: @selector (compareEventByStart:)];
[self _addBlocksWidth: currentDay];
[days addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[currentDate shortDateString], @"date",
[NSNumber numberWithInt: count], @"number", nil]];
currentDate = [currentDate addYear:0 month:0 day:1 hour:0 minute:0 second:0];
}
[eventsByCalendars addObject: eventsBlocks];
}
@@ -1368,12 +1396,14 @@ _computeBlocksPosition (NSArray *blocks)
}
else
{
days = [NSMutableArray array];
[self _prepareEventBlocks: &blocks withAllDays: &allDayBlocks];
eventsBlocks = [NSDictionary dictionaryWithObjectsAndKeys:
eventsFields, @"eventsFields",
events, @"events",
allDayBlocks, @"allDayBlocks",
blocks, @"blocks", nil];
blocks, @"blocks",
days, @"days", nil];
max = [events count];
for (count = 0; count < max; count++)
{
@@ -1390,14 +1420,44 @@ _computeBlocksPosition (NSArray *blocks)
else
[self _fillBlocks: blocks withEvent: event withNumber: eventNbr];
}
currentDate = [[startDate copy] autorelease];
[ setTimeZone: userTimeZone];
max = [blocks count];
for (count = 0; count < max; count++)
{
currentDay = [blocks objectAtIndex: count];
[currentDay sortUsingSelector: @selector (compareEventByStart:)];
[self _addBlocksWidth: currentDay];
[days addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[currentDate shortDateString], @"date",
[NSNumber numberWithInt: count], @"number", nil]];
currentDate = [currentDate addYear:0 month:0 day:1 hour:0 minute:0 second:0];
}
if ([enabledWeekDays count] > 0 && [enabledWeekDays count] < 7)
{
// Remove the days that are disabled in the user's defaults
int weekDay, weekDayCount;
weekDayCount= [currentDate dayOfWeek];
for (count = max - 1; count >= 0; count--)
{
weekDayCount--;
if (weekDayCount < 0)
weekDay = ((weekDayCount % 7) + 7) % 7;
else
weekDay = weekDayCount;
if (![enabledWeekDays containsObject: iCalWeekDayString[weekDay]])
{
[allDayBlocks removeObjectAtIndex: count];
[blocks removeObjectAtIndex: count];
[days removeObjectAtIndex: count];
}
}
}
return [self _responseWithData: [NSArray arrayWithObject: eventsBlocks]];
}
}
+3 -1
View File
@@ -1,6 +1,6 @@
/* UIxCalMonthView.h - this file is part of SOGo
*
* Copyright (C) 2006-2015 Inverse inc.
* Copyright (C) 2006-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,6 +44,8 @@
NSArray *dayNames;
NSArray *monthNames;
unsigned int *daysNumbersToDisplay;
}
- (NSDictionary *) monthBeforePrevMonthQueryParameters;
+36 -19
View File
@@ -1,6 +1,6 @@
/* UIxCalMonthView.m - this file is part of SOGo
*
* Copyright (C) 2006-2015 Inverse inc.
* Copyright (C) 2006-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,8 +23,11 @@
#import <NGExtensions/NSCalendarDate+misc.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SOPE/NGCards/iCalRecurrenceRule.h>
#import <SOGoUI/SOGoAptFormatter.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import "UIxCalMonthView.h"
@@ -59,6 +62,8 @@
[weeksToDisplay release];
[currentTableDay release];
[currentWeek release];
[enabledWeekDays release];
free(daysNumbersToDisplay);
[super dealloc];
}
@@ -71,16 +76,19 @@
- (NSArray *) headerDaysToDisplay
{
NSMutableArray *headerDaysToDisplay;
unsigned int counter;
NSCalendarDate *currentDate;
NSMutableArray *headerDaysToDisplay;
NSString *weekDay;
unsigned int counter;
headerDaysToDisplay = [NSMutableArray arrayWithCapacity: 7];
currentDate
= [[context activeUser] firstDayOfWeekForDate: [self selectedDate]];
currentDate = [[context activeUser] firstDayOfWeekForDate: [self selectedDate]];
for (counter = 0; counter < 7; counter++)
{
[headerDaysToDisplay addObject: currentDate];
// Skip days that match disabled weekdays in user's defaults
weekDay = iCalWeekDayString[[currentDate dayOfWeek]];
if ([enabledWeekDays count] == 0 || [enabledWeekDays containsObject: weekDay])
[headerDaysToDisplay addObject: currentDate];
currentDate = [currentDate tomorrow];
}
@@ -89,31 +97,37 @@
- (NSArray *) weeksToDisplay
{
NSMutableArray *week;
unsigned int counter, day;
NSCalendarDate *currentDate, *selectedDate, *lastDayOfMonth, *firstOfAllDays;
NSMutableArray *week;
NSString *weekDay;
unsigned int counter, day, enabledCounter;
unsigned int firstToLast, weeks;
if (!weeksToDisplay)
{
selectedDate = [self selectedDate];
firstOfAllDays
= [[context activeUser] firstDayOfWeekForDate:
[selectedDate firstDayOfMonth]];
firstOfAllDays = [[context activeUser] firstDayOfWeekForDate:
[selectedDate firstDayOfMonth]];
lastDayOfMonth = [selectedDate lastDayOfMonth];
firstToLast = ([lastDayOfMonth timeIntervalSinceDate: firstOfAllDays]
/ 86400) + 1;
firstToLast = ([lastDayOfMonth timeIntervalSinceDate: firstOfAllDays] / 86400) + 1;
weeks = firstToLast / 7;
if ((firstToLast % 7))
weeks++;
weeksToDisplay = [NSMutableArray arrayWithCapacity: weeks];
daysNumbersToDisplay = malloc (weeks * 7 * sizeof (unsigned int));
currentDate = firstOfAllDays;
for (counter = 0; counter < weeks; counter++)
for (counter = 0, enabledCounter = 0; counter < weeks; counter++)
{
week = [NSMutableArray arrayWithCapacity: 7];
for (day = 0; day < 7; day++)
{
[week addObject: currentDate];
weekDay = iCalWeekDayString[[currentDate dayOfWeek]];
if ([enabledWeekDays count] == 0 || [enabledWeekDays containsObject: weekDay])
{
[week addObject: currentDate];
daysNumbersToDisplay[enabledCounter] = (counter * 7) + day;
enabledCounter++;
}
currentDate = [currentDate tomorrow];
}
[weeksToDisplay addObject: week];
@@ -137,7 +151,7 @@
date = [firstDay dateByAddingYears: 0 months: monthsOffset
days: 0 hours: 0 minutes: 0 seconds: 0];
return [self queryParametersBySettingSelectedDate: date];
return [self queryParametersBySettingSelectedDate: [self _nextValidDate: date]];
}
- (NSDictionary *) monthBeforePrevMonthQueryParameters
@@ -214,8 +228,10 @@
- (int) currentDayNumber
{
return ([currentWeek indexOfObject: currentTableDay]
+ [weeksToDisplay indexOfObject: currentWeek] * 7);
int i = [currentWeek indexOfObject: currentTableDay] +
([weeksToDisplay indexOfObject: currentWeek] * [currentWeek count]);
return daysNumbersToDisplay[i];
}
- (void) setCurrentWeek: (NSArray *) newCurrentWeek
@@ -285,8 +301,9 @@
NSCalendarDate *firstDayOfMonth;
firstDayOfMonth = [[self selectedDate] firstDayOfMonth];
firstDayOfMonth = [[context activeUser] firstDayOfWeekForDate: firstDayOfMonth];
return [[context activeUser] firstDayOfWeekForDate: firstDayOfMonth];
return [self _nextValidDate: firstDayOfMonth];
}
- (NSCalendarDate *) endDate
+4 -3
View File
@@ -1,8 +1,6 @@
/* UIxCalView.h - this file is part of SOGo
*
* Copyright (C) 2006-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Copyright (C) 2006-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -48,6 +46,7 @@
NSMutableDictionary *componentsData;
NSArray *tasks;
NSArray *allDayApts;
NSArray *enabledWeekDays;
id appointment;
NSCalendarDate *currentDay;
NSTimeZone *timeZone;
@@ -130,6 +129,8 @@
- (NSString *) aptStyle;
/* protected methods */
- (NSCalendarDate *) _nextValidDate: (NSCalendarDate *) date;
- (int) _nextValidOffset: (int) daysOffset;
- (NSDictionary *) _dateQueryParametersWithOffset: (int) daysOffset;
@end
+62 -10
View File
@@ -1,6 +1,6 @@
/* UIxCalView.m - this file is part of SOGo
*
* Copyright (C) 2006-2015 Inverse inc.
* Copyright (C) 2006-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +26,8 @@
#import <NGExtensions/NSString+misc.h>
#import <NGCards/NGCards.h>
#import <SOPE/NGCards/iCalRecurrenceRule.h>
#import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentFolders.h>
#import <SOGo/NSArray+Utilities.h>
@@ -55,6 +57,7 @@
{
ud = [[context activeUser] userDefaults];
ASSIGN (timeZone, [ud timeZone]);
ASSIGN (enabledWeekDays, [ud calendarWeekdays]);
aptFormatter
= [[SOGoAptFormatter alloc] initWithDisplayTimeZone: timeZone];
aptTooltipFormatter
@@ -253,7 +256,7 @@
title = [appointment valueForKey: @"title"];
if ([title length] > 12)
title = [[title substringToIndex: 11] stringByAppendingString: @"..."];
return title;
}
@@ -396,7 +399,7 @@
if ([bv boolValue])
[filtered addObject: apt];
}
ASSIGN(allDayApts, filtered);
[filtered release];
return allDayApts;
@@ -448,10 +451,10 @@
- (NSString *) appointmentViewURL
{
id pkey;
if (![(pkey = [[self appointment] valueForKey: @"uid"]) isNotNull])
return nil;
return [[[self clientObject] baseURLForAptWithUID: [pkey stringValue]
inContext: [self context]]
stringByAppendingString: @"/view"];
@@ -474,7 +477,7 @@
- (BOOL) shouldDisplayRejectedAppointments
{
NSString *bv;
bv = [self queryParameterForKey: @"dr"];
if (!bv) return NO;
return [bv boolValue];
@@ -484,7 +487,7 @@
{
NSMutableDictionary *qp;
BOOL shouldDisplay;
shouldDisplay = ![self shouldDisplayRejectedAppointments];
qp = [[[self queryParameters] mutableCopy] autorelease];
[qp setObject: shouldDisplay ? @"1" : @"0" forKey: @"dr"];
@@ -500,19 +503,68 @@
/* date selection & conversion */
- (NSCalendarDate *) _nextValidDate: (NSCalendarDate *) date
{
NSCalendarDate *validDate;
NSString *weekDay;
validDate = [[date copy] autorelease];
if ([enabledWeekDays count])
{
weekDay = iCalWeekDayString[[validDate dayOfWeek]];
while (![enabledWeekDays containsObject: weekDay])
{
validDate = [validDate dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0];
weekDay = iCalWeekDayString[[validDate dayOfWeek]];
}
}
return validDate;
}
- (int) _nextValidOffset: (int) daysOffset
{
NSCalendarDate *date;
NSString *weekDay;
int count, offset;
count = (daysOffset < 0)? -1 : +1;
offset = daysOffset;
if ([enabledWeekDays count])
{
date = [[self startDate] dateByAddingYears:0 months:0 days:offset hours:0 minutes:0 seconds:0];
weekDay = iCalWeekDayString[[date dayOfWeek]];
while (![enabledWeekDays containsObject: weekDay])
{
offset += count;
date = [date dateByAddingYears:0 months:0 days:count hours:0 minutes:0 seconds:0];
weekDay = iCalWeekDayString[[date dayOfWeek]];
}
}
return offset;
}
- (NSDictionary *) _dateQueryParametersWithOffset: (int) daysOffset
{
NSCalendarDate *date;
date = [[self startDate] dateByAddingYears: 0 months: 0
days: daysOffset
hours: 0 minutes: 0 seconds: 0];
return [self queryParametersBySettingSelectedDate: date];
}
- (NSDictionary *) todayQueryParameters
{
return [self queryParametersBySettingSelectedDate: [NSCalendarDate date]];
NSCalendarDate *today;
today = [NSCalendarDate date];
[today setTimeZone: timeZone];
return [self queryParametersBySettingSelectedDate: [self _nextValidDate: today]];
}
- (NSDictionary *) currentDayQueryParameters
@@ -581,7 +633,7 @@
&& (![userFolderID isEqualToString: uidsString])))
{
NSRange r;
/* uri ends with an '/', so we have to adjust the range a little */
r = NSMakeRange(0, [uri length] - 1);
r = [uri rangeOfString: @"/"
+1 -1
View File
@@ -44,7 +44,7 @@
date = [[context activeUser] firstDayOfWeekForDate: [super startDate]];
return [date beginOfDay];
return [self _nextValidDate: [date beginOfDay]];
}
- (NSCalendarDate *) endDate