]> err.no Git - scalable-opengroupware.org/blob - UI/Scheduler/UIxCalInlineAptView.m
moved partstat modification from UI to SoObject
[scalable-opengroupware.org] / UI / Scheduler / UIxCalInlineAptView.m
1 /*
2  Copyright (C) 2000-2004 SKYRIX Software AG
3  
4  This file is part of OGo
5  
6  OGo is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License as published by the
8  Free Software Foundation; either version 2, or (at your option) any
9  later version.
10  
11  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12  WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14  License for more details.
15  
16  You should have received a copy of the GNU Lesser General Public
17  License along with OGo; see the file COPYING.  If not, write to the
18  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20  */
21 // $Id$
22
23 #include <NGObjWeb/NGObjWeb.h>
24
25 @interface UIxCalInlineAptView : WOComponent
26 {
27   id   appointment;
28   id   formatter;
29   id   tooltipFormatter;
30   id   url;
31   id   style;
32   id   queryDictionary;
33   id   referenceDate;
34   BOOL canAccess;
35 }
36
37 @end
38
39 #include "common.h"
40 #include <SOGoUI/SOGoAptFormatter.h>
41 #include <SOGo/SOGoUser.h>
42 #include <NGObjWeb/WOContext+SoObjects.h>
43
44 @implementation UIxCalInlineAptView
45
46 - (void)dealloc {
47   [self->appointment      release];
48   [self->formatter        release];
49   [self->tooltipFormatter release];
50   [self->url              release];
51   [self->style            release];
52   [self->queryDictionary  release];
53   [self->referenceDate    release];
54   [super dealloc];
55 }
56
57 - (void)setAppointment:(id)_appointment {
58   ASSIGN(self->appointment, _appointment);
59 }
60 - (id)appointment {
61   return self->appointment;
62 }
63
64 - (void)setFormatter:(id)_formatter {
65   ASSIGN(self->formatter, _formatter);
66 }
67 - (id)formatter {
68   return self->formatter;
69 }
70
71 - (void)setTooltipFormatter:(id)_tooltipFormatter {
72   ASSIGN(self->tooltipFormatter, _tooltipFormatter);
73 }
74 - (id)tooltipFormatter {
75   return self->tooltipFormatter;
76 }
77
78 - (void)setUrl:(id)_url {
79   ASSIGN(self->url, _url);
80 }
81 - (id)url {
82   return self->url;
83 }
84
85 - (void)setStyle:(id)_style {
86   NSMutableString *ms;
87   NSNumber        *prio;
88   NSString        *s;
89   NSString        *email;
90
91   if (_style) {
92     ms = [NSMutableString stringWithString:_style];
93   }
94   else {
95     ms = (NSMutableString *)[NSMutableString string];
96   }
97   if ((prio = [self->appointment valueForKey:@"priority"])) {
98     [ms appendFormat:@" apt_prio%@", prio];
99   }
100   email = [[[self context] activeUser] email];
101   if ((s = [self->appointment valueForKey:@"orgmail"])) {
102     if ([s rangeOfString:email].length > 0) {
103       [ms appendString:@" apt_organizer"];
104     }
105     else {
106       [ms appendString:@" apt_other"];
107     }
108   }
109   if ((s = [self->appointment valueForKey:@"partmails"])) {
110     if ([s rangeOfString:email].length > 0) {
111       [ms appendString:@" apt_participant"];
112     }
113     else {
114       [ms appendString:@" apt_nonparticipant"];
115     }
116   }
117   ASSIGNCOPY(self->style, ms);
118 }
119 - (id)style {
120   return self->style;
121 }
122
123 - (void)setQueryDictionary:(id)_queryDictionary {
124   ASSIGN(self->queryDictionary, _queryDictionary);
125 }
126 - (id)queryDictionary {
127   return self->queryDictionary;
128 }
129
130 - (void)setReferenceDate:(id)_referenceDate {
131   ASSIGN(self->referenceDate, _referenceDate);
132 }
133 - (id)referenceDate {
134   return self->referenceDate;
135 }
136
137 - (void)setCanAccess:(BOOL)_canAccess {
138   self->canAccess = _canAccess;
139 }
140 - (BOOL)canAccess {
141   return self->canAccess;
142 }
143
144 /* helpers */
145
146 - (NSString *)title {
147   return [self->formatter stringForObjectValue:self->appointment
148                           referenceDate:[self referenceDate]];
149 }
150
151 - (NSString *)tooltip {
152   return [self->tooltipFormatter stringForObjectValue:self->appointment
153                                  referenceDate:[self referenceDate]];
154 }
155
156 @end