diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index 8c39a7ebd..5278a9d09 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -19,6 +19,7 @@ */ #import +#import #import #import #import @@ -80,10 +81,12 @@ return defaultUserID; } -- (NSArray *) usersForObject +- (id ) usersForObjectAction { + id result; NSEnumerator *aclsEnum; NSString *currentUID, *ownerLogin; + NSDictionary *object; if (!prepared) { @@ -96,13 +99,30 @@ { if (!([currentUID isEqualToString: ownerLogin] || [currentUID isEqualToString: defaultUserID] - || [currentUID isEqualToString: @"anonymous"])) - [users addObjectUniquely: currentUID]; + || [currentUID isEqualToString: @"anonymous"])) + { + // Set the current user in order to get information associated with it + [self setCurrentUser: currentUID]; + + // Build the object associated with the key; currentUID + object = [NSDictionary dictionaryWithObjectsAndKeys: currentUser, @"UID", + [self currentUserClass], @"userClass", + [self currentUserDisplayName], @"displayName", + [NSNumber numberWithBool:[self currentUserIsSubscribed]], @"isSubscribed", nil]; + [users addObject:object]; + } } + // Adding the Any authenticated user and the public access + [users addObject:[NSDictionary dictionaryWithObjectsAndKeys: @"", @"UID", @"Any authenticated user", @"displayName", @"public-user", @"userClass", nil]]; + if ([self isPublicAccessEnabled]) + [users addObject:[NSDictionary dictionaryWithObjectsAndKeys: @"anonymous", @"UID", @"Public access", @"displayName", @"public-user", @"userClass", nil]]; prepared = YES; } - return users; + result = [self responseWithStatus: 200 + andString: [users jsonRepresentation]]; + + return result; } - (void) setCurrentUser: (NSString *) newCurrentUser @@ -133,20 +153,13 @@ return [um getFullEmailForUID: [self currentUser]]; } -- (BOOL) canSubscribeUsers -{ - return [[self clientObject] - respondsToSelector: @selector (subscribeUserOrGroup:reallyDo:response:)]; -} - - (BOOL) currentUserIsSubscribed { SOGoGCSFolder *folder; folder = [self clientObject]; - return ([folder respondsToSelector: @selector (userIsSubscriber:)] - && [folder userIsSubscriber: currentUser]); + return ([folder respondsToSelector: @selector (userIsSubscriber:)] && [folder userIsSubscriber: currentUser]); } - (void) setUserUIDS: (NSString *) retainedUsers diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 8a6ee1166..aa7599d0f 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -119,25 +119,25 @@ if ([newUID length] > 0) { if (!defaultUserID) - ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); um = [SOGoUserManager sharedUserManager]; if ([newUID isEqualToString: defaultUserID] || [newUID isEqualToString: @"anonymous"] || [[um getEmailForUID: newUID] length] > 0) - { - if (![newUID hasPrefix: @"@"]) - { + { + if (![newUID hasPrefix: @"@"]) + { domain = [[context activeUser] domain]; - group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain]; - if (group) - newUID = [NSString stringWithFormat: @"@%@", newUID]; - } + group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain]; + if (group) + newUID = [NSString stringWithFormat: @"@%@", newUID]; + } ASSIGN (uid, newUID); - clientObject = [self clientObject]; - [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; + clientObject = [self clientObject]; + [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; response = YES; - } + } } return response; } @@ -183,13 +183,11 @@ id response; if (![self _initRights]) - response = [NSException exceptionWithHTTPStatus: 403 - reason: @"No such user."]; + response = [self responseWithStatus: 403 + andString: @"No such user."]; else - { - [self prepareRightsForm]; - response = self; - } + response = [self responseWithStatus: 200 + andString:[[self userRightsForObject] jsonRepresentation]]; return response; } @@ -237,6 +235,7 @@ { response = [self responseWithStatus: 403 andString: @"No such user."]; + return response; } else { @@ -247,10 +246,9 @@ dd = [[context activeUser] domainDefaults]; if (![o isEqualToArray: userRights] && [dd aclSendEMailNotifications]) [self sendACLAdvisoryTemplateForObject: [self clientObject]]; - - response = [self jsCloseWithRefreshMethod: nil]; } } + response = [self jsCloseWithRefreshMethod: nil]; return response; } @@ -267,7 +265,7 @@ } - (void) appendExclusiveRight: (NSString *) newRight - fromList: (NSArray *) list + fromList: (NSArray *) list { [userRights removeObjectsInArray: list]; [self appendRight: newRight]; diff --git a/UI/Common/product.plist b/UI/Common/product.plist index d1ad5c1fd..56f8d74e9 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -63,6 +63,11 @@ pageName = "UIxUserRightsEditor"; actionName = "saveUserRights"; }; + getUsersForObject = { + protectedBy = "view"; + pageName = "UIxAclEditor"; + actionName = "usersForObject"; + }; }; }; SOGoParentFolder = { diff --git a/UI/Contacts/UIxContactsUserRightsEditor.m b/UI/Contacts/UIxContactsUserRightsEditor.m index 74e1e1a05..08a929b53 100644 --- a/UI/Contacts/UIxContactsUserRightsEditor.m +++ b/UI/Contacts/UIxContactsUserRightsEditor.m @@ -22,6 +22,7 @@ #import #import +#import #import #import @@ -29,80 +30,61 @@ @implementation UIxContactsUserRightsEditor -- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects +/*- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects { if (userCanCreateObjects) [self appendRight: SOGoRole_ObjectCreator]; else [self removeRight: SOGoRole_ObjectCreator]; -} +}*/ - (BOOL) userCanCreateObjects { 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]; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index 69f8cf59b..ab571a174 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -8,7 +8,7 @@ xmlns:label="OGo:label" xmlns:rsrc="OGo:url" const:userDefaultsKeys="SOGoContactsCategories" - const:jsFiles="Common/resource.js, Contacts/card-model.js, Contacts/addressbook-model.js" + const:jsFiles="Common/acl-model.js, Common/resource.js, Contacts/card-model.js, Contacts/addressbook-model.js" className="UIxPageFrame" title="name" var:popup="isPopup"> @@ -61,12 +61,14 @@
+
+ - -
- - - -