1 /* UIxContactsUserRightsEditor.m - this file is part of SOGo
3 * Copyright (C) 2007 Inverse groupe conseil
5 * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #import <Foundation/NSArray.h>
24 #import <Foundation/NSEnumerator.h>
25 #import <NGObjWeb/WORequest.h>
26 #import <SoObjects/SOGo/SOGoPermissions.h>
28 #import "UIxContactsUserRightsEditor.h"
30 @implementation UIxContactsUserRightsEditor
32 - (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects
34 if (userCanCreateObjects)
35 [self appendRight: SOGoRole_ObjectCreator];
37 [self removeRight: SOGoRole_ObjectCreator];
40 - (BOOL) userCanCreateObjects
42 return [userRights containsObject: SOGoRole_ObjectCreator];
45 - (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects
47 if (userCanEraseObjects)
48 [self appendRight: SOGoRole_ObjectEraser];
50 [self removeRight: SOGoRole_ObjectEraser];
53 - (BOOL) userCanEraseObjects
55 return [userRights containsObject: SOGoRole_ObjectEraser];
58 - (void) setUserCanEditObjects: (BOOL) userCanEditObjects
60 if (userCanEditObjects)
61 [self appendRight: SOGoRole_ObjectEditor];
63 [self removeRight: SOGoRole_ObjectEditor];
66 - (BOOL) userCanEditObjects
68 return [userRights containsObject: SOGoRole_ObjectEditor];
71 - (void) setUserCanViewObjects: (BOOL) userCanViewObjects
73 if (userCanViewObjects)
74 [self appendRight: SOGoRole_ObjectViewer];
76 [self removeRight: SOGoRole_ObjectViewer];
79 - (BOOL) userCanViewObjects
81 return [userRights containsObject: SOGoRole_ObjectViewer];
84 - (void) setUserCanReadObjects: (BOOL) userCanReadObjects
86 if (userCanReadObjects)
87 [self appendRight: SOGoRole_ObjectReader];
89 [self removeRight: SOGoRole_ObjectReader];
92 - (BOOL) userCanReadObjects
94 return [userRights containsObject: SOGoRole_ObjectReader];
101 request = [context request];
103 if ([[request formValueForKey: @"ObjectCreator"] length] > 0)
104 [self appendRight: SOGoRole_ObjectCreator];
106 [self removeRight: SOGoRole_ObjectCreator];
108 if ([[request formValueForKey: @"ObjectEditor"] length] > 0)
109 [self appendRight: SOGoRole_ObjectEditor];
111 [self removeRight: SOGoRole_ObjectEditor];
113 if ([[request formValueForKey: @"ObjectViewer"] length] > 0)
114 [self appendRight: SOGoRole_ObjectViewer];
116 [self removeRight: SOGoRole_ObjectViewer];
118 if ([[request formValueForKey: @"ObjectReader"] length] > 0)
119 [self appendRight: SOGoRole_ObjectReader];
121 [self removeRight: SOGoRole_ObjectReader];
123 if ([[request formValueForKey: @"ObjectEraser"] length] > 0)
124 [self appendRight: SOGoRole_ObjectEraser];
126 [self removeRight: SOGoRole_ObjectEraser];