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