From: znek Date: Fri, 13 Aug 2004 14:06:17 +0000 (+0000) Subject: enhancements X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f9b3d33df1fdfab88e674cfd14b32fa16fefc8e;p=scalable-opengroupware.org enhancements git-svn-id: http://svn.opengroupware.org/SOGo/trunk@199 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 8706d704..d0dd351e 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,14 @@ +2004-08-13 Marcus Mueller + + * v0.9.28 + + * iCalPerson+UIx.[hm]: more convenience + + * UIxAppointmentView.[hm]: display CN's as Names + + * UIxAppointmentEditor.[wox|m]: more functionality, but still + unfinished. You can use it to test appointments, though. + 2004-08-13 Helge Hess * UIxAppointmentEditor.wox: fixed base URL of form not to include diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.m b/SOGo/UI/Scheduler/UIxAppointmentEditor.m index 07ecdbb9..169a123d 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.m +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.m @@ -31,12 +31,15 @@ { id appointment; id participants; + id item; } - (SOGoAppointment *)appointment; - (NSString *)iCalStringTemplate; - (NSString *)iCalString; +- (NSString *)_completeURIForMethod:(NSString *)_method; + @end #include @@ -66,11 +69,19 @@ - (void)dealloc { [self->appointment release]; [self->participants release]; + [self->item release]; [super dealloc]; } /* accessors */ +- (void)setItem:(id)_item { + ASSIGN(self->item, _item); +} +- (id)item { + return self->item; +} + - (NSString *)formattedAptStartTime { NSCalendarDate *date; SOGoDateFormatter *fmt; @@ -143,29 +154,18 @@ return self->appointment; } -- (id)participants { - NSArray *attendees; - NSMutableArray *emailAddresses; - unsigned i, count; - - if (self->participants) - return self->participants; +- (BOOL)hasParticipants { + return [[self participants] count] != 0; +} - attendees = [self->appointment attendees]; - count = [attendees count]; - emailAddresses = [[NSMutableArray alloc] initWithCapacity:count]; - for (i = 0; i < count; i++) { - NSString *email; - - email = [[attendees objectAtIndex:i] rfc822Email]; - if (email) - [emailAddresses addObject:email]; - } - - self->participants = - [[emailAddresses componentsJoinedByString:@"\n"] copy]; - [emailAddresses release]; - return self->participants; +- (NSArray *)participants { +#warning TODO: FILTER ROLE! + return [self->appointment attendees]; +} + +- (NSArray *)resources { +#warning TODO: FILTER ROLE! + return [self->appointment attendees]; } @@ -186,7 +186,7 @@ @" checkbox = document.createElement('input');" @" checkbox.setAttribute('type', 'checkbox');" @" checkbox.setAttribute('checked', 'checked');" - @" checkbox.setAttribute('value', email);" + @" checkbox.setAttribute('value', email + ';' + cn);" @" checkbox.setAttribute('id', email);" @" checkbox.setAttribute('name', tableId);" @" td.appendChild(checkbox);" @@ -209,38 +209,38 @@ /* helper */ -- (NSString *)uriAsFormat { - // TODO: replace that with "-uriToCallMethodNamed:" or sth like this - NSString *uri, *qp; - NSRange r; - - uri = [[[self context] request] uri]; - - /* first: identify query parameters */ - r = [uri rangeOfString:@"?" options:NSBackwardsSearch]; - if (r.length > 0) { - qp = [uri substringFromIndex:r.location]; - uri = [uri substringToIndex:r.location]; - } - else - qp = nil; +- (NSString *)_completeURIForMethod:(NSString *)_method { + NSString *uri; + NSRange r; + + uri = [[[self context] request] uri]; + + /* first: identify query parameters */ + r = [uri rangeOfString:@"?" options:NSBackwardsSearch]; + if(r.length > 0) + uri = [uri substringToIndex:r.location]; + + /* next: append trailing slash */ + if(![uri hasSuffix:@"/"]) + uri = [uri stringByAppendingString:@"/"]; - /* next: strip trailing slash */ - if ([uri hasSuffix:@"/"]) - uri = [uri substringToIndex:([uri length] - 1)]; - r = [uri rangeOfString:@"/" options:NSBackwardsSearch]; + /* next: append method */ + uri = [uri stringByAppendingString:_method]; - /* then: cut of last path component */ - if (r.length == 0) // no slash? are we at root? - uri = @"/"; - else - uri = [uri substringToIndex:(r.location + 1)]; - - /* next: append format token */ - uri = [uri stringByAppendingString:@"%@"]; - if (qp != nil) - uri = [uri stringByAppendingString:qp]; - return uri; + /* next: append query parameters */ + return [self completeHrefForMethod:uri]; +} + +/* HACK: this is for agenor only */ +- (NSString *)emailForUser { + NSString *uid; + NSRange r; + + uid = [[self user] login]; + r = [uid rangeOfString:@"@"]; + if(r.length > 0) + return uid; + return [NSString stringWithFormat:@"%@@equipement.gouv.fr", uid]; } @@ -254,15 +254,13 @@ Note: 'clientObject' is the SOGoAppointmentFolder! */ - NSString *uri, *uriFormat, *objectId, *nextMethod; + NSString *uri, *objectId, *nextMethod; objectId = [NSClassFromString(@"SOGoAppointmentFolder") globallyUniqueObjectId]; - nextMethod = [NSString stringWithFormat:@"%@/edit", objectId]; - uriFormat = [self uriAsFormat]; - uri = [NSString stringWithFormat:uriFormat, nextMethod]; - + nextMethod = [NSString stringWithFormat:@"../%@/edit", objectId]; + uri = [self _completeURIForMethod:nextMethod]; return [self redirectToLocation:uri]; } @@ -278,6 +276,7 @@ return date; } +/* for testing only */ - (id)testAction { WORequest *req; @@ -292,16 +291,18 @@ - (id)saveAction { SOGoAppointment *apt; NSString *iCalString; - NSString *summary, *location, *uri, *uriFormat; + NSString *summary, *location, *uri; NSCalendarDate *sd, *ed; NSArray *ps; unsigned i, count; WORequest *req; + if (![[self clientObject] respondsToSelector:@selector(saveContentString:)]){ - return [NSException exceptionWithHTTPStatus:400 /* invalid request */ - reason: - @"method cannot be invoked on the specified object"]; + /* return 400 == Bad Request */ + return [NSException exceptionWithHTTPStatus:400 + reason:@"method cannot be invoked on " + @"the specified object"]; } req = [[self context] request]; @@ -333,20 +334,39 @@ ps = [req formValuesForKey:@"participants"]; count = [ps count]; for (i = 0; i < count; i++) { - NSString *email; + NSString *pString, *email, *cn; + NSRange r; iCalPerson *p; - NSRange cnr; - email = [ps objectAtIndex:i]; - if ([email length] == 0) + pString = [ps objectAtIndex:i]; + if([pString length] == 0) continue; - + + /* delimiter between email and cn */ + r = [pString rangeOfString:@";"]; + if(r.length > 0) { + email = [pString substringToIndex:r.location]; + if(r.location + 1 < [pString length]) { + cn = [pString substringFromIndex:r.location + 1]; + } + else { + cn = nil; + } + } + else { + email = pString; + cn = nil; + } + if(cn == nil) { + /* construct a fake CN if possible */ + r = [email rangeOfString:@"@"]; + if (r.length > 0) + cn = [email substringToIndex:r.location]; + } p = [[iCalPerson alloc] init]; - [p setEmail:[@"mailto:" stringByAppendingString:[email stringValue]]]; - /* construct a fake CN */ - cnr = [email rangeOfString:@"@"]; - if (cnr.length > 0) - [p setCn:[email substringToIndex:cnr.location]]; + [p setEmail:[@"mailto:" stringByAppendingString:email]]; + if(cn) + [p setCn:cn]; [apt addToAttendees:p]; [p release]; } @@ -363,8 +383,7 @@ // TODO: add some error handling in form! (eg like in Zope) } - uriFormat = [self uriAsFormat]; - uri = [NSString stringWithFormat:uriFormat, @"view"]; + uri = [self _completeURIForMethod:@"view"]; return [self redirectToLocation:uri]; } diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.wox b/SOGo/UI/Scheduler/UIxAppointmentEditor.wox index 8cfc68fd..1920835f 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.wox +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.wox @@ -137,15 +137,30 @@ />
- - - - + + + + + + + + + + + + + +
TODO: EMAIL(!)
@@ -183,6 +198,17 @@ />
+ + + + + +
@@ -190,11 +216,45 @@ + + + + + + + + + + +
+ + + +
+ + : + + + + + +
+ + - + diff --git a/SOGo/UI/Scheduler/UIxAppointmentView.m b/SOGo/UI/Scheduler/UIxAppointmentView.m index 46d653d7..68f41da4 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentView.m +++ b/SOGo/UI/Scheduler/UIxAppointmentView.m @@ -31,14 +31,6 @@ return self->attendee; } -- (NSString *)attendeeEmail { - NSString *s; - - s = [[self attendee] email]; - if (![s hasPrefix:@"mailto:"]) return s; - return [s substringFromIndex:7]; -} - /* backend */ - (SOGoAppointment *)appointment { diff --git a/SOGo/UI/Scheduler/UIxAppointmentView.wox b/SOGo/UI/Scheduler/UIxAppointmentView.wox index 775a5c5f..b7a226db 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentView.wox +++ b/SOGo/UI/Scheduler/UIxAppointmentView.wox @@ -123,16 +123,24 @@ var:href="participantsTabLink"> + + diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index 9461bed0..42d0a3b8 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=27 +SUBMINOR_VERSION:=28 diff --git a/SOGo/UI/Scheduler/iCalPerson+UIx.h b/SOGo/UI/Scheduler/iCalPerson+UIx.h index eaa1989c..7417aa62 100644 --- a/SOGo/UI/Scheduler/iCalPerson+UIx.h +++ b/SOGo/UI/Scheduler/iCalPerson+UIx.h @@ -29,6 +29,7 @@ @interface iCalPerson(Convenience) - (NSString *)rfc822Email; +- (NSString *)cnForDisplay; @end #endif /* __iCalPerson_UIx_H__ */ diff --git a/SOGo/UI/Scheduler/iCalPerson+UIx.m b/SOGo/UI/Scheduler/iCalPerson+UIx.m index 94473e33..14ab19eb 100644 --- a/SOGo/UI/Scheduler/iCalPerson+UIx.m +++ b/SOGo/UI/Scheduler/iCalPerson+UIx.m @@ -38,4 +38,12 @@ return _email; } +- (NSString *)cnForDisplay { + NSString *_cn; + _cn = [self cn]; + if([_cn length] > 2) + return [_cn substringWithRange:NSMakeRange(1, [_cn length] - 2)]; + return _cn; +} + @end /* iCalPerson(Convenience) */
+ Name + Email
+ + + + + >