]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Scheduler/UIxAppointmentView.m
62fd16a2c9a9535683890f8890e3b7bfa2a3c306
[scalable-opengroupware.org] / SOGo / UI / Scheduler / UIxAppointmentView.m
1 // $Id$
2
3 #include "UIxAppointmentView.h"
4 #include "common.h"
5 #include <SOGoLogic/SOGoAppointment.h>
6
7 @implementation UIxAppointmentView
8
9 - (void)dealloc {
10   [self->appointment release];
11   [self->attendee release];
12   [super dealloc];
13 }
14
15 /* accessors */
16
17 - (NSString *)tabSelection {
18   NSString *selection;
19     
20   selection = [self queryParameterForKey:@"tab"];
21   if (selection == nil)
22     selection = @"attributes";
23   return selection;
24 }
25
26 - (void)setAttendee:(id)_attendee {
27   ASSIGN(self->attendee, _attendee);
28 }
29 - (id)attendee {
30   return self->attendee;
31 }
32
33
34 - (NSString *)attendeeEmail {
35   NSString *s;
36   
37   s = [[self attendee] email];
38   if (![s hasPrefix:@"mailto:"]) return s;
39   return [s substringFromIndex:7];
40 }
41
42 /* backend */
43
44 - (SOGoAppointment *)appointment {
45   NSString *iCalString;
46   
47   if (self->appointment)
48     return self->appointment;
49     
50   iCalString = [[self clientObject] valueForKey:@"iCalString"];
51   self->appointment = [[SOGoAppointment alloc] initWithICalString:iCalString];
52   return self->appointment;
53 }
54
55 - (NSString *)formattedAptStartTime {
56   NSCalendarDate *date;
57     
58   date = [[self appointment] startDate];
59   /* TODO: convert this into display timeZone! */
60   return [date descriptionWithCalendarFormat:@"%A, %Y-%m-%d %H:%M %Z"];
61 }
62
63 - (NSString *)formattedAptEndTime {
64   NSCalendarDate *date;
65     
66   date = [[self appointment] endDate];
67   /* TODO: convert this into display timeZone! */
68   return [date descriptionWithCalendarFormat:@"%A, %Y-%m-%d %H:%M %Z"];
69 }
70
71
72 /* hrefs */
73
74 - (NSString *)attributesTabLink {
75   return [self completeHrefForMethod:[self ownMethodName]
76                withParameter:@"attributes"
77                forKey:@"tab"];
78 }
79
80 - (NSString *)participantsTabLink {
81     return [self completeHrefForMethod:[self ownMethodName]
82                  withParameter:@"participants"
83                  forKey:@"tab"];
84 }
85
86 - (NSString *)debugTabLink {
87     return [self completeHrefForMethod:[self ownMethodName]
88                  withParameter:@"debug"
89                  forKey:@"tab"];
90 }
91
92 - (NSString *)completeHrefForMethod:(NSString *)_method
93               withParameter:(NSString *)_param
94               forKey:(NSString *)_key
95 {
96     NSString *href;
97
98     [self setQueryParameter:_param forKey:_key];
99     href = [self completeHrefForMethod:[self ownMethodName]];
100     [self setQueryParameter:nil forKey:_key];
101     return href;
102 }
103
104 @end /* UIxAppointmentView */