]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/SoUser.m
fixed copyrights for 2005
[sope] / sope-appserver / NGObjWeb / SoObjects / SoUser.m
1 /*
2   Copyright (C) 2002-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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 "SoUser.h"
23 #include "common.h"
24
25 @implementation SoUser
26
27 - (id)initWithLogin:(NSString *)_login roles:(NSArray *)_roles {
28   if (_login == nil) {
29     [self release];
30     return nil;
31   }
32   if ((self = [super init])) {
33     self->login = [_login copy];
34     self->roles = [_roles copy];
35   }
36   return self;
37 }
38 - (id)init {
39   return [self initWithLogin:nil roles:nil];
40 }
41
42 - (void)dealloc {
43   [self->login release];
44   [self->roles release];
45   [super dealloc];
46 }
47
48 /* accessors */
49
50 - (NSString *)login {
51   return self->login;
52 }
53
54 /* roles */
55
56 - (NSArray *)rolesInContext:(id)_ctx {
57   return self->roles;
58 }
59
60 - (NSArray *)rolesForObject:(id)_object inContext:(id)_ctx {
61   NSArray *aroles, *localRoles;
62   
63   aroles = [self rolesInContext:_ctx];
64   if (aroles == nil) aroles = [NSArray array];
65   
66   /* 
67      TODO: collect all local roles (of the object and its parents, local
68      roles are stored in __ac_local_roles__ of the object in Zope. Note
69      that this attribute can be a callable returning the roles !
70   */
71   localRoles = nil;
72   
73   return aroles;
74 }
75
76 /* KVC */
77
78 - (id)valueForUndefinedKey:(NSString *)_key {
79   return nil;
80 }
81
82 /* description */
83
84 - (NSString *)description {
85   NSMutableString *ms;
86   
87   ms = [NSMutableString stringWithCapacity:16];
88   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
89   [ms appendFormat:@" login=%@", self->login];
90   [ms appendFormat:@" roles=%@", [self->roles componentsJoinedByString:@","]];
91   [ms appendString:@">"];
92   return ms;
93 }
94
95 @end /* SoUser */