1 /* UIxMailUserRightsEditor.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 "UIxMailUserRightsEditor.h"
30 @implementation UIxMailUserRightsEditor
32 - (void) setUserCanSeeFolder: (BOOL) userCanSeeFolder
35 [self appendRight: SOGoRole_ObjectViewer];
37 [self removeRight: SOGoRole_ObjectViewer];
40 - (BOOL) userCanSeeFolder
42 return [userRights containsObject: SOGoRole_ObjectViewer];
45 - (void) setUserCanReadMails: (BOOL) userCanReadMails
48 [self appendRight: SOGoRole_ObjectReader];
50 [self removeRight: SOGoRole_ObjectReader];
53 - (BOOL) userCanReadMails
55 return [userRights containsObject: SOGoRole_ObjectReader];
58 - (void) setUserCanMarkMailsRead: (BOOL) userCanMarkMailsRead
60 if (userCanMarkMailsRead)
61 [self appendRight: SOGoMailRole_SeenKeeper];
63 [self removeRight: SOGoMailRole_SeenKeeper];
66 - (BOOL) userCanMarkMailsRead
68 return [userRights containsObject: SOGoMailRole_SeenKeeper];
71 - (void) setUserCanWriteMails: (BOOL) userCanWriteMails
73 if (userCanWriteMails)
74 [self appendRight: SOGoMailRole_Writer];
76 [self removeRight: SOGoMailRole_Writer];
79 - (BOOL) userCanWriteMails
81 return [userRights containsObject: SOGoMailRole_Writer];
84 - (void) setUserCanInsertMails: (BOOL) userCanInsertMails
86 if (userCanInsertMails)
87 [self appendRight: SOGoRole_ObjectCreator];
89 [self removeRight: SOGoRole_ObjectCreator];
92 - (BOOL) userCanInsertMails
94 return [userRights containsObject: SOGoRole_ObjectCreator];
97 - (void) setUserCanPostMails: (BOOL) userCanPostMails
100 [self appendRight: SOGoMailRole_Poster];
102 [self removeRight: SOGoMailRole_Poster];
105 - (BOOL) userCanPostMails
107 return [userRights containsObject: SOGoMailRole_Poster];
110 - (void) setUserCanCreateSubfolders: (BOOL) userCanCreateSubfolders
112 if (userCanCreateSubfolders)
113 [self appendRight: SOGoRole_FolderCreator];
115 [self removeRight: SOGoRole_FolderCreator];
118 - (BOOL) userCanCreateSubfolders
120 return [userRights containsObject: SOGoRole_FolderCreator];
123 - (void) setUserCanRemoveFolder: (BOOL) userCanRemoveFolder
125 if (userCanRemoveFolder)
126 [self appendRight: SOGoRole_ObjectEraser];
128 [self removeRight: SOGoRole_ObjectEraser];
131 - (BOOL) userCanRemoveFolder
133 return [userRights containsObject: SOGoRole_ObjectEraser];
136 - (void) setUserCanEraseMails: (BOOL) userCanEraseMails
138 if (userCanEraseMails)
139 [self appendRight: SOGoMailRole_MessageEraser];
141 [self removeRight: SOGoMailRole_MessageEraser];
144 - (BOOL) userCanEraseMails
146 return [userRights containsObject: SOGoMailRole_MessageEraser];
149 - (void) setUserCanExpungeFolder: (BOOL) userCanExpungeFolder
151 if (userCanExpungeFolder)
152 [self appendRight: SOGoMailRole_Expunger];
154 [self removeRight: SOGoMailRole_Expunger];
157 - (BOOL) userCanExpungeFolder
159 return [userRights containsObject: SOGoMailRole_Expunger];
162 - (void) setUserIsAdministrator: (BOOL) userIsAdministrator
164 if (userIsAdministrator)
165 [self appendRight: SOGoMailRole_Administrator];
167 [self removeRight: SOGoMailRole_Administrator];
170 - (BOOL) userIsAdministrator
172 return [userRights containsObject: SOGoMailRole_Administrator];
175 - (void) updateRights
179 request = [context request];
181 if ([[request formValueForKey: SOGoRole_ObjectViewer] length] > 0)
182 [self appendRight: SOGoRole_ObjectViewer];
184 [self removeRight: SOGoRole_ObjectViewer];
186 if ([[request formValueForKey: SOGoRole_ObjectReader] length] > 0)
187 [self appendRight: SOGoRole_ObjectReader];
189 [self removeRight: SOGoRole_ObjectReader];
191 if ([[request formValueForKey: SOGoMailRole_SeenKeeper] length] > 0)
192 [self appendRight: SOGoMailRole_SeenKeeper];
194 [self removeRight: SOGoMailRole_SeenKeeper];
196 if ([[request formValueForKey: SOGoMailRole_Writer] length] > 0)
197 [self appendRight: SOGoMailRole_Writer];
199 [self removeRight: SOGoMailRole_Writer];
201 if ([[request formValueForKey: SOGoRole_ObjectCreator] length] > 0)
202 [self appendRight: SOGoRole_ObjectCreator];
204 [self removeRight: SOGoRole_ObjectCreator];
206 if ([[request formValueForKey: SOGoMailRole_Poster] length] > 0)
207 [self appendRight: SOGoMailRole_Poster];
209 [self removeRight: SOGoMailRole_Poster];
211 if ([[request formValueForKey: SOGoRole_FolderCreator] length] > 0)
212 [self appendRight: SOGoRole_FolderCreator];
214 [self removeRight: SOGoRole_FolderCreator];
216 if ([[request formValueForKey: SOGoRole_ObjectEraser] length] > 0)
217 [self appendRight: SOGoRole_ObjectEraser];
219 [self removeRight: SOGoRole_ObjectEraser];
221 if ([[request formValueForKey: SOGoMailRole_MessageEraser] length] > 0)
222 [self appendRight: SOGoMailRole_MessageEraser];
224 [self removeRight: SOGoMailRole_MessageEraser];
226 if ([[request formValueForKey: SOGoMailRole_Expunger] length] > 0)
227 [self appendRight: SOGoMailRole_Expunger];
229 [self removeRight: SOGoMailRole_Expunger];
231 if ([[request formValueForKey: SOGoMailRole_Administrator] length] > 0)
232 [self appendRight: SOGoMailRole_Administrator];
234 [self removeRight: SOGoMailRole_Administrator];