]> err.no Git - scalable-opengroupware.org/blob - UI/Contacts/UIxContactsUserRightsEditor.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1065 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Contacts / UIxContactsUserRightsEditor.m
1 /* UIxContactsUserRightsEditor.m - this file is part of SOGo
2  *
3  * Copyright (C) 2007 Inverse groupe conseil
4  *
5  * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
6  *
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)
10  * any later version.
11  *
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.
16  *
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.
21  */
22
23 #import <Foundation/NSArray.h>
24 #import <Foundation/NSEnumerator.h>
25 #import <NGObjWeb/WORequest.h>
26 #import <SoObjects/SOGo/SOGoPermissions.h>
27
28 #import "UIxContactsUserRightsEditor.h"
29
30 @implementation UIxContactsUserRightsEditor
31
32 - (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects
33 {
34   if (userCanCreateObjects)
35     [self appendRight: SOGoRole_ObjectCreator];
36   else
37     [self removeRight: SOGoRole_ObjectCreator];
38 }
39
40 - (BOOL) userCanCreateObjects
41 {
42   return [userRights containsObject: SOGoRole_ObjectCreator];
43 }
44
45 - (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects
46 {
47   if (userCanEraseObjects)
48     [self appendRight: SOGoRole_ObjectEraser];
49   else
50     [self removeRight: SOGoRole_ObjectEraser];
51 }
52
53 - (BOOL) userCanEraseObjects
54 {
55   return [userRights containsObject: SOGoRole_ObjectEraser];
56 }
57
58 - (void) setUserCanEditObjects: (BOOL) userCanEditObjects
59 {
60   if (userCanEditObjects)
61     [self appendRight: SOGoRole_ObjectEditor];
62   else
63     [self removeRight: SOGoRole_ObjectEditor];
64 }
65
66 - (BOOL) userCanEditObjects
67 {
68   return [userRights containsObject: SOGoRole_ObjectEditor];
69 }
70
71 - (void) setUserCanViewObjects: (BOOL) userCanViewObjects
72 {
73   if (userCanViewObjects)
74     [self appendRight: SOGoRole_ObjectViewer];
75   else
76     [self removeRight: SOGoRole_ObjectViewer];
77 }
78
79 - (BOOL) userCanViewObjects
80 {
81   return [userRights containsObject: SOGoRole_ObjectViewer];
82 }
83
84 - (void) updateRights
85 {
86   WORequest *request;
87
88   request = [context request];
89
90   if ([[request formValueForKey: @"ObjectCreator"] length] > 0)
91     [self appendRight: SOGoRole_ObjectCreator];
92   else
93     [self removeRight: SOGoRole_ObjectCreator];
94
95   if ([[request formValueForKey: @"ObjectEditor"] length] > 0)
96     [self appendRight: SOGoRole_ObjectEditor];
97   else
98     [self removeRight: SOGoRole_ObjectEditor];
99
100   if ([[request formValueForKey: @"ObjectViewer"] length] > 0)
101     [self appendRight: SOGoRole_ObjectViewer];
102   else
103     [self removeRight: SOGoRole_ObjectViewer];
104
105   if ([[request formValueForKey: @"ObjectEraser"] length] > 0)
106     [self appendRight: SOGoRole_ObjectEraser];
107   else
108     [self removeRight: SOGoRole_ObjectEraser];
109 }
110
111 @end