2006-08-24 20:56:24 +02:00
|
|
|
/* UIxCalDayTable.m - this file is part of SOGo
|
|
|
|
*
|
2016-05-06 20:14:45 +02:00
|
|
|
* Copyright (C) 2006-2016 Inverse inc.
|
2006-08-24 20:56:24 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-11-15 01:06:21 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <Foundation/NSUserDefaults.h> /* for locale string constants */
|
2008-07-18 21:25:26 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2006-08-24 20:56:24 +02:00
|
|
|
|
2007-06-19 20:08:16 +02:00
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
2006-08-24 20:56:24 +02:00
|
|
|
|
2016-05-06 20:14:45 +02:00
|
|
|
#import <SOPE/NGCards/iCalRecurrenceRule.h>
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
#import <SOGo/NSCalendarDate+SOGo.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoDateFormatter.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2011-02-03 17:12:22 +01:00
|
|
|
#import <SOGo/WOResourceManager+SOGo.h>
|
2009-04-01 15:49:24 +02:00
|
|
|
|
2015-09-18 22:11:31 +02:00
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolders.h>
|
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
#import "UIxCalDayTable.h"
|
|
|
|
|
|
|
|
@class SOGoAppointment;
|
|
|
|
|
|
|
|
@implementation UIxCalDayTable
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUser *user;
|
|
|
|
SOGoUserDefaults *ud;
|
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
user = [context activeUser];
|
|
|
|
ud = [user userDefaults];
|
|
|
|
ASSIGN (timeFormat, [ud timeFormat]);
|
2008-12-23 01:12:14 +01:00
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
daysToDisplay = nil;
|
2014-06-20 19:16:55 +02:00
|
|
|
calendarsToDisplay = nil;
|
2006-08-24 20:56:24 +02:00
|
|
|
hoursToDisplay = nil;
|
|
|
|
numberOfDays = 1;
|
|
|
|
startDate = nil;
|
2014-06-20 19:16:55 +02:00
|
|
|
currentView = nil;
|
|
|
|
currentCalendar = nil;
|
2006-08-24 20:56:24 +02:00
|
|
|
currentTableDay = nil;
|
|
|
|
currentTableHour = nil;
|
2016-05-06 20:14:45 +02:00
|
|
|
weekDays = [locale objectForKey: NSWeekDayNameArray];
|
2007-06-19 20:08:16 +02:00
|
|
|
[weekDays retain];
|
2009-11-29 05:19:32 +01:00
|
|
|
dateFormatter = [user dateFormatterInContext: context];
|
2009-03-03 20:08:02 +01:00
|
|
|
[dateFormatter retain];
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
2009-11-29 05:19:32 +01:00
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2007-06-11 23:27:14 +02:00
|
|
|
// if (allAppointments)
|
|
|
|
// [allAppointments release];
|
2007-06-19 20:08:16 +02:00
|
|
|
[weekDays release];
|
2007-06-11 23:27:14 +02:00
|
|
|
[daysToDisplay release];
|
2014-06-20 19:16:55 +02:00
|
|
|
[calendarsToDisplay release];
|
2014-06-27 23:21:18 +02:00
|
|
|
[currentView release];
|
2007-06-11 23:27:14 +02:00
|
|
|
[hoursToDisplay release];
|
2009-03-03 20:08:02 +01:00
|
|
|
[dateFormatter release];
|
2009-11-29 05:19:32 +01:00
|
|
|
[timeFormat release];
|
2016-05-06 20:14:45 +02:00
|
|
|
free(daysNumbersToDisplay);
|
2006-08-24 20:56:24 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2008-07-18 21:25:26 +02:00
|
|
|
- (void) setNumberOfDays: (NSNumber *) aNumber
|
2006-08-24 20:56:24 +02:00
|
|
|
{
|
|
|
|
numberOfDays = [aNumber intValue];
|
2007-06-11 23:27:14 +02:00
|
|
|
[daysToDisplay release];
|
|
|
|
daysToDisplay = nil;
|
2006-11-15 01:06:21 +01:00
|
|
|
}
|
|
|
|
|
2008-07-18 21:25:26 +02:00
|
|
|
- (NSNumber *) numberOfDays
|
2006-11-15 01:06:21 +01:00
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
return [NSNumber numberWithUnsignedInt: numberOfDays];
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setStartDate: (NSCalendarDate *) aStartDate
|
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
startDate = [aStartDate beginOfDay];
|
2007-06-11 23:27:14 +02:00
|
|
|
[daysToDisplay release];
|
|
|
|
daysToDisplay = nil;
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) startDate
|
|
|
|
{
|
|
|
|
if (!startDate)
|
2008-07-18 21:25:26 +02:00
|
|
|
startDate = [[super startDate] beginOfDay];
|
2006-08-24 20:56:24 +02:00
|
|
|
|
2008-07-18 21:25:26 +02:00
|
|
|
return startDate;
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) endDate
|
|
|
|
{
|
|
|
|
NSCalendarDate *endDate;
|
|
|
|
|
|
|
|
endDate = [[self startDate] dateByAddingYears: 0
|
|
|
|
months: 0
|
|
|
|
days: numberOfDays - 1];
|
|
|
|
|
|
|
|
return [endDate endOfDay];
|
|
|
|
}
|
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
- (void) setCurrentView: (NSString *) aView
|
|
|
|
{
|
2014-06-27 23:21:18 +02:00
|
|
|
ASSIGN(currentView, aView);
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentView
|
|
|
|
{
|
|
|
|
return currentView;
|
|
|
|
}
|
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
- (NSArray *) hoursToDisplay
|
|
|
|
{
|
|
|
|
unsigned int currentHour, lastHour;
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
if (!hoursToDisplay)
|
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
hoursToDisplay = [NSMutableArray new];
|
2006-08-24 20:56:24 +02:00
|
|
|
currentHour = [self dayStartHour];
|
|
|
|
lastHour = [self dayEndHour];
|
|
|
|
while (currentHour < lastHour)
|
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
[hoursToDisplay addObject: [NSNumber numberWithInt: currentHour]];
|
2006-08-24 20:56:24 +02:00
|
|
|
currentHour++;
|
|
|
|
}
|
2008-07-18 21:25:26 +02:00
|
|
|
[hoursToDisplay addObject: [NSNumber numberWithInt: currentHour]];
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hoursToDisplay;
|
|
|
|
}
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
- (NSString *) currentHourId
|
2008-07-18 21:25:26 +02:00
|
|
|
{
|
2010-02-13 00:24:24 +01:00
|
|
|
return [NSString stringWithFormat: @"hour%d", [currentTableHour intValue]];
|
2008-07-18 21:25:26 +02:00
|
|
|
}
|
|
|
|
|
2016-05-06 20:14:45 +02:00
|
|
|
/**
|
|
|
|
* Return an array of NSCalendarDate instances matching the requested time period
|
|
|
|
* and the week days enabled in the user's defaults.
|
|
|
|
*/
|
2006-08-24 20:56:24 +02:00
|
|
|
- (NSArray *) daysToDisplay
|
|
|
|
{
|
|
|
|
NSCalendarDate *currentDate;
|
2016-05-06 20:14:45 +02:00
|
|
|
NSString *weekDay;
|
|
|
|
int count, enabledCount;
|
|
|
|
|
2006-11-15 01:06:21 +01:00
|
|
|
if (!daysToDisplay)
|
2014-06-20 19:16:55 +02:00
|
|
|
{
|
|
|
|
daysToDisplay = [NSMutableArray new];
|
2016-05-06 20:14:45 +02:00
|
|
|
daysNumbersToDisplay = malloc (numberOfDays * sizeof (unsigned int));
|
2014-06-20 19:16:55 +02:00
|
|
|
currentDate = [[self startDate] hour: [self dayStartHour]
|
|
|
|
minute: 0];
|
2016-05-06 20:14:45 +02:00
|
|
|
|
|
|
|
for (count = 0, enabledCount = 0; count < numberOfDays; count++)
|
2006-08-24 20:56:24 +02:00
|
|
|
{
|
2016-05-06 20:14:45 +02:00
|
|
|
weekDay = iCalWeekDayString[[currentDate dayOfWeek]];
|
|
|
|
if ([enabledWeekDays count] == 0 || [enabledWeekDays containsObject: weekDay])
|
|
|
|
{
|
|
|
|
[daysToDisplay addObject: currentDate];
|
|
|
|
daysNumbersToDisplay[enabledCount] = count;
|
|
|
|
enabledCount++;
|
|
|
|
}
|
2014-06-20 19:16:55 +02:00
|
|
|
currentDate = [currentDate tomorrow];
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2006-11-15 01:06:21 +01:00
|
|
|
return daysToDisplay;
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
- (NSArray *) calendarsToDisplay
|
|
|
|
{
|
2014-06-27 23:21:18 +02:00
|
|
|
if (!calendarsToDisplay)
|
|
|
|
{
|
2014-06-20 19:16:55 +02:00
|
|
|
NSArray *folders;
|
|
|
|
SOGoAppointmentFolders *co;
|
|
|
|
SOGoAppointmentFolder *folder;
|
|
|
|
NSMutableDictionary *calendar;
|
|
|
|
unsigned int count, foldersCount;
|
|
|
|
NSString *folderName, *fDisplayName;
|
2015-10-31 07:10:03 +01:00
|
|
|
BOOL isActive;
|
2014-06-20 19:16:55 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
co = [self clientObject];
|
|
|
|
folders = [co subFolders];
|
|
|
|
foldersCount = [folders count];
|
|
|
|
calendarsToDisplay = [[NSMutableArray alloc] initWithCapacity: foldersCount];
|
|
|
|
for (count = 0; count < foldersCount; count++)
|
|
|
|
{
|
|
|
|
folder = [folders objectAtIndex: count];
|
2015-10-31 07:10:03 +01:00
|
|
|
isActive = [folder isActive];
|
|
|
|
if (isActive != NO) {
|
2014-06-20 19:16:55 +02:00
|
|
|
calendar = [NSMutableDictionary dictionary];
|
|
|
|
folderName = [folder nameInContainer];
|
|
|
|
fDisplayName = [folder displayName];
|
|
|
|
if (fDisplayName == nil)
|
|
|
|
fDisplayName = @"";
|
|
|
|
if ([fDisplayName isEqualToString: [co defaultFolderName]])
|
|
|
|
fDisplayName = [self labelForKey: fDisplayName];
|
|
|
|
[calendar setObject: [NSString stringWithFormat: @"/%@", folderName]
|
|
|
|
forKey: @"id"];
|
|
|
|
[calendar setObject: fDisplayName forKey: @"displayName"];
|
|
|
|
[calendar setObject: folderName forKey: @"folder"];
|
|
|
|
[calendar setObject: [folder calendarColor] forKey: @"color"];
|
2015-10-31 07:10:03 +01:00
|
|
|
[calendar setObject: [NSNumber numberWithBool:isActive] forKey: @"active"];
|
2014-06-20 19:16:55 +02:00
|
|
|
[calendar setObject: [folder ownerInContext: context]
|
|
|
|
forKey: @"owner"];
|
|
|
|
[calendarsToDisplay addObject: calendar];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
return calendarsToDisplay;
|
|
|
|
}
|
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
- (void) setCurrentTableDay: (NSCalendarDate *) aTableDay
|
|
|
|
{
|
|
|
|
currentTableDay = aTableDay;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) currentTableDay
|
|
|
|
{
|
|
|
|
return currentTableDay;
|
|
|
|
}
|
|
|
|
|
2015-10-31 07:10:03 +01:00
|
|
|
- (void) setCurrentCalendar: (NSMutableDictionary *) aCalendar
|
2014-06-20 19:16:55 +02:00
|
|
|
{
|
2014-06-27 23:21:18 +02:00
|
|
|
ASSIGN(currentCalendar, aCalendar);
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
|
2015-10-31 07:10:03 +01:00
|
|
|
- (NSMutableDictionary *) currentCalendar
|
2014-06-20 19:16:55 +02:00
|
|
|
{
|
|
|
|
return currentCalendar;
|
|
|
|
}
|
|
|
|
|
2016-05-17 22:22:50 +02:00
|
|
|
- (void) setCurrentTableHour: (NSNumber *) aTableHour
|
2006-08-24 20:56:24 +02:00
|
|
|
{
|
2016-05-17 22:22:50 +02:00
|
|
|
ASSIGN(currentTableHour, aTableHour);
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
2016-05-17 22:22:50 +02:00
|
|
|
- (NSNumber *) currentTableHour
|
|
|
|
{
|
|
|
|
return currentTableHour;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentFormattedHour
|
2006-08-24 20:56:24 +02:00
|
|
|
{
|
2009-08-25 17:05:01 +02:00
|
|
|
int hour;
|
|
|
|
NSCalendarDate *tmp;
|
2016-05-17 22:22:50 +02:00
|
|
|
NSString *formatted = [NSString stringWithFormat: @"%d", [currentTableHour intValue]], *parse;
|
2009-08-25 17:05:01 +02:00
|
|
|
|
|
|
|
hour = [currentTableHour intValue];
|
|
|
|
parse = [NSString stringWithFormat: @"2000-01-01 %02d:00", hour];
|
|
|
|
|
|
|
|
tmp = [NSCalendarDate dateWithString: parse
|
|
|
|
calendarFormat: @"%Y-%m-%d %H:%M"];
|
|
|
|
if (tmp)
|
2016-05-17 22:22:50 +02:00
|
|
|
formatted = [tmp descriptionWithCalendarFormat: timeFormat
|
|
|
|
locale: locale];
|
2009-08-25 17:05:01 +02:00
|
|
|
|
|
|
|
return formatted;
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
- (NSString *) currentAllDayId
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"allDay%@", [currentTableDay shortDateString]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentDayId
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"day%@", [currentTableDay shortDateString]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) currentDayNumber
|
|
|
|
{
|
2016-05-06 20:14:45 +02:00
|
|
|
int i = [daysToDisplay indexOfObject: currentTableDay];
|
|
|
|
|
|
|
|
return daysNumbersToDisplay[i];
|
2010-02-13 00:24:24 +01:00
|
|
|
}
|
|
|
|
|
2015-11-06 21:12:24 +01:00
|
|
|
- (NSNumber *) currentAppointmentHour
|
2006-08-31 00:59:03 +02:00
|
|
|
{
|
2015-11-06 21:12:24 +01:00
|
|
|
return [NSNumber numberWithInt: [currentTableHour intValue]];
|
2006-08-31 00:59:03 +02:00
|
|
|
}
|
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
- (NSString *) labelForDay
|
|
|
|
{
|
2007-06-19 20:08:16 +02:00
|
|
|
return [weekDays objectAtIndex: [currentTableDay dayOfWeek]];
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
2015-09-18 22:11:31 +02:00
|
|
|
- (NSString *) labelForMonth
|
|
|
|
{
|
2015-09-23 21:19:39 +02:00
|
|
|
NSString *calendarFormat;
|
2016-06-10 20:06:41 +02:00
|
|
|
BOOL isFirstDay;
|
2015-09-18 22:11:31 +02:00
|
|
|
|
2016-06-10 20:06:41 +02:00
|
|
|
isFirstDay = NO;
|
2015-09-23 21:19:39 +02:00
|
|
|
calendarFormat = @"%b";
|
|
|
|
|
2015-09-29 20:08:05 +02:00
|
|
|
if ([currentView hasSuffix: @"dayview"])
|
2015-09-18 22:11:31 +02:00
|
|
|
{
|
2016-06-10 20:06:41 +02:00
|
|
|
isFirstDay = YES;
|
2015-09-23 21:19:39 +02:00
|
|
|
calendarFormat = @"%B";
|
2015-09-18 22:11:31 +02:00
|
|
|
}
|
2016-06-10 20:06:41 +02:00
|
|
|
else if ([currentTableDay dayOfMonth] == 1 || [daysToDisplay indexOfObject: currentTableDay] == 0)
|
2015-09-18 22:11:31 +02:00
|
|
|
{
|
2016-06-10 20:06:41 +02:00
|
|
|
isFirstDay = YES;
|
2015-09-18 22:11:31 +02:00
|
|
|
}
|
|
|
|
|
2016-06-10 20:06:41 +02:00
|
|
|
return isFirstDay? [currentTableDay descriptionWithCalendarFormat: calendarFormat locale: locale] : nil;
|
2015-09-18 22:11:31 +02:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:27:14 +02:00
|
|
|
- (NSString *) labelForDate
|
2006-11-15 01:06:21 +01:00
|
|
|
{
|
2007-06-19 20:08:16 +02:00
|
|
|
return [dateFormatter shortFormattedDate: currentTableDay];
|
2006-11-15 01:06:21 +01:00
|
|
|
}
|
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
- (NSString *) labelForCalendar
|
|
|
|
{
|
2014-06-27 23:21:18 +02:00
|
|
|
return [currentCalendar objectForKey: @"displayName"];
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) colorForCalendar
|
|
|
|
{
|
2014-06-27 23:21:18 +02:00
|
|
|
return [currentCalendar objectForKey:@"color"];
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:27:14 +02:00
|
|
|
// - (NSDictionary *) _adjustedAppointment: (NSDictionary *) anAppointment
|
|
|
|
// forStart: (NSCalendarDate *) start
|
|
|
|
// andEnd: (NSCalendarDate *) end
|
|
|
|
// {
|
|
|
|
// NSMutableDictionary *newMutableAppointment;
|
|
|
|
// NSDictionary *newAppointment;
|
|
|
|
// BOOL startIsEarlier, endIsLater;
|
|
|
|
|
|
|
|
// startIsEarlier
|
|
|
|
// = ([[anAppointment objectForKey: @"startDate"] laterDate: start] == start);
|
|
|
|
// endIsLater
|
|
|
|
// = ([[anAppointment objectForKey: @"endDate"] earlierDate: end] == end);
|
|
|
|
|
|
|
|
// if (startIsEarlier || endIsLater)
|
|
|
|
// {
|
|
|
|
// newMutableAppointment
|
|
|
|
// = [NSMutableDictionary dictionaryWithDictionary: anAppointment];
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2007-06-11 23:27:14 +02:00
|
|
|
// if (startIsEarlier)
|
|
|
|
// [newMutableAppointment setObject: start
|
|
|
|
// forKey: @"startDate"];
|
|
|
|
// if (endIsLater)
|
|
|
|
// [newMutableAppointment setObject: end
|
|
|
|
// forKey: @"endDate"];
|
|
|
|
|
|
|
|
// newAppointment = newMutableAppointment;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// newAppointment = anAppointment;
|
|
|
|
|
|
|
|
// return newAppointment;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSArray *) appointmentsForCurrentDay
|
|
|
|
// {
|
|
|
|
// NSMutableArray *filteredAppointments;
|
|
|
|
// NSEnumerator *aptsEnumerator;
|
|
|
|
// NSDictionary *currentDayAppointment;
|
|
|
|
// NSCalendarDate *start, *end;
|
|
|
|
// int endHour;
|
|
|
|
|
|
|
|
// if (!allAppointments)
|
|
|
|
// {
|
|
|
|
// allAppointments = [self fetchCoreAppointmentsInfos];
|
|
|
|
// [allAppointments retain];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// filteredAppointments = [NSMutableArray new];
|
|
|
|
// [filteredAppointments autorelease];
|
|
|
|
|
|
|
|
// start = [currentTableDay hour: [self dayStartHour] minute: 0];
|
|
|
|
// endHour = [self dayEndHour];
|
|
|
|
// if (endHour < 24)
|
|
|
|
// end = [currentTableDay hour: [self dayEndHour] minute: 59];
|
|
|
|
// else
|
|
|
|
// end = [[currentTableDay tomorrow] hour: 0 minute: 0];
|
|
|
|
|
|
|
|
// aptsEnumerator = [allAppointments objectEnumerator];
|
|
|
|
// currentDayAppointment = [aptsEnumerator nextObject];
|
|
|
|
// while (currentDayAppointment)
|
|
|
|
// {
|
|
|
|
// if (([end laterDate: [currentDayAppointment
|
|
|
|
// valueForKey: @"startDate"]] == end)
|
|
|
|
// && ([start earlierDate: [currentDayAppointment
|
|
|
|
// valueForKey: @"endDate"]] == start))
|
|
|
|
// [filteredAppointments
|
|
|
|
// addObject: [self _adjustedAppointment: currentDayAppointment
|
|
|
|
// forStart: start andEnd: end]];
|
|
|
|
// currentDayAppointment = [aptsEnumerator nextObject];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return filteredAppointments;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setCurrentAppointment: (NSDictionary *) newCurrentAppointment
|
|
|
|
// {
|
|
|
|
// currentAppointment = newCurrentAppointment;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSDictionary *) currentAppointment
|
|
|
|
// {
|
|
|
|
// return currentAppointment;
|
|
|
|
// }
|
2006-11-15 01:06:21 +01:00
|
|
|
|
2007-02-13 23:01:52 +01:00
|
|
|
- (NSString *) appointmentsClasses
|
2006-11-15 01:06:21 +01:00
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"appointments appointmentsFor%dDays",
|
|
|
|
numberOfDays];
|
|
|
|
}
|
|
|
|
|
2015-09-23 21:19:39 +02:00
|
|
|
// - (NSString *) daysViewClasses
|
|
|
|
// {
|
|
|
|
// NSString *daysView;
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2015-09-23 21:19:39 +02:00
|
|
|
// if ([currentView isEqualToString:@"multicolumndayview"])
|
|
|
|
// daysView = @"daysView daysViewForMultipleDays";
|
2014-06-20 19:16:55 +02:00
|
|
|
|
2015-09-23 21:19:39 +02:00
|
|
|
// else
|
|
|
|
// daysView = [NSString stringWithFormat: @"daysView daysViewFor%dDays", numberOfDays];
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2015-09-23 21:19:39 +02:00
|
|
|
// return daysView;
|
|
|
|
//}
|
2006-08-24 20:56:24 +02:00
|
|
|
|
2015-09-23 21:19:39 +02:00
|
|
|
// - (NSString *) daysViewHeaderClasses
|
|
|
|
// {
|
|
|
|
// return [NSString stringWithFormat: @"%@ daysHeader", [self daysViewClasses]];
|
|
|
|
// }
|
2015-09-18 22:11:31 +02:00
|
|
|
|
2006-11-15 01:06:21 +01:00
|
|
|
- (NSString *) dayClasses
|
|
|
|
{
|
|
|
|
NSMutableString *classes;
|
2016-05-06 20:14:45 +02:00
|
|
|
unsigned int realDayOfWeek;
|
|
|
|
|
|
|
|
classes = [NSMutableString stringWithString: @"day"];
|
2015-09-29 20:08:05 +02:00
|
|
|
realDayOfWeek = [currentTableDay dayOfWeek];
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2015-09-29 20:08:05 +02:00
|
|
|
if (numberOfDays > 1)
|
2006-08-24 20:56:24 +02:00
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
if (realDayOfWeek == 0 || realDayOfWeek == 6)
|
2006-11-15 01:06:21 +01:00
|
|
|
[classes appendString: @" weekEndDay"];
|
|
|
|
if ([currentTableDay isToday])
|
|
|
|
[classes appendString: @" dayOfToday"];
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2006-11-15 01:06:21 +01:00
|
|
|
return classes;
|
2006-08-24 20:56:24 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:53:59 +01:00
|
|
|
- (NSString *) clickableHourCellClass
|
|
|
|
{
|
2008-07-18 21:25:26 +02:00
|
|
|
NSMutableString *cellClass;
|
|
|
|
int hour;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
2008-07-18 21:25:26 +02:00
|
|
|
|
|
|
|
cellClass = [NSMutableString string];
|
|
|
|
hour = [currentTableHour intValue];
|
2009-11-29 05:19:32 +01:00
|
|
|
ud = [[context activeUser] userDefaults];
|
2008-07-18 21:25:26 +02:00
|
|
|
[cellClass appendFormat: @"clickableHourCell clickableHourCell%d", hour];
|
2009-11-29 05:19:32 +01:00
|
|
|
if (hour < [ud dayStartHour] || hour > [ud dayEndHour] - 1)
|
2008-07-18 21:25:26 +02:00
|
|
|
[cellClass appendString: @" outOfDay"];
|
|
|
|
|
|
|
|
return cellClass;
|
2006-11-15 01:53:59 +01:00
|
|
|
}
|
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
- (BOOL) isMultiColumnView
|
|
|
|
{
|
|
|
|
if ([currentView isEqualToString:@"multicolumndayview"])
|
2014-06-27 23:21:18 +02:00
|
|
|
return YES;
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2014-06-27 23:21:18 +02:00
|
|
|
return NO;
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isNotMultiColumnView
|
|
|
|
{
|
|
|
|
if ([currentView isEqualToString:@"dayview"] || [currentView isEqualToString:@"weekview"])
|
2014-06-27 23:21:18 +02:00
|
|
|
return YES;
|
2016-05-06 20:14:45 +02:00
|
|
|
|
2014-06-27 23:21:18 +02:00
|
|
|
return NO;
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
|
2015-09-18 22:11:31 +02:00
|
|
|
- (BOOL) isWeekView
|
|
|
|
{
|
|
|
|
return [currentView isEqualToString:@"weekview"];
|
|
|
|
}
|
|
|
|
|
2006-08-24 20:56:24 +02:00
|
|
|
@end
|