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