From bde483a270f8df210a37534af86fe7f7f777c402 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Thu, 7 Jun 2007 18:51:04 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1079 d1b88da0-ebda-0310-925b-ed51d893ca5b --- UI/Scheduler/UIxCalTasksListView.h | 17 +--- UI/Scheduler/UIxCalTasksListView.m | 145 +++++++++++++++++++---------- 2 files changed, 102 insertions(+), 60 deletions(-) diff --git a/UI/Scheduler/UIxCalTasksListView.h b/UI/Scheduler/UIxCalTasksListView.h index 5cdc7f84..8cefb7ca 100644 --- a/UI/Scheduler/UIxCalTasksListView.h +++ b/UI/Scheduler/UIxCalTasksListView.h @@ -23,23 +23,14 @@ #ifndef UIXCALTASKSLISTVIEW_H #define UIXCALTASKSLISTVIEW_H -#import "UIxCalView.h" -@class NSDictionary; +#import -@interface UIxCalTasksListView : UIxCalView -{ - NSCalendarDate *startDate; - NSCalendarDate *endDate; +@class WOResponse; - BOOL knowsToShow; - BOOL showCompleted; +@interface UIxCalTasksListView : WODirectAction - NSDictionary *currentTask; -} - -- (void) setCurrentTask: (NSDictionary *) task; -- (NSDictionary *) currentTask; +- (WOResponse *) tasksListAction; @end diff --git a/UI/Scheduler/UIxCalTasksListView.m b/UI/Scheduler/UIxCalTasksListView.m index 349cee29..ab01e056 100644 --- a/UI/Scheduler/UIxCalTasksListView.m +++ b/UI/Scheduler/UIxCalTasksListView.m @@ -46,61 +46,117 @@ return self; } -- (void) setCurrentTask: (NSDictionary *) task +- (void) _updatePrivacyInObjects: (NSArray *) objectInfos + fromFolder: (SOGoAppointmentFolder *) folder { - currentTask = task; + int hideDetails[] = {-1, -1, -1}; + NSMutableDictionary *currentRecord; + int privacyFlag; + NSString *roleString, *userLogin; + NSEnumerator *infos; + + userLogin = [[context activeUser] login]; + infos = [objectInfos objectEnumerator]; + currentRecord = [infos nextObject]; + while (currentRecord) + { + privacyFlag = [[currentRecord objectForKey: @"classification"] intValue]; + if (hideDetails[privacyFlag] == -1) + { + roleString = [folder roleForComponentsWithAccessClass: privacyFlag + forUser: userLogin]; + hideDetails[privacyFlag] = ([roleString isEqualToString: @"ComponentDAndTViewer"] + ? 1 : 0); + } + if (hideDetails[privacyFlag]) + { + [currentRecord setObject: [self labelForKey: @"(Private Event)"] + forKey: @"title"]; + [currentRecord setObject: @"" forKey: @"location"]; + } + currentRecord = [infos nextObject]; + } } -- (NSDictionary *) currentTask +- (NSArray *) _fetchCoreInfosForComponent: (NSString *) component { - return currentTask; -} + NSArray *currentInfos; + NSMutableArray *infos; + NSEnumerator *folders; + SOGoAppointmentFolder *currentFolder; -- (NSCalendarDate *) startDate -{ - return nil; + infos = [componentsData objectForKey: component]; + if (!infos) + { + infos = [NSMutableArray array]; + folders = [[self _activeCalendarFolders] objectEnumerator]; + currentFolder = [folders nextObject]; + while (currentFolder) + { + currentInfos = [currentFolder fetchCoreInfosFrom: [[self startDate] beginOfDay] + to: [[self endDate] endOfDay] + component: component]; + [currentInfos makeObjectsPerform: @selector (setObject:forKey:) + withObject: [currentFolder ownerInContext: nil] + withObject: @"owner"]; + [self _updatePrivacyInObjects: currentInfos + fromFolder: currentFolder]; + [infos addObjectsFromArray: currentInfos]; + currentFolder = [folders nextObject]; + } + [componentsData setObject: infos forKey: component]; + } + + return infos; } -- (NSCalendarDate *) endDate +- (NSArray *) fetchCoreAppointmentsInfos { - return nil; + if (!appointments) + [self setAppointments: [self _fetchCoreInfosForComponent: @"vevent"]]; + + return appointments; } -- (NSString *) currentStatusClass +- (WOResponse *) tasksListAction { - NSCalendarDate *taskDate, *now; - NSString *statusClass, *allClasses; - NSNumber *taskDueStamp; - - if ([[currentTask objectForKey: @"status"] intValue] == 1) - statusClass = @"completed"; - else - { - taskDueStamp = [currentTask objectForKey: @"enddate"]; - if ([taskDueStamp intValue]) - { - now = [NSCalendarDate calendarDate]; - taskDate = [NSCalendarDate dateWithTimeIntervalSince1970: - [taskDueStamp intValue]]; - if ([taskDate earlierDate: now] == taskDate) - statusClass = @"overdue"; - else - { - if ([taskDate isToday]) - statusClass = @"duetoday"; - else - statusClass = @"duelater"; - } - } - else - statusClass = @"duelater"; + WOResponse *response; + NSDictionary *tasks; + NSMutableArray *filteredTasks; + BOOL showCompleted; + unsigned i, count; + + response = [context response]; + filteredTasks = [NSMutableArray new]; + [filteredTasks autorelease]; + tasks = [self _fetchCoreInfosForComponent: @"vtodo"]; + showCompleted = [[self queryParameterForKey: @"show-completed"] intValue]; + + count = [tasks count]; + for (i = 0; i < count; i++) { + NSDictionary *task; + NSArray *filteredTask; + + task = [tasks objectAtIndex: i]; + + if ([[task objectForKey: @"status"] intValue] != 1 + || showCompleted) + { + filteredTask = [NSArray arrayWithObjects: + [task objectForKey: @"c_name"], + [task objectForKey: @"owner"], + [task objectForKey: @"status"], + [task objectForKey: @"title"], + [self getStatusClassForTask: task], + nil]; + [filteredTasks addObject: filteredTask]; } + } + + [response setStatus: 200]; + [response appendContentString: [filteredTasks jsonRepresentation]]; - allClasses = [NSString stringWithFormat: @"%@ ownerIs%@", - statusClass, - [currentTask objectForKey: @"owner"]]; - - return allClasses; + return response; } - (BOOL) shouldDisplayCurrentTask @@ -128,9 +184,4 @@ return showCompleted; } -- (BOOL) isCurrentTaskCompleted -{ - return ([[currentTask objectForKey: @"status"] intValue] == 1); -} - @end -- 2.39.5