From df3ad5445cb9a0f4929a94383f2b1c9c30a4af99 Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Wed, 8 Oct 2014 14:23:51 -0400 Subject: [PATCH] Modification for ContactsUserRightsEditor --- UI/Common/UIxAclEditor.m | 8 +++- UI/Contacts/UIxContactsUserRightsEditor.m | 46 +++++++---------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index 8093ce7d8..24da639e7 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -19,6 +19,7 @@ */ #import +#import #import #import #import @@ -82,8 +83,10 @@ - (id ) aclsAction { + id result; NSEnumerator *aclsEnum; NSString *currentUID, *ownerLogin; + NSDictionary *object; if (!prepared) { @@ -116,7 +119,10 @@ prepared = YES; } - return users; + result = [self responseWithStatus: 200 + andString: [users jsonRepresentation]]; + + return result; } - (void) setCurrentUser: (NSString *) newCurrentUser diff --git a/UI/Contacts/UIxContactsUserRightsEditor.m b/UI/Contacts/UIxContactsUserRightsEditor.m index ee3e45444..381e4d9f5 100644 --- a/UI/Contacts/UIxContactsUserRightsEditor.m +++ b/UI/Contacts/UIxContactsUserRightsEditor.m @@ -22,6 +22,7 @@ #import #import +#import #import #import @@ -34,70 +35,51 @@ return [userRights containsObject: SOGoRole_ObjectCreator]; } -- (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects -{ - if (userCanEraseObjects) - [self appendRight: SOGoRole_ObjectEraser]; - else - [self removeRight: SOGoRole_ObjectEraser]; -} - - (BOOL) userCanEraseObjects { return [userRights containsObject: SOGoRole_ObjectEraser]; } -- (void) setUserCanEditObjects: (BOOL) userCanEditObjects -{ - if (userCanEditObjects) - [self appendRight: SOGoRole_ObjectEditor]; - else - [self removeRight: SOGoRole_ObjectEditor]; -} - - (BOOL) userCanEditObjects { return [userRights containsObject: SOGoRole_ObjectEditor]; } -- (void) setUserCanViewObjects: (BOOL) userCanViewObjects -{ - if (userCanViewObjects) - [self appendRight: SOGoRole_ObjectViewer]; - else - [self removeRight: SOGoRole_ObjectViewer]; -} - - (BOOL) userCanViewObjects { 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]; else [self removeRight: SOGoRole_ObjectCreator]; - if ([[request formValueForKey: @"ObjectEditor"] length] > 0) + if ([[newRights objectForKey: @"canEditObjects"] boolValue]) [self appendRight: SOGoRole_ObjectEditor]; else [self removeRight: SOGoRole_ObjectEditor]; - if ([[request formValueForKey: @"ObjectViewer"] length] > 0) + if ([[newRights objectForKey: @"canViewObjects"] boolValue]) [self appendRight: SOGoRole_ObjectViewer]; else [self removeRight: SOGoRole_ObjectViewer]; - if ([[request formValueForKey: @"ObjectEraser"] length] > 0) + if ([[newRights objectForKey: @"canEraseObjects"] boolValue]) [self appendRight: SOGoRole_ObjectEraser]; else [self removeRight: SOGoRole_ObjectEraser]; } -@end +@end \ No newline at end of file