2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OGo
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
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.
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
24 #include <SOGoUI/UIxComponent.h>
29 Modifiable list of uids used to select multiple calendars for viewing at once.
32 @interface AnaisUidSelector : UIxComponent
34 NSArray *calendarUIDs;
40 - (NSString *)prettyUid;
41 - (NSString *)userUid;
43 - (NSString *)_colorizedUid:(NSString *)_uid;
44 - (NSString *)showHref;
51 #include <NGObjWeb/SoUser.h>
52 #include <SOGo/AgenorUserManager.h>
53 #include <SOGo/SOGoUser.h>
54 #include <SOGo/WOContext+Agenor.h>
56 @implementation AnaisUidSelector
66 [self->calendarUIDs release];
68 [self->userUid release];
72 - (void)setCalendarUIDs:(NSArray *)_calendarUIDs {
73 ASSIGN(self->calendarUIDs, _calendarUIDs);
75 - (NSArray *)calendarUIDs {
76 return self->calendarUIDs;
78 - (void)setUid:(NSString *)_uid {
79 ASSIGN(self->uid, _uid);
84 - (NSString *)prettyUid {
85 AgenorUserManager *um;
88 if([self->calendarUIDs objectAtIndex:0] == self->uid)
89 return [self _colorizedUid:[self userCN]];
91 um = [AgenorUserManager sharedUserManager];
92 cn = [um getCNForUID:self->uid];
93 return [NSString stringWithFormat:@", %@", [self _colorizedUid:cn]];
96 - (NSString *)_colorizedUid:(NSString *)_uid {
97 if([_uid isEqualToString:[self userCN]]) {
98 _uid = [NSString stringWithFormat:@"<span class=\""
99 @"anais_me\">%@</span>",
107 - (NSString *)showHref {
108 return [self completeHrefForMethod:@"show"];
114 - (NSString *)userUid {
116 ASSIGN(self->userUid, [[self user] login]);
118 return self->userUid;
121 - (NSString *)userCN {
123 ASSIGN(self->userCN, [[[self context] activeUser] cn]);
128 - (NSString *)calendarUIDString {
129 return [[self calendarUIDs] componentsJoinedByString:@","];
132 /* this is to determine the initial visibility of the 'addMeToo' button */
133 - (NSString *)meTooStyle {
134 if([[self calendarUIDs] containsObject:userUid])
135 return @"visibility:hidden";
136 return @"visibility:visible";
141 - (NSString *)jsCode {
142 static NSString *script = \
143 @"function clearElementWithId(elemId) {\n"
144 @" var o = document.getElementById(elemId);\n"
145 @" var dst = o.parentNode;\n"
146 @" var n = document.createElement('td');\n"
147 @" n.setAttribute('id', elemId);\n"
148 @" n.setAttribute('align', 'left');\n"
149 @" n.setAttribute('class', 'anais_uids');\n"
150 @" dst.replaceChild(n, o);\n"
152 @"function clearUidList() {\n"
153 @" clearElementWithId('anaisUIDList');\n"
154 @" var e = document.getElementById('anaisUIDString');\n"
155 @" e.setAttribute('value', '');\n"
156 @" var td = document.getElementById('addMeToo');\n"
157 @" td.setAttribute('style', 'visibility:visible');\n"
158 @" td = document.getElementById('clearUidList');\n"
159 @" td.setAttribute('style', 'visibility:hidden');\n"
160 @" td = document.getElementById('showUidList');\n"
161 @" td.setAttribute('style', 'visibility:hidden');\n"
163 @"function addMeToo() {\n"
164 @" addUid('', '', '%@', '', '%@', '');\n"
165 @" var td = document.getElementById('addMeToo');\n"
166 @" td.setAttribute('style', 'visibility:hidden');\n"
168 @"function clearAllAndAddMe() {\n"
169 @" clearUidList();\n"
172 @"function addUidFromAnais(type, email, uid, sn, cn, dn) {\n"
173 @" addUid(type, email, uid, sn, cn, dn); \n"
175 @"function addUid(type, email, uid, sn, cn, dn) {\n"
178 @" var e = document.getElementById('anaisUIDString');\n"
179 @" var s = e.getAttribute('value');\n"
181 @" s = s + ',' + uid;\n"
184 @" e.setAttribute('value', s);\n"
185 @" var td = document.getElementById('anaisUIDList');\n"
187 @" if(td.hasChildNodes()) {\n"
188 @" text = document.createTextNode(', ');\n"
189 @" td.appendChild(text);\n"
191 @" text = document.createTextNode(cn);\n"
192 @" if(uid == '%@') {\n"
193 @" var span = document.createElement('span');\n"
194 @" span.setAttribute('class', 'anais_me');\n"
195 @" span.appendChild(text);\n"
196 @" td.appendChild(span);\n"
199 @" td.appendChild(text);\n"
201 @" td = document.getElementById('clearUidList');\n"
202 @" td.setAttribute('style', 'visibility:visible');\n"
203 @" td = document.getElementById('showUidList');\n"
204 @" td.setAttribute('style', 'visibility:visible');\n"
208 return [NSString stringWithFormat:script,