Modification for ContactsUserRightsEditor

This commit is contained in:
Alexandre Cloutier
2014-11-11 22:32:45 -05:00
committed by Francis Lachapelle
parent 3f27e9bb57
commit 29d114188f
2 changed files with 21 additions and 33 deletions
+7 -1
View File
@@ -19,6 +19,7 @@
*/ */
#import <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSKeyValueCoding.h> #import <Foundation/NSKeyValueCoding.h>
@@ -82,8 +83,10 @@
- (id <WOActionResults>) aclsAction - (id <WOActionResults>) aclsAction
{ {
id <WOActionResults> result;
NSEnumerator *aclsEnum; NSEnumerator *aclsEnum;
NSString *currentUID, *ownerLogin; NSString *currentUID, *ownerLogin;
NSDictionary *object;
if (!prepared) if (!prepared)
{ {
@@ -116,7 +119,10 @@
prepared = YES; prepared = YES;
} }
return users; result = [self responseWithStatus: 200
andString: [users jsonRepresentation]];
return result;
} }
- (void) setCurrentUser: (NSString *) newCurrentUser - (void) setCurrentUser: (NSString *) newCurrentUser
+13 -31
View File
@@ -22,6 +22,7 @@
#import <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSValue.h>
#import <NGObjWeb/WORequest.h> #import <NGObjWeb/WORequest.h>
#import <SoObjects/SOGo/SOGoPermissions.h> #import <SoObjects/SOGo/SOGoPermissions.h>
@@ -34,67 +35,48 @@
return [userRights containsObject: SOGoRole_ObjectCreator]; return [userRights containsObject: SOGoRole_ObjectCreator];
} }
- (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects
{
if (userCanEraseObjects)
[self appendRight: SOGoRole_ObjectEraser];
else
[self removeRight: SOGoRole_ObjectEraser];
}
- (BOOL) userCanEraseObjects - (BOOL) userCanEraseObjects
{ {
return [userRights containsObject: SOGoRole_ObjectEraser]; return [userRights containsObject: SOGoRole_ObjectEraser];
} }
- (void) setUserCanEditObjects: (BOOL) userCanEditObjects
{
if (userCanEditObjects)
[self appendRight: SOGoRole_ObjectEditor];
else
[self removeRight: SOGoRole_ObjectEditor];
}
- (BOOL) userCanEditObjects - (BOOL) userCanEditObjects
{ {
return [userRights containsObject: SOGoRole_ObjectEditor]; return [userRights containsObject: SOGoRole_ObjectEditor];
} }
- (void) setUserCanViewObjects: (BOOL) userCanViewObjects
{
if (userCanViewObjects)
[self appendRight: SOGoRole_ObjectViewer];
else
[self removeRight: SOGoRole_ObjectViewer];
}
- (BOOL) userCanViewObjects - (BOOL) userCanViewObjects
{ {
return [userRights containsObject: SOGoRole_ObjectViewer]; return [userRights containsObject: SOGoRole_ObjectViewer];
} }
- (void) updateRights - (NSDictionary *) userRightsForObject
{ {
WORequest *request; return [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:[self userCanCreateObjects]], @"canCreateObjects",
[NSNumber numberWithBool:[self userCanEraseObjects]], @"canEraseObjects",
[NSNumber numberWithBool:[self userCanEditObjects]], @"canEditObjects",
[NSNumber numberWithBool:[self userCanViewObjects]], @"canViewObjects", nil];
}
request = [context request]; - (void) updateRights: (NSDictionary *) newRights
{
if ([[request formValueForKey: @"ObjectCreator"] length] > 0) if ([[newRights objectForKey: @"canCreateObjects"] boolValue])
[self appendRight: SOGoRole_ObjectCreator]; [self appendRight: SOGoRole_ObjectCreator];
else else
[self removeRight: SOGoRole_ObjectCreator]; [self removeRight: SOGoRole_ObjectCreator];
if ([[request formValueForKey: @"ObjectEditor"] length] > 0) if ([[newRights objectForKey: @"canEditObjects"] boolValue])
[self appendRight: SOGoRole_ObjectEditor]; [self appendRight: SOGoRole_ObjectEditor];
else else
[self removeRight: SOGoRole_ObjectEditor]; [self removeRight: SOGoRole_ObjectEditor];
if ([[request formValueForKey: @"ObjectViewer"] length] > 0) if ([[newRights objectForKey: @"canViewObjects"] boolValue])
[self appendRight: SOGoRole_ObjectViewer]; [self appendRight: SOGoRole_ObjectViewer];
else else
[self removeRight: SOGoRole_ObjectViewer]; [self removeRight: SOGoRole_ObjectViewer];
if ([[request formValueForKey: @"ObjectEraser"] length] > 0) if ([[newRights objectForKey: @"canEraseObjects"] boolValue])
[self appendRight: SOGoRole_ObjectEraser]; [self appendRight: SOGoRole_ObjectEraser];
else else
[self removeRight: SOGoRole_ObjectEraser]; [self removeRight: SOGoRole_ObjectEraser];