diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index 5278a9d09..8c39a7ebd 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -19,7 +19,6 @@ */ #import -#import #import #import #import @@ -81,12 +80,10 @@ return defaultUserID; } -- (id ) usersForObjectAction +- (NSArray *) usersForObject { - id result; NSEnumerator *aclsEnum; NSString *currentUID, *ownerLogin; - NSDictionary *object; if (!prepared) { @@ -99,30 +96,13 @@ { if (!([currentUID isEqualToString: ownerLogin] || [currentUID isEqualToString: defaultUserID] - || [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]; - } + || [currentUID isEqualToString: @"anonymous"])) + [users addObjectUniquely: currentUID]; } - // 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; } - result = [self responseWithStatus: 200 - andString: [users jsonRepresentation]]; - - return result; + return users; } - (void) setCurrentUser: (NSString *) newCurrentUser @@ -153,13 +133,20 @@ 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 aa7599d0f..8a6ee1166 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,11 +183,13 @@ id response; if (![self _initRights]) - response = [self responseWithStatus: 403 - andString: @"No such user."]; + response = [NSException exceptionWithHTTPStatus: 403 + reason: @"No such user."]; else - response = [self responseWithStatus: 200 - andString:[[self userRightsForObject] jsonRepresentation]]; + { + [self prepareRightsForm]; + response = self; + } return response; } @@ -235,7 +237,6 @@ { response = [self responseWithStatus: 403 andString: @"No such user."]; - return response; } else { @@ -246,9 +247,10 @@ dd = [[context activeUser] domainDefaults]; if (![o isEqualToArray: userRights] && [dd aclSendEMailNotifications]) [self sendACLAdvisoryTemplateForObject: [self clientObject]]; + + response = [self jsCloseWithRefreshMethod: nil]; } } - response = [self jsCloseWithRefreshMethod: nil]; return response; } @@ -265,7 +267,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 56f8d74e9..d1ad5c1fd 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -63,11 +63,6 @@ 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 08a929b53..74e1e1a05 100644 --- a/UI/Contacts/UIxContactsUserRightsEditor.m +++ b/UI/Contacts/UIxContactsUserRightsEditor.m @@ -22,7 +22,6 @@ #import #import -#import #import #import @@ -30,61 +29,80 @@ @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]; } -- (NSDictionary *) userRightsForObject +- (void) updateRights { - return [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:[self userCanCreateObjects]], @"canCreateObjects", - [NSNumber numberWithBool:[self userCanEraseObjects]], @"canEraseObjects", - [NSNumber numberWithBool:[self userCanEditObjects]], @"canEditObjects", - [NSNumber numberWithBool:[self userCanViewObjects]], @"canViewObjects", nil]; -} + WORequest *request; -- (void) updateRights: (NSDictionary *) newRights -{ + request = [context request]; - if ([[newRights objectForKey: @"canCreateObjects"] boolValue]) + if ([[request formValueForKey: @"ObjectCreator"] length] > 0) [self appendRight: SOGoRole_ObjectCreator]; else [self removeRight: SOGoRole_ObjectCreator]; - if ([[newRights objectForKey: @"canEditObjects"] boolValue]) + if ([[request formValueForKey: @"ObjectEditor"] length] > 0) [self appendRight: SOGoRole_ObjectEditor]; else [self removeRight: SOGoRole_ObjectEditor]; - if ([[newRights objectForKey: @"canViewObjects"] boolValue]) + if ([[request formValueForKey: @"ObjectViewer"] length] > 0) [self appendRight: SOGoRole_ObjectViewer]; else [self removeRight: SOGoRole_ObjectViewer]; - if ([[newRights objectForKey: @"canEraseObjects"] boolValue]) + if ([[request formValueForKey: @"ObjectEraser"] length] > 0) [self appendRight: SOGoRole_ObjectEraser]; else [self removeRight: SOGoRole_ObjectEraser]; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index d4bdfcb1e..d009fe24b 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/acl-model.js, Common/resource.js, Contacts/card-model.js, Contacts/addressbook-model.js" + const:jsFiles="Common/resource.js, Contacts/card-model.js, Contacts/addressbook-model.js" className="UIxPageFrame" title="name" var:popup="isPopup"> @@ -61,14 +61,12 @@
-
- - +
+ + + +