From 45638bced11e8ba29462f4e288e0198c75459d8d Mon Sep 17 00:00:00 2001 From: znek Date: Wed, 30 Jun 2004 01:07:58 +0000 Subject: [PATCH] see changelog git-svn-id: http://svn.opengroupware.org/SOGo/trunk@90 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ZideStore/UI-X/ChangeLog | 6 + .../UI-X/Scheduler/UIxAppointmentEditor.m | 130 ++++++++++++------ .../UI-X/Scheduler/UIxAppointmentEditor.wox | 2 +- 3 files changed, 97 insertions(+), 41 deletions(-) diff --git a/ZideStore/UI-X/ChangeLog b/ZideStore/UI-X/ChangeLog index 4e9ebe71..f8c8667d 100644 --- a/ZideStore/UI-X/ChangeLog +++ b/ZideStore/UI-X/ChangeLog @@ -1,3 +1,9 @@ +2004-06-30 Marcus Müller + + * Scheduler/UIxAppointmentEditor.m: improved -saveAction. Does + everything in a complete manner now - except for saving which isn't + done at all. + 2004-06-30 Helge Hess * Scheduler/UIxAppointmentEditor.m: made the hack more hackish to work diff --git a/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.m b/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.m index 6239cb0c..5d1ef100 100644 --- a/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.m +++ b/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.m @@ -63,6 +63,7 @@ - (SOGoAppointment *)appointment; - (NSString *)iCalStringTemplate; +- (NSString *)iCalString; - (BOOL)isNewAppointment; @end @@ -91,21 +92,44 @@ return ! [[self clientObject] isAppointment]; } +- (NSString *)iCalString { + if([self isNewAppointment]) { + return [self iCalStringTemplate]; + } + else { + return [[self clientObject] valueForKey:@"iCalString"]; + } +} + +- (NSString *)iCalStringTemplate { + static NSString *iCalStringTemplate = \ + @"BEGIN:VCALENDAR\nMETHOD:REQUEST\nPRODID:OpenGroupware.org ZideStore 1.2\n" \ + @"VERSION:2.0\nBEGIN:VEVENT\nCLASS:PRIVATE\nSTATUS:CONFIRMED\n" \ + @"DTSTART:%@\nDTEND:%@\n" \ + @"TRANSP:OPAQUE\n" \ + @"END:VEVENT\nEND:VCALENDAR"; + NSCalendarDate *startDate, *endDate; + NSString *template; + + startDate = [self selectedDate]; + endDate = [startDate dateByAddingYears:0 months:0 days:0 + hours:1 minutes:0 seconds:0]; + + template = [NSString stringWithFormat:iCalStringTemplate, + [startDate icalString], + [endDate icalString]]; + + return template; +} + + /* backend */ - (SOGoAppointment *)appointment { if(self->appointment == nil) { - NSString *iCalString; - - if([[self clientObject] isAppointment]) { - iCalString = [[self clientObject] valueForKey:@"iCalString"]; - } - else { - iCalString = [self iCalStringTemplate]; - } self->appointment = [[SOGoAppointment alloc] - initWithICalString:iCalString]; + initWithICalString:[self iCalString]]; } return self->appointment; } @@ -133,28 +157,6 @@ return self->participants; } -- (NSString *)iCalStringTemplate { - static NSString *iCalStringTemplate = \ - @"BEGIN:VCALENDAR\nMETHOD:REQUEST\nPRODID:OpenGroupware.org ZideStore 1.2\n" \ - @"VERSION:2.0\nBEGIN:VEVENT\nCLASS:PRIVATE\nSTATUS:CONFIRMED\n" \ - @"DTSTART:%@\nDTEND:%@\n" \ - @"TRANSP:OPAQUE\n" \ - @"END:VEVENT\nEND:VCALENDAR"; - NSCalendarDate *startDate, *endDate; - NSString *template; - - startDate = [self selectedDate]; - endDate = [startDate dateByAddingYears:0 months:0 days:0 - hours:1 minutes:0 seconds:0]; - - - template = [NSString stringWithFormat:iCalStringTemplate, - [startDate icalString], - [endDate icalString]]; - - return template; -} - /* helper */ @@ -198,25 +200,73 @@ - (id)saveAction { - NSString *foo, *nextMethod, *uri, *uriFormat; - NSMutableArray *attendees; + SOGoAppointment *apt; + NSString *iCalString, *summary, *location, *nextMethod, *uri, *uriFormat; + NSCalendarDate *sd, *ed; + NSArray *ps; + unsigned i, count; WOResponse *r; WORequest *req; req = [[self context] request]; - foo = [req formValueForKey:@"ical"]; - if([self isNewAppointment]) + /* get iCalString from hidden input */ + iCalString = [req formValueForKey:@"ical"]; + apt = [[SOGoAppointment alloc] initWithICalString:iCalString]; + + /* merge in form values */ + sd = [NSCalendarDate dateWithString:[req formValueForKey:@"startDate"] + calendarFormat:@"%Y-%m-%d %H:%M"]; + [apt setStartDate:sd]; + ed = [NSCalendarDate dateWithString:[req formValueForKey:@"endDate"] + calendarFormat:@"%Y-%m-%d %H:%M"]; + [apt setEndDate:ed]; + summary = [req formValueForKey:@"summary"]; + [apt setSummary:title]; + location = [req formValueForKey:@"location"]; + [apt setLocation:location]; + + [apt removeAllAttendees]; /* clean up */ + ps = [[req formValueForKey:@"participants"] + componentsSeparatedByString:@"\n"]; + count = [ps count]; + for(i = 0; i < count; i++) { + NSString *email; + + email = [ps objectAtIndex:i]; + if([email length] > 0) { + iCalPerson *p; + NSRange cnr; + + p = [[iCalPerson alloc] init]; + [p setEmail:[NSString stringWithFormat:@"mailto:%@", email]]; + /* construct a fake CN */ + cnr = [email rangeOfString:@"@"]; + if(cnr.location != NSNotFound) { + [p setCn:[email substringToIndex:cnr.location]]; + } + [apt addToAttendees:p]; + [p release]; + } + } + + /* receive current representation for save operation */ + iCalString = [apt iCalString]; + [apt release]; + + + /* determine what's to do and where to go next */ + if([self isNewAppointment]) { nextMethod = @"duhduh"; - else + } + else { nextMethod = @"view"; + } + + NSLog(@"%s new iCalString:\n%@", __PRETTY_FUNCTION__, iCalString); uriFormat = [self uriAsFormat]; uri = [NSString stringWithFormat:uriFormat, nextMethod]; - NSLog(@"%s got foo:%@, redirecting to '%@'", - __PRETTY_FUNCTION__, - foo, - uri); r = [WOResponse responseWithRequest:req]; [r setStatus:302 /* moved */]; diff --git a/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.wox b/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.wox index 12b699ea..ce2381aa 100644 --- a/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.wox +++ b/ZideStore/UI-X/Scheduler/UIxAppointmentEditor.wox @@ -100,7 +100,7 @@ - + -- 2.39.5