]> err.no Git - scalable-opengroupware.org/commitdiff
see changelog
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 30 Jun 2004 01:07:58 +0000 (01:07 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 30 Jun 2004 01:07:58 +0000 (01:07 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@90 d1b88da0-ebda-0310-925b-ed51d893ca5b

ZideStore/UI-X/ChangeLog
ZideStore/UI-X/Scheduler/UIxAppointmentEditor.m
ZideStore/UI-X/Scheduler/UIxAppointmentEditor.wox

index 4e9ebe71ef26df61da310fdeca203eb08aa572d4..f8c8667dab03119b99a8e6ed7345735b040255a7 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-30  Marcus Müller  <znek@mulle-kybernetik.com>
+
+       * 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  <helge.hess@opengroupware.org>
 
        * Scheduler/UIxAppointmentEditor.m: made the hack more hackish to work
index 6239cb0cf9bebc560d33e1a37f6b46395735f083..5d1ef100362e9ae94f6ceac133f4ac17f100318d 100644 (file)
@@ -63,6 +63,7 @@
 
 - (SOGoAppointment *)appointment;
 - (NSString *)iCalStringTemplate;
+- (NSString *)iCalString;
 - (BOOL)isNewAppointment;
 
 @end
     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;
 }
     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 */
 
 
 
 - (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 */];
index 12b699eae28bf65e611fc77ee1ca0044afc1f743..ce2381aad302514d5074c1ddfb365f04817e13a6 100644 (file)
   <tr>
     <td>
         <input type="submit" value="Save" />
-        <input type="hidden" name="ical" var:value="appointment.iCalString" />
+        <input type="hidden" name="ical" var:value="iCalString" />
     </td>
   </tr>
   </table>