]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Scheduler/UIxAppointmentView.m
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@137 d1b88da0-ebda-0310-925b-ed51d...
[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 - (NSString *)attendeeEmail {
34   NSString *s;
35   
36   s = [[self attendee] email];
37   if (![s hasPrefix:@"mailto:"]) return s;
38   return [s substringFromIndex:7];
39 }
40
41 /* backend */
42
43 - (SOGoAppointment *)appointment {
44   NSString *iCalString;
45   
46   if (self->appointment)
47     return self->appointment;
48     
49   iCalString = [[self clientObject] valueForKey:@"iCalString"];
50   if ([iCalString length] == 0) {
51     [self logWithFormat:@"ERROR(%s): missing iCal string!", 
52           __PRETTY_FUNCTION__];
53     return nil;
54   }
55   
56   self->appointment = [[SOGoAppointment alloc] initWithICalString:iCalString];
57   return self->appointment;
58 }
59
60 - (NSString *)formattedAptStartTime {
61   NSCalendarDate *date;
62     
63   date = [[self appointment] startDate];
64   [date setTimeZone:[self viewTimeZone]];
65   return [date descriptionWithCalendarFormat:@"%A, %Y-%m-%d %H:%M %Z"];
66 }
67
68 - (NSString *)formattedAptEndTime {
69   NSCalendarDate *date;
70   
71   date = [[self appointment] endDate];
72   [date setTimeZone:[self viewTimeZone]];
73   return [date descriptionWithCalendarFormat:@"%A, %Y-%m-%d %H:%M %Z"];
74 }
75
76
77 /* hrefs */
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 */