]> err.no Git - scalable-opengroupware.org/blob - UI/Contacts/UIxContactsSelectionView.m
2e960de9a47581eff5a11d0936ec5e924bf4c5de
[scalable-opengroupware.org] / UI / Contacts / UIxContactsSelectionView.m
1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
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
22 #include "UIxContactsListViewBase.h"
23 #include <SOGoUI/SOGoJSStringFormatter.h>
24
25 @interface UIxContactsSelectionView : UIxContactsListViewBase
26 {
27   NSString *callback;
28 }
29
30 - (NSString *)_getCN;
31 - (NSString *)getCN;
32 - (NSString *)getSN;
33 - (NSString *)getMail;
34 - (NSString *)getUID;
35   
36 @end
37
38 #include "common.h"
39 #include <SOGo/AgenorUserManager.h>
40
41 @implementation UIxContactsSelectionView
42
43 static SOGoJSStringFormatter *jsFormatter = nil;
44
45 + (void)initialize {
46   static BOOL didInit = NO;
47
48   if(didInit)
49     return;
50
51   didInit = YES;
52   jsFormatter = [SOGoJSStringFormatter sharedFormatter];
53 }
54
55 - (void)dealloc {
56   [self->callback release];
57   [super dealloc];
58 }
59
60 - (NSString *)callback {
61   if(!self->callback) {
62     WORequest *r = [[self context] request];
63     self->callback = [[r formValueForKey:@"callback"] retain];
64   }
65   return self->callback;
66 }
67
68 - (NSString *)_getCN {
69   return [self->contact valueForKey:@"cn"];
70 }
71
72 - (NSString *)getCN {
73   return [jsFormatter stringByEscapingQuotesInString:[self _getCN]];
74 }
75
76 - (NSString *)getSN {
77   NSString *sn = [self->contact valueForKey:@"sn"];
78   return [jsFormatter stringByEscapingQuotesInString:sn];
79 }
80
81 - (NSString *)getMail {
82   return [self->contact valueForKey:@"mail"];
83 }
84
85 - (NSString *)getUID {
86   return [[AgenorUserManager sharedUserManager] getUIDForEmail:[self getMail]];
87 }
88
89 - (NSString *)jsOnClickCode {
90   /* callback parameters: (type, cn, dn, email, uid, sn) */
91
92
93
94   /* changed to :  type, email, uid, sn, cn, dn */
95   static NSString *jsCode = \
96     @"javascript:opener.window.%@('', '%@', '%@', '%@', '%@', '');";
97
98   return [NSString stringWithFormat:jsCode,
99                    [self callback],
100                    [self getMail],
101                    [self getUID],
102                    [self getSN],
103                    [self getCN]];
104
105
106
107   //  return [NSString stringWithFormat:jsCode,
108   //    [self callback],
109   //    [self getCN],
110   //    [self getMail],
111   //    [self getUID],
112   //    [self getSN]];
113 }
114
115 @end /* UIxContactsInlineListView */