- (NSArray *)getICalPersonsFromFormValues:(NSArray *)_values
treatAsResource:(BOOL)_isResource;
+- (NSString *)iCalParticipantsAndResourcesStringFromQueryParameters;
+- (NSString *)iCalParticipantsStringFromQueryParameters;
+- (NSString *)iCalResourcesStringFromQueryParameters;
+- (NSString *)iCalStringFromQueryParameter:(NSString *)_qp
+ format:(NSString *)_format;
@end
#include "common.h"
@"DTEND:%@\n"
@"TRANSP:OPAQUE\n"
@"SEQUENCE:1\n"
+ @"%@"
@"END:VEVENT\n"
@"END:VCALENDAR";
+
NSCalendarDate *lStartDate, *lEndDate;
NSString *template, *s;
unsigned minutes;
else {
minutes = 60;
}
-
lStartDate = [self selectedDate];
lEndDate = [lStartDate dateByAddingYears:0 months:0 days:0
- hours:0 minutes:minutes seconds:0];
+ hours:0 minutes:minutes seconds:0];
+ s = [self iCalParticipantsAndResourcesStringFromQueryParameters];
template = [NSString stringWithFormat:iCalStringTemplate,
[[self clientObject] nameInContainer],
[[NSCalendarDate date] icalString],
[lStartDate icalString],
- [lEndDate icalString]];
+ [lEndDate icalString],
+ s];
return template;
}
+- (NSString *)iCalParticipantsAndResourcesStringFromQueryParameters {
+ NSString *s;
+
+ s = [self iCalParticipantsStringFromQueryParameters];
+ return [s stringByAppendingString:
+ [self iCalResourcesStringFromQueryParameters]];
+}
+
+- (NSString *)iCalParticipantsStringFromQueryParameters {
+ static NSString *iCalParticipantString = \
+ @"ATTENDEE;ROLE=REQ-PARTICIPANT;CN=\"%@\":mailto:%@\n";
+
+ return [self iCalStringFromQueryParameter:@"ps"
+ format:iCalParticipantString];
+}
+
+- (NSString *)iCalResourcesStringFromQueryParameters {
+ static NSString *iCalResourceString = \
+ @"ATTENDEE;ROLE=NON-PARTICIPANT;CN=\"%@\":mailto:%@\n";
+
+ return [self iCalStringFromQueryParameter:@"rs"
+ format:iCalResourceString];
+}
+
+- (NSString *)iCalStringFromQueryParameter:(NSString *)_qp
+ format:(NSString *)_format
+{
+ AgenorUserManager *um;
+ NSMutableString *iCalRep;
+ NSString *s;
+
+ um = [AgenorUserManager sharedUserManager];
+ iCalRep = (NSMutableString *)[NSMutableString string];
+ s = [self queryParameterForKey:_qp];
+ if(s && [s length] > 0) {
+ NSArray *es;
+ unsigned i, count;
+
+ es = [s componentsSeparatedByString:@","];
+ count = [es count];
+ for(i = 0; i < count; i++) {
+ NSString *email, *cn;
+
+ email = [es objectAtIndex:i];
+ cn = [um getCNForUID:[um getUIDForEmail:email]];
+ [iCalRep appendFormat:_format, cn, email];
+ }
+ }
+ return iCalRep;
+}
+
/* helper */
- (NSString *)_completeURIForMethod:(NSString *)_method {
- (NSMutableDictionary *)currentQueryParameters;
- (NSDictionary *)currentHourQueryParametersForFirstHalf:(BOOL)_first;
+
+- (void)setICalPersons:(NSArray *)_ps asQueryParameter:(NSString *)_qp;
@end
#include <SoObjects/Appointments/SOGoAppointmentFolder.h>
#include <NGExtensions/NGCalendarDateRange.h>
+#include "iCalPerson+UIx.h"
#include "common.h"
@implementation UIxAppointmentProposal
if(!self->currentQueryParameters) {
self->currentQueryParameters = [[self queryParameters] mutableCopy];
[self->currentQueryParameters setObject:[self duration] forKey:@"dur"];
- // TODO: add participants
+ [self setICalPersons:[self resources] asQueryParameter:@"rs"];
+ [self setICalPersons:[self participants] asQueryParameter:@"ps"];
}
return self->currentQueryParameters;
}
+- (void)setICalPersons:(NSArray *)_ps asQueryParameter:(NSString *)_qp {
+ NSMutableString *s;
+ unsigned i, count;
+
+ s = [[NSMutableString alloc] init];
+ count = [_ps count];
+ for(i = 0; i < count; i++) {
+ iCalPerson *p = [_ps objectAtIndex:i];
+ [s appendString:[p rfc822Email]];
+ if(i != (count - 1))
+ [s appendString:@","];
+ }
+ [[self currentQueryParameters] setObject:s forKey:_qp];
+ [s release];
+}
+
- (NSDictionary *)currentHourQueryParametersForFirstHalf:(BOOL)_first {
NSMutableDictionary *qp;
NSString *hmString;