From 1485554bf04ef54eee20aaf98010b1f4001123fa Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 12 Aug 2004 16:28:32 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/trunk@191 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Appointments/ChangeLog | 8 ++ .../Appointments/SOGoAppointmentFolder.h | 4 + .../Appointments/SOGoAppointmentFolder.m | 14 ++ .../Appointments/SOGoGroupAppointmentFolder.m | 15 ++ SOGo/SoObjects/Appointments/Version | 2 +- SOGo/UI/Scheduler/ChangeLog | 13 +- SOGo/UI/Scheduler/GNUmakefile | 2 + SOGo/UI/Scheduler/NOTES | 17 +-- SOGo/UI/Scheduler/NSCalendarDate+UIx.h | 35 +++++ SOGo/UI/Scheduler/NSCalendarDate+UIx.m | 50 +++++++ SOGo/UI/Scheduler/UIxAppointmentEditor.m | 48 +++---- SOGo/UI/Scheduler/UIxAppointmentView.m | 34 +++-- SOGo/UI/Scheduler/UIxCalMonthView.m | 71 ++-------- SOGo/UI/Scheduler/UIxCalSelectTab.wox | 16 +-- SOGo/UI/Scheduler/UIxCalView.h | 18 ++- SOGo/UI/Scheduler/UIxCalView.m | 89 ++++++------ SOGo/UI/Scheduler/UIxCalWeekChartview.m | 5 +- SOGo/UI/Scheduler/UIxCalWeekColumnsview.m | 46 +++--- SOGo/UI/Scheduler/UIxCalWeekPrintview.m | 2 - SOGo/UI/Scheduler/UIxCalWeekView.h | 2 + SOGo/UI/Scheduler/UIxCalWeekView.m | 19 ++- SOGo/UI/Scheduler/UIxCalYearOverview.m | 134 ++++++++---------- SOGo/UI/Scheduler/Version | 2 +- 23 files changed, 364 insertions(+), 282 deletions(-) create mode 100644 SOGo/UI/Scheduler/NSCalendarDate+UIx.h create mode 100644 SOGo/UI/Scheduler/NSCalendarDate+UIx.m diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog index 7141aa20..414d8eb4 100644 --- a/SOGo/SoObjects/Appointments/ChangeLog +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -1,3 +1,11 @@ +2004-08-12 + + * v0.9.4 + + * SOGoAppointmentFolder.m: added -baseURLForAptWithUID:inContext: for + determining the resource URL of an appointment, used by calendar + views to locate the viewer page + 2004-08-11 Helge Hess * SOGoGroupAppointmentFolder: can merge input folders, tracks conflicts diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h index 0ae8fb6d..819a7b79 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -56,6 +56,10 @@ from:(NSCalendarDate *)_startDate to:(NSCalendarDate *)_endDate; +/* URL generation */ + +- (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx; + @end #endif /* __Appointments_SOGoAppointmentFolder_H__ */ diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index be8734b4..3bde4e99 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -216,6 +216,20 @@ static NSTimeZone *MET = nil; return [self fetchCoreInfosFromFolder:folder from:_startDate to:_endDate]; } +/* URL generation */ + +- (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx { + NSString *url; + + if ([_uid length] == 0) + return nil; + + url = [self baseURLInContext:_ctx]; + if (![url hasSuffix:@"/"]) + url = [url stringByAppendingString:@"/"]; + return [url stringByAppendingString:_uid]; +} + /* GET */ - (id)GETAction:(WOContext *)_ctx { diff --git a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m index a3eaa57a..3089b558 100644 --- a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m @@ -171,4 +171,19 @@ memberFolders:folders]; } +/* URL generation */ + +- (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx { + //NSString *url; + + if ([_uid length] == 0) + return nil; + +#warning TODO: fix URL generation for aggregate + [self logWithFormat:@"FIXME: URL generation for viewer"]; + + // need to locate the folder containing the apt, then call it + return [super baseURLForAptWithUID:_uid inContext:_ctx]; +} + @end /* SOGoGroupAppointmentFolder */ diff --git a/SOGo/SoObjects/Appointments/Version b/SOGo/SoObjects/Appointments/Version index 58d50ae7..8ca0a8d0 100644 --- a/SOGo/SoObjects/Appointments/Version +++ b/SOGo/SoObjects/Appointments/Version @@ -1,3 +1,3 @@ # $Id: Version,v 1.9 2004/05/19 14:30:45 helge Exp $ -SUBMINOR_VERSION:=3 +SUBMINOR_VERSION:=4 diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 54ef7074..9c93c4e2 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,7 +1,18 @@ 2004-08-12 Helge Hess - * added (still empty) proposal component (v0.9.21) + * v0.9.22 + * UIxAppointmentView.m: properly catch invalid appointment references + and return a 404 (because SOGoAppointmentObject's are created even + for invalid IDs for performance reasons) + + * UIxCalView.m: generate appointment URLs using clientObject (the + appointment folder) + + * more cleanups + + * added (still empty) proposal component (v0.9.21) + * some code reorganizations, fixed some compile warnings (v0.9.20) 2004-08-11 Marcus Mueller diff --git a/SOGo/UI/Scheduler/GNUmakefile b/SOGo/UI/Scheduler/GNUmakefile index d5d35bae..4828361d 100644 --- a/SOGo/UI/Scheduler/GNUmakefile +++ b/SOGo/UI/Scheduler/GNUmakefile @@ -14,6 +14,8 @@ SchedulerUI_OBJC_FILES = \ SchedulerUIProduct.m \ UIxAppointmentFormatter.m \ iCalPerson+UIx.m \ + NSCalendarDate+UIx.m \ + \ UIxCalView.m \ UIxCalDayView.m \ UIxCalWeekView.m \ diff --git a/SOGo/UI/Scheduler/NOTES b/SOGo/UI/Scheduler/NOTES index 35c83b1b..17658cd6 100644 --- a/SOGo/UI/Scheduler/NOTES +++ b/SOGo/UI/Scheduler/NOTES @@ -16,18 +16,19 @@ Class Hierarchy UIxCalMonthOverview UIxCalWeekView UIxCalWeekOverview + UIxCalWeekPrintview + UIxCalWeekColumnsview + UIxCalWeekListview + UIxCalWeekChartview + UIxCalDayView + UIxCalDayOverview + UIxCalDayChartview UIxAptTableView SchedulerUIProduct TBD: - UIxCalDayView - UIxCalDayOverview - UIxCalDayChart - UIxCalDayHChart - [UIxCalWeekView] - UIxCalWeekColumnView - UIxCalWeekChart - UIxCalWeekHChart + UIxCalDayHChart? + UIxCalWeekHChart? OGoYearOverview - should use aggressive caching in the long run - editor page (which comes up in a new window) diff --git a/SOGo/UI/Scheduler/NSCalendarDate+UIx.h b/SOGo/UI/Scheduler/NSCalendarDate+UIx.h new file mode 100644 index 00000000..83e228eb --- /dev/null +++ b/SOGo/UI/Scheduler/NSCalendarDate+UIx.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo 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 + 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 + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +// $Id: UIxAppointmentEditor.m 181 2004-08-11 15:13:25Z helge $ + +#ifndef __NSCalendarDate_UIx_H__ +#define __NSCalendarDate_UIx_H__ + +#import + +@interface NSCalendarDate(UIx) + +- (NSCalendarDate *)dayOfWeeK:(unsigned)_day offsetFromSunday:(unsigned)_off; +- (NSCalendarDate *)sundayOfWeek; + +@end + +#endif /* __NSCalendarDate_UIx_H__ */ diff --git a/SOGo/UI/Scheduler/NSCalendarDate+UIx.m b/SOGo/UI/Scheduler/NSCalendarDate+UIx.m new file mode 100644 index 00000000..53c4647f --- /dev/null +++ b/SOGo/UI/Scheduler/NSCalendarDate+UIx.m @@ -0,0 +1,50 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo 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 + 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 + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +// $Id: UIxAppointmentEditor.m 181 2004-08-11 15:13:25Z helge $ + +#include "NSCalendarDate+UIx.h" +#include "common.h" + +@implementation NSCalendarDate(UIx) + +- (NSCalendarDate *)dayOfWeeK:(unsigned)_day + offsetFromSunday:(unsigned)_offset +{ + unsigned dayOfWeek, distance; + + /* perform "locale" correction */ + dayOfWeek = (7 + [self dayOfWeek] - _offset) % 7; + + _day = (_day % 7); + if(_day == dayOfWeek) + return self; + + distance = _day - dayOfWeek; + return [self dateByAddingYears:0 months:0 days:distance]; +} + +/* this implies that monday is the start of week! */ + +- (NSCalendarDate *)sundayOfWeek { + return [self dayOfWeeK:6 offsetFromSunday:1]; +} + +@end /* NSCalendarDate(UIx) */ diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.m b/SOGo/UI/Scheduler/UIxAppointmentEditor.m index c62b8831..c7954755 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.m +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.m @@ -136,7 +136,7 @@ - (SOGoAppointment *)appointment { - if(self->appointment == nil) { + if (self->appointment == nil) { self->appointment = [[SOGoAppointment alloc] initWithICalString:[self iCalString]]; } @@ -210,9 +210,10 @@ /* helper */ - (NSString *)uriAsFormat { + // TODO: replace that with "-uriToCallMethodNamed:" or sth like this NSString *uri, *qp; - NSRange r; - + NSRange r; + uri = [[[self context] request] uri]; /* first: identify query parameters */ @@ -237,7 +238,7 @@ /* next: append format token */ uri = [uri stringByAppendingString:@"%@"]; - if(qp != nil) + if (qp != nil) uri = [uri stringByAppendingString:qp]; return uri; } @@ -245,7 +246,6 @@ /* new */ - - (id)newAction { /* This method creates a unique ID and redirects to the "edit" method on the @@ -254,8 +254,6 @@ Note: 'clientObject' is the SOGoAppointmentFolder! */ - WORequest *req; - WOResponse *r; NSString *uri, *uriFormat, *objectId, *nextMethod; objectId = [NSClassFromString(@"SOGoAppointmentFolder") @@ -263,26 +261,21 @@ nextMethod = [NSString stringWithFormat:@"%@/edit", objectId]; uriFormat = [self uriAsFormat]; - uri = [[NSString alloc] initWithFormat:uriFormat, nextMethod]; - req = [[self context] request]; - r = [WOResponse responseWithRequest:req]; - [r setStatus:302 /* moved */]; - [r setHeader:uri forKey:@"location"]; - [uri release]; uri = nil; - return r; + uri = [NSString stringWithFormat:uriFormat, nextMethod]; + + return [self redirectToLocation:uri]; } - /* save */ /* returned dates are in GMT */ - (NSCalendarDate *)_dateFromString:(NSString *)_str { - NSCalendarDate *date; - - date = [NSCalendarDate dateWithString:_str - calendarFormat:@"%Y-%m-%d %H:%M %Z"]; - [date setTimeZone:[self backendTimeZone]]; - return date; + NSCalendarDate *date; + + date = [NSCalendarDate dateWithString:_str + calendarFormat:@"%Y-%m-%d %H:%M %Z"]; + [date setTimeZone:[self backendTimeZone]]; + return date; } - (id)saveAction { @@ -292,9 +285,8 @@ NSCalendarDate *sd, *ed; NSArray *ps; unsigned i, count; - WOResponse *r; WORequest *req; - + req = [[self context] request]; /* get iCalString from hidden input */ @@ -347,9 +339,6 @@ iCalString = [apt iCalString]; [apt release]; apt = nil; -#if 0 - NSLog(@"%s new iCalString:\n%@", __PRETTY_FUNCTION__, iCalString); -#else { NSException *ex; @@ -357,15 +346,10 @@ if (ex) return ex; // TODO: add some error handling in form! (eg like in Zope) } -#endif uriFormat = [self uriAsFormat]; uri = [NSString stringWithFormat:uriFormat, @"view"]; - - r = [WOResponse responseWithRequest:req]; - [r setStatus:302 /* moved */]; - [r setHeader:uri forKey:@"location"]; - return r; + return [self redirectToLocation:uri]; } @end /* UIxAppointmentEditor */ diff --git a/SOGo/UI/Scheduler/UIxAppointmentView.m b/SOGo/UI/Scheduler/UIxAppointmentView.m index 241fef8a..46d653d7 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentView.m +++ b/SOGo/UI/Scheduler/UIxAppointmentView.m @@ -2,6 +2,7 @@ #include "UIxAppointmentView.h" #include "common.h" +#include #include @implementation UIxAppointmentView @@ -45,10 +46,10 @@ if (self->appointment) return self->appointment; - + iCalString = [[self clientObject] valueForKey:@"iCalString"]; - if ([iCalString length] == 0) { - [self logWithFormat:@"ERROR(%s): missing iCal string!", + if (![iCalString isNotNull] || [iCalString length] == 0) { + [self debugWithFormat:@"ERROR(%s): missing iCal string!", __PRETTY_FUNCTION__]; return nil; } @@ -89,21 +90,32 @@ } - (NSString *)debugTabLink { - return [self completeHrefForMethod:[self ownMethodName] - withParameter:@"debug" - forKey:@"tab"]; + return [self completeHrefForMethod:[self ownMethodName] + withParameter:@"debug" + forKey:@"tab"]; } - (NSString *)completeHrefForMethod:(NSString *)_method withParameter:(NSString *)_param forKey:(NSString *)_key { - NSString *href; + NSString *href; - [self setQueryParameter:_param forKey:_key]; - href = [self completeHrefForMethod:[self ownMethodName]]; - [self setQueryParameter:nil forKey:_key]; - return href; + [self setQueryParameter:_param forKey:_key]; + href = [self completeHrefForMethod:[self ownMethodName]]; + [self setQueryParameter:nil forKey:_key]; + return href; +} + +/* action */ + +- (id)defaultAction { + if ([self appointment] == nil) { + return [NSException exceptionWithHTTPStatus:404 /* Not Found */ + reason:@"could not locate appointment"]; + } + + return self; } @end /* UIxAppointmentView */ diff --git a/SOGo/UI/Scheduler/UIxCalMonthView.m b/SOGo/UI/Scheduler/UIxCalMonthView.m index 05649862..ef2ea81c 100644 --- a/SOGo/UI/Scheduler/UIxCalMonthView.m +++ b/SOGo/UI/Scheduler/UIxCalMonthView.m @@ -1,43 +1,13 @@ // $Id$ #include "UIxCalMonthView.h" -#include +#include "NSCalendarDate+UIx.h" #include "common.h" - -@interface NSCalendarDate (UIxCalMonthViewExtensions) -- (NSCalendarDate *)dayOfWeeK:(unsigned)_day - offsetFromSunday:(unsigned)_offset; -- (NSCalendarDate *)sundayOfWeek; -@end - -@implementation NSCalendarDate (UIxCalMonthViewExtensions) -- (NSCalendarDate *)dayOfWeeK:(unsigned)_day - offsetFromSunday:(unsigned)_offset -{ - unsigned dayOfWeek, distance; - - /* perform "locale" correction */ - dayOfWeek = (7 + [self dayOfWeek] - _offset) % 7; - - _day = (_day % 7); - if(_day == dayOfWeek) - return self; - - distance = _day - dayOfWeek; - return [self dateByAddingYears:0 months:0 days:distance]; -} - -/* this implies that monday is the start of week! */ -- (NSCalendarDate *)sundayOfWeek { - return [self dayOfWeeK:6 offsetFromSunday:1]; -} -@end - @implementation UIxCalMonthView - (NSCalendarDate *)startOfMonth { - return [[[super startDate] firstDayOfMonth] beginOfDay]; + return [[[super startDate] firstDayOfMonth] beginOfDay]; } - (NSCalendarDate *)startDate { @@ -45,42 +15,31 @@ } - (NSCalendarDate *)endDate { - NSCalendarDate *date = [self startOfMonth]; - date = [date dateByAddingYears:0 - months:0 - days:[date numberOfDaysInMonth] - hours:0 - minutes:0 - seconds:0]; + NSCalendarDate *date; + + date = [self startOfMonth]; + date = [date dateByAddingYears:0 months:0 days:[date numberOfDaysInMonth] + hours:0 minutes:0 seconds:0]; date = [[date sundayOfWeek] endOfDay]; return date; } /* URLs */ - - (NSDictionary *)prevMonthQueryParameters { - NSCalendarDate *date; + NSCalendarDate *date; - date = [[self startOfMonth] dateByAddingYears:0 - months:-1 - days:0 - hours:0 - minutes:0 - seconds:0]; - return [self queryParametersBySettingSelectedDate:date]; + date = [[self startOfMonth] dateByAddingYears:0 months:-1 days:0 + hours:0 minutes:0 seconds:0]; + return [self queryParametersBySettingSelectedDate:date]; } - (NSDictionary *)nextMonthQueryParameters { - NSCalendarDate *date; + NSCalendarDate *date; - date = [[self startOfMonth] dateByAddingYears:0 - months:1 - days:0 - hours:0 - minutes:0 - seconds:0]; - return [self queryParametersBySettingSelectedDate:date]; + date = [[self startOfMonth] dateByAddingYears:0 months:1 days:0 + hours:0 minutes:0 seconds:0]; + return [self queryParametersBySettingSelectedDate:date]; } @end /* UIxCalMonthView */ diff --git a/SOGo/UI/Scheduler/UIxCalSelectTab.wox b/SOGo/UI/Scheduler/UIxCalSelectTab.wox index 98ae502c..d253e366 100644 --- a/SOGo/UI/Scheduler/UIxCalSelectTab.wox +++ b/SOGo/UI/Scheduler/UIxCalSelectTab.wox @@ -10,16 +10,16 @@ const:selectedTabStyle="tab_selected" const:bodyStyle="tabview_body" > - + - - + + - - + + - - + + - + diff --git a/SOGo/UI/Scheduler/UIxCalView.h b/SOGo/UI/Scheduler/UIxCalView.h index e53a4229..d5bbff95 100644 --- a/SOGo/UI/Scheduler/UIxCalView.h +++ b/SOGo/UI/Scheduler/UIxCalView.h @@ -5,13 +5,20 @@ #include -@class NSArray, NSCalendarDate; +/* + UIxCalView + + Superclass for most components which render a set of appointments coming from + a SOPE clientObject (which usually is an SOGoAppointmentFolder). +*/ + +@class NSString, NSArray, NSDictionary, NSCalendarDate; @interface UIxCalView : UIxComponent { - NSArray *appointments; - NSArray *allDayApts; - id appointment; + NSArray *appointments; + NSArray *allDayApts; + id appointment; NSCalendarDate *currentDay; } @@ -60,11 +67,12 @@ - (NSArray *)fetchCoreInfos; /* date selection */ + - (NSDictionary *)todayQueryParameters; - (NSDictionary *)currentDayQueryParameters; - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date; - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate - inDictionary:(NSMutableDictionary *)_qp; + inDictionary:(NSMutableDictionary *)_qp; @end diff --git a/SOGo/UI/Scheduler/UIxCalView.m b/SOGo/UI/Scheduler/UIxCalView.m index f153fc36..3da61309 100644 --- a/SOGo/UI/Scheduler/UIxCalView.m +++ b/SOGo/UI/Scheduler/UIxCalView.m @@ -188,25 +188,24 @@ /* defaults */ - - (BOOL)showFullNames { - return YES; + return YES; } - (BOOL)showAMPMDates { - return NO; + return NO; } - (unsigned)dayStartHour { - return 8; + return 8; } - (unsigned)dayEndHour { - return 18; + return 18; } - (BOOL)shouldDisplayWeekend { - return NO; + return NO; } @@ -215,10 +214,12 @@ - (NSString *)appointmentViewURL { id pkey; - if ((pkey = [[self appointment] valueForKey:@"uid"]) == nil) + if (![(pkey = [[self appointment] valueForKey:@"uid"]) isNotNull]) return nil; - return [NSString stringWithFormat:@"%@/view", pkey]; + return [[[self clientObject] baseURLForAptWithUID:[pkey stringValue] + inContext:[self context]] + stringByAppendingString:@"/view"]; } @@ -227,6 +228,7 @@ /* resource URLs (TODO?) */ - (NSString *)resourcePath { + // TODO: broken return @"/sogod.woa/WebServerResources/"; } @@ -389,47 +391,44 @@ /* Actions */ - (NSString *)_userFolderURI { - WOContext *ctx; - id obj; - NSURL *url; + WOContext *ctx; + id obj; + NSURL *url; - ctx = [self context]; - obj = [[ctx objectTraversalStack] objectAtIndex:1]; - url = [NSURL URLWithString:[obj baseURLInContext:ctx]]; - return [url path]; + ctx = [self context]; + obj = [[ctx objectTraversalStack] objectAtIndex:1]; + url = [NSURL URLWithString:[obj baseURLInContext:ctx]]; + return [url path]; } - (id)redirectForUIDsAction { - NSMutableString *uri; - NSString *uidsString, *loc, *prevMethod; - WOResponse *r; - WORequest *req; - - req = [[self context] request]; - - uidsString = [req formValueForKey:@"anaisUIDString"]; - uidsString = [uidsString stringByTrimmingWhiteSpaces]; - if([uidsString length] == 0) { - // TODO: improve user experience ... (eg error panel like Zope) - return [NSException exceptionWithHTTPStatus:400 /* bad request */ - reason:@"missing uids from request"]; - } - prevMethod = [req formValueForKey:@"previousMethod"]; - if(prevMethod == nil) - prevMethod = @""; - - uri = [[NSMutableString alloc] initWithString:[self _userFolderURI]]; - [uri appendString:@"/Groups/_custom_"]; - [uri appendString:uidsString]; - [uri appendString:@"/Calendar/"]; - [uri appendString:prevMethod]; - - loc = [self completeHrefForMethod:uri]; /* this might return uri! */ - r = [WOResponse responseWithRequest:req]; - [r setStatus:302 /* moved */]; - [r setHeader:loc forKey:@"location"]; - [uri release]; - return r; + NSMutableString *uri; + NSString *uidsString, *loc, *prevMethod; + WORequest *req; + + req = [[self context] request]; + + uidsString = [req formValueForKey:@"anaisUIDString"]; + uidsString = [uidsString stringByTrimmingWhiteSpaces]; + if ([uidsString length] == 0) { + // TODO: improve user experience ... (eg error panel like Zope) + return [NSException exceptionWithHTTPStatus:400 /* bad request */ + reason:@"missing uids from request"]; + } + + prevMethod = [req formValueForKey:@"previousMethod"]; + if (prevMethod == nil) + prevMethod = @""; + + uri = [[NSMutableString alloc] initWithString:[self _userFolderURI]]; + [uri appendString:@"/Groups/_custom_"]; + [uri appendString:uidsString]; + [uri appendString:@"/Calendar/"]; + [uri appendString:prevMethod]; + + loc = [self completeHrefForMethod:uri]; /* this might return uri! */ + + return [self redirectToLocation:loc]; } @end /* UIxCalView */ diff --git a/SOGo/UI/Scheduler/UIxCalWeekChartview.m b/SOGo/UI/Scheduler/UIxCalWeekChartview.m index 449c0de1..cd63bcab 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekChartview.m +++ b/SOGo/UI/Scheduler/UIxCalWeekChartview.m @@ -22,16 +22,15 @@ #include "UIxCalWeekView.h" -#include "common.h" @interface UIxCalWeekChartview : UIxCalWeekView { - } @end +#include "common.h" @implementation UIxCalWeekChartview +@end /* UIxCalWeekChartview */ -@end diff --git a/SOGo/UI/Scheduler/UIxCalWeekColumnsview.m b/SOGo/UI/Scheduler/UIxCalWeekColumnsview.m index d9c121be..975291a9 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekColumnsview.m +++ b/SOGo/UI/Scheduler/UIxCalWeekColumnsview.m @@ -22,58 +22,56 @@ #include "UIxCalWeekView.h" -#include "common.h" @interface UIxCalWeekColumnsview : UIxCalWeekView { - int dayIndex; + int dayIndex; } @end +#include "common.h" @implementation UIxCalWeekColumnsview - (NSArray *)appointments { - return [self fetchCoreInfos]; + return [self fetchCoreInfos]; } - (void)setDayIndex:(char)_idx { - NSCalendarDate *d; + NSCalendarDate *d; - if ((self->dayIndex == _idx) && (self->currentDay != nil)) - return; + if ((self->dayIndex == _idx) && (self->currentDay != nil)) + return; - self->dayIndex = _idx; + self->dayIndex = _idx; - if (_idx > 0) { - d = [[self startDate] - dateByAddingYears:0 months:0 days:_idx - hours:0 minutes:0 seconds:0]; - } - else - d = [self startDate]; + if (_idx > 0) { + d = [[self startDate] dateByAddingYears:0 months:0 days:_idx + hours:0 minutes:0 seconds:0]; + } + else + d = [self startDate]; - [self setCurrentDay:d]; + [self setCurrentDay:d]; } - (int)dayIndex { - return self->dayIndex; + return self->dayIndex; } /* style sheet */ - (NSString *)titleStyle { - if([self->currentDay isToday]) - return @"weekcolumnsview_title_hilite"; - return @"weekcolumnsview_title"; + return [self->currentDay isToday] + ? @"weekcolumnsview_title_hilite" + : @"weekcolumnsview_title"; } - - (NSString *)contentStyle { - if([self->currentDay isToday]) - return @"weekcolumnsview_content_hilite"; - return @"weekcolumnsview_content"; + return [self->currentDay isToday] + ? @"weekcolumnsview_content_hilite" + : @"weekcolumnsview_content"; } -@end +@end /* UIxCalWeekColumnsview */ diff --git a/SOGo/UI/Scheduler/UIxCalWeekPrintview.m b/SOGo/UI/Scheduler/UIxCalWeekPrintview.m index 76ab3d69..ddf9056f 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekPrintview.m +++ b/SOGo/UI/Scheduler/UIxCalWeekPrintview.m @@ -20,10 +20,8 @@ */ // $Id$ - #include "UIxCalWeekOverview.h" - @interface UIxCalWeekPrintview : UIxCalWeekOverview { } diff --git a/SOGo/UI/Scheduler/UIxCalWeekView.h b/SOGo/UI/Scheduler/UIxCalWeekView.h index e867846c..df8a196d 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekView.h +++ b/SOGo/UI/Scheduler/UIxCalWeekView.h @@ -5,6 +5,8 @@ #include "UIxCalView.h" +@class NSDictionary; + @interface UIxCalWeekView : UIxCalView { } diff --git a/SOGo/UI/Scheduler/UIxCalWeekView.m b/SOGo/UI/Scheduler/UIxCalWeekView.m index 43303b09..92d2bf1e 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekView.m +++ b/SOGo/UI/Scheduler/UIxCalWeekView.m @@ -1,7 +1,6 @@ // $Id$ #include "UIxCalWeekView.h" -#include #include "common.h" @implementation UIxCalWeekView @@ -12,26 +11,26 @@ - (NSCalendarDate *)endDate { return [[[self startDate] dateByAddingYears:0 months:0 days:7 - hours:0 minutes:0 seconds:0] + hours:0 minutes:0 seconds:0] endOfDay]; } /* URLs */ - (NSDictionary *)prevWeekQueryParameters { - NSCalendarDate *date; + NSCalendarDate *date; - date = [[self startDate] dateByAddingYears:0 months:0 days:-7 - hours:0 minutes:0 seconds:0]; - return [self queryParametersBySettingSelectedDate:date]; + date = [[self startDate] dateByAddingYears:0 months:0 days:-7 + hours:0 minutes:0 seconds:0]; + return [self queryParametersBySettingSelectedDate:date]; } - (NSDictionary *)nextWeekQueryParameters { - NSCalendarDate *date; + NSCalendarDate *date; - date = [[self startDate] dateByAddingYears:0 months:0 days:7 - hours:0 minutes:0 seconds:0]; - return [self queryParametersBySettingSelectedDate:date]; + date = [[self startDate] dateByAddingYears:0 months:0 days:7 + hours:0 minutes:0 seconds:0]; + return [self queryParametersBySettingSelectedDate:date]; } @end /* UIxCalWeekView */ diff --git a/SOGo/UI/Scheduler/UIxCalYearOverview.m b/SOGo/UI/Scheduler/UIxCalYearOverview.m index 16a8e71d..207a151e 100644 --- a/SOGo/UI/Scheduler/UIxCalYearOverview.m +++ b/SOGo/UI/Scheduler/UIxCalYearOverview.m @@ -20,146 +20,130 @@ */ // $Id$ - #include -#include -#include - @interface UIxCalYearOverview : UIxComponent { - NSArray *row; - NSCalendarDate *month; + NSArray *row; + NSCalendarDate *month; } - (NSCalendarDate *)startDate; + - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date; + - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate - inDictionary:(NSMutableDictionary *)_qp; + inDictionary:(NSMutableDictionary *)_qp; @end +#include "common.h" @implementation UIxCalYearOverview -/* init & dealloc */ - - (void)dealloc { [self->row release]; [self->month release]; [super dealloc]; } - /* accessors */ - (void)setRow:(NSArray *)_row { - ASSIGN(self->row, _row); + ASSIGN(self->row, _row); } - - (NSArray *)row { - return self->row; + return self->row; } - (void)setMonth:(NSCalendarDate *)_date { - ASSIGN(self->month, _date); + ASSIGN(self->month, _date); } - - (NSCalendarDate *)month { - return self->month; + return self->month; } - (int)year { - return [[self selectedDate] yearOfCommonEra]; + return [[self selectedDate] yearOfCommonEra]; } - (NSArray *)arrayOfDateArrays { - NSCalendarDate *startDate; - NSMutableArray *result, *tmp; - unsigned rowIdx, columnIdx; - int monthOffset = 0; - - startDate = [self startDate]; - result = [[NSMutableArray alloc] initWithCapacity:3]; - for(rowIdx = 0; rowIdx < 3; rowIdx++) { - tmp = [[NSMutableArray alloc] initWithCapacity:4]; - for(columnIdx = 0; columnIdx < 4; columnIdx++) { - NSCalendarDate *date; - - date = [startDate dateByAddingYears:0 - months:monthOffset - days:0]; - [tmp addObject:date]; - monthOffset++; - } - [result addObject:tmp]; - [tmp release]; + NSCalendarDate *startDate; + NSMutableArray *result, *tmp; + unsigned rowIdx, columnIdx; + int monthOffset = 0; + + startDate = [self startDate]; + result = [NSMutableArray arrayWithCapacity:3]; + + for (rowIdx = 0; rowIdx < 3; rowIdx++) { + tmp = [[NSMutableArray alloc] initWithCapacity:4]; + + for (columnIdx = 0; columnIdx < 4; columnIdx++) { + NSCalendarDate *date; + + date = [startDate dateByAddingYears:0 months:monthOffset days:0]; + [tmp addObject:date]; + monthOffset++; } - return [result autorelease]; + [result addObject:tmp]; + [tmp release]; + } + return result; } /* date ranges */ - (NSCalendarDate *)startDate { - return [[[NSCalendarDate alloc] initWithYear:[self year] month:1 day:1 - hour:0 minute:0 second:0 - timeZone:[self viewTimeZone]] autorelease]; + return [[[NSCalendarDate alloc] initWithYear:[self year] month:1 day:1 + hour:0 minute:0 second:0 + timeZone:[self viewTimeZone]] autorelease]; } - - (NSCalendarDate *)endDate { - return nil; + return nil; } - /* URLs */ - (NSDictionary *)todayQueryParameters { - NSCalendarDate *date; + NSCalendarDate *date; - date = [NSCalendarDate date]; /* today */ - return [self queryParametersBySettingSelectedDate:date]; + date = [NSCalendarDate date]; /* today */ + return [self queryParametersBySettingSelectedDate:date]; } -- (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date { - NSMutableDictionary *qp; +- (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date{ + NSMutableDictionary *qp; - qp = [[self queryParameters] mutableCopy]; - [self setSelectedDateQueryParameter:_date inDictionary:qp]; - return [qp autorelease]; + qp = [[self queryParameters] mutableCopy]; + [self setSelectedDateQueryParameter:_date inDictionary:qp]; + return [qp autorelease]; } - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate - inDictionary:(NSMutableDictionary *)_qp; + inDictionary:(NSMutableDictionary *)_qp; { - if(_newDate != nil) - [_qp setObject:[self dateStringForDate:_newDate] forKey:@"day"]; - else - [_qp removeObjectForKey:@"day"]; + if (_newDate != nil) + [_qp setObject:[self dateStringForDate:_newDate] forKey:@"day"]; + else + [_qp removeObjectForKey:@"day"]; } - (NSDictionary *)prevYearQueryParameters { - NSCalendarDate *date; + NSCalendarDate *date; - date = [[self startDate] dateByAddingYears:-1 - months:0 - days:0 - hours:0 - minutes:0 - seconds:0]; - return [self queryParametersBySettingSelectedDate:date]; + date = [[self startDate] dateByAddingYears:-1 months:0 days:0 + hours:0 minutes:0 seconds:0]; + return [self queryParametersBySettingSelectedDate:date]; } - (NSDictionary *)nextYearQueryParameters { - NSCalendarDate *date; - - date = [[self startDate] dateByAddingYears:1 - months:0 - days:0 - hours:0 - minutes:0 - seconds:0]; - return [self queryParametersBySettingSelectedDate:date]; + NSCalendarDate *date; + + date = [[self startDate] dateByAddingYears:1 months:0 days:0 + hours:0 minutes:0 seconds:0]; + return [self queryParametersBySettingSelectedDate:date]; } -@end +@end /* UIxCalYearOverview */ diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index 49f242e5..78237daf 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=21 +SUBMINOR_VERSION:=22 -- 2.39.5