2 Copyright (C) 2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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>
26 @interface UIxContactView : UIxComponent
30 - (BOOL)isDeletableClientObject;
34 #include <Contacts/SOGoContactObject.h>
37 @implementation UIxContactView
41 - (NSString *)tabSelection {
44 selection = [self queryParameterForKey:@"tab"];
46 selection = @"attributes";
52 - (NSString *)completeHrefForMethod:(NSString *)_method
53 withParameter:(NSString *)_param
54 forKey:(NSString *)_key
58 [self setQueryParameter:_param forKey:_key];
59 href = [self completeHrefForMethod:[self ownMethodName]];
60 [self setQueryParameter:nil forKey:_key];
64 - (NSString *)attributesTabLink {
65 return [self completeHrefForMethod:[self ownMethodName]
66 withParameter:@"attributes"
69 - (NSString *)debugTabLink {
70 return [self completeHrefForMethod:[self ownMethodName]
71 withParameter:@"debug"
77 - (id<WOActionResults>)defaultAction {
78 if ([[self clientObject] record] == nil) {
79 return [NSException exceptionWithHTTPStatus:404 /* Not Found */
80 reason:@"could not locate contact"];
85 - (BOOL)isDeletableClientObject {
86 return [[self clientObject] respondsToSelector:@selector(delete)];
93 if (![self isDeletableClientObject]) {
94 /* return 400 == Bad Request */
95 return [NSException exceptionWithHTTPStatus:400
96 reason:@"method cannot be invoked on "
97 @"the specified object"];
100 if ((ex = [[self clientObject] delete]) != nil) {
101 // TODO: improve error handling
102 [self debugWithFormat:@"failed to delete: %@", ex];
106 url = [[[self clientObject] container] baseURLInContext:[self context]];
107 return [self redirectToLocation:url];
110 @end /* UIxContactView */