NSMutableArray *userApts;
NSMutableArray *foreignApts;
id item;
- NSArray *partNames;
- NSArray *partStates;
+ NSMutableArray *partNames;
+ NSMutableArray *partStates;
NSString *userParticipationStatus;
unsigned participantIndex;
+ unsigned userIndex;
}
- (NSCalendarDate *)startDate;
/* accessors */
- (void)setItem:(id)_item {
- NSString *ps;
-
+ NSString *ps, *email;
+ NSArray *partmails;
+ unsigned idx;
+
ASSIGN(self->item, _item);
- [self->partNames release];
+ [self->partNames release];
[self->partStates release];
ps = [self->item valueForKey:@"participants"];
- self->partNames = [[ps componentsSeparatedByString:@"\n"] retain];
+ self->partNames = [[ps componentsSeparatedByString:@"\n"] mutableCopy];
ps = [self->item valueForKey:@"partstates"];
- self->partStates = [[ps componentsSeparatedByString:@"\n"] retain];
+ self->partStates = [[ps componentsSeparatedByString:@"\n"] mutableCopy];
+ ps = [self->item valueForKey:@"partmails"];
+ partmails = [ps componentsSeparatedByString:@"\n"];
+
+ /* reorder partNames/partStates */
+
+ /* ensure organizer is first entry */
+ email = [self->item valueForKey:@"orgmail"];
+ if ([email isNotNull]) {
+ idx = [partmails indexOfObject:email];
+ if (idx != NSNotFound && idx != 0) {
+ id obj;
+
+ obj = [self->partNames objectAtIndex:idx];
+ [self->partNames insertObject:obj atIndex:0]; /* frontmost */
+ [self->partNames removeObjectAtIndex:idx + 1];
+ obj = [self->partStates objectAtIndex:idx];
+ [self->partStates insertObject:obj atIndex:0]; /* frontmost */
+ [self->partStates removeObjectAtIndex:idx + 1];
+ }
+ }
+ /* user is either second, first or none at all */
+ [self->userParticipationStatus release];
+ email = [self emailForUser];
+ idx = [partmails indexOfObject:email];
+ if (idx != NSNotFound && idx != 0 && idx != 1) {
+ id obj;
+
+ self->userIndex = 1;
+ obj = [self->partNames objectAtIndex:idx];
+ [self->partNames insertObject:obj atIndex:self->userIndex]; /* second */
+ [self->partNames removeObjectAtIndex:idx + 1];
+ obj = [self->partStates objectAtIndex:idx];
+ [self->partStates insertObject:obj atIndex:self->userIndex]; /* second */
+ [self->partStates removeObjectAtIndex:idx + 1];
+ }
+ else {
+ self->userIndex = idx;
+ }
+ if (self->userIndex != NSNotFound)
+ self->userParticipationStatus =
+ [[self->partStates objectAtIndex:self->userIndex] retain];
+ else
+ self->userParticipationStatus = nil;
}
- (id)item {
return self->item;
return self->participantIndex;
}
+- (unsigned)userIndex {
+ return self->userIndex;
+}
+
- (BOOL)isFirstParticipant {
return self->participantIndex == 0 ? YES : NO;
}
}
- (NSString *)userParticipationStatus {
- if (!self->userParticipationStatus) {
- NSString *pms;
- NSArray *partmails;
- unsigned idx;
-
- pms = [self->item valueForKey:@"partmails"];
- partmails = [pms componentsSeparatedByString:@"\n"];
- idx = [partmails indexOfObject:[self emailForUser]];
- if (idx == NSNotFound)
- self->userParticipationStatus = @"";
- self->userParticipationStatus =
- [[self->partStates objectAtIndex:idx] retain];
- }
- return userParticipationStatus;
+ return self->userParticipationStatus;
}
partStat="participationStatus"
/>
</td>
- <var:if condition="isFirstParticipant">
- <td class="schedoverview"
- var:rowspan="rowspan"
+ <td class="schedoverview">
+ <var:if-key const:key="participantIndex"
+ value="userIndex"
>
- <p class="schedoverview">
- <var:component className="UIxCalParticipationStatusView"
- partStat="userParticipationStatus"
- />
- </p>
-
- <var:if-key const:key="userParticipationStatus"
- const:value="1"
- const:negate="YES"
- >
- <a var:href="acceptAppointmentURL"
- class="button_auto"
- ><var:string label:value="accept" /></a>
- </var:if-key>
- <var:if-key const:key="userParticipationStatus"
- const:value="2"
- const:negate="YES"
- >
- <a var:href="declineAppointmentURL"
- class="button_auto"
- ><var:string label:value="decline" /></a>
- </var:if-key>
-
- </td>
- </var:if>
+ <var:if-key const:key="userParticipationStatus"
+ const:value="1"
+ const:negate="YES"
+ >
+ <a var:href="acceptAppointmentURL"
+ class="button_auto"
+ ><var:string label:value="accept" /></a>
+ </var:if-key>
+ <var:if-key const:key="userParticipationStatus"
+ const:value="2"
+ const:negate="YES"
+ >
+ <a var:href="declineAppointmentURL"
+ class="button_auto"
+ ><var:string label:value="decline" /></a>
+ </var:if-key>
+ </var:if-key>
+ </td>
</tr>
</var:foreach>
<var:if condition="didTruncateParticipants">