diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index 373adf331..8093ce7d8 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -80,7 +80,7 @@ return defaultUserID; } -- (NSArray *) usersForObject +- (id ) aclsAction { NSEnumerator *aclsEnum; NSString *currentUID, *ownerLogin; @@ -105,14 +105,14 @@ object = [NSDictionary dictionaryWithObjectsAndKeys: currentUser, @"uid", [self currentUserClass], @"userClass", [self currentUserDisplayName], @"displayName", - [NSNumber numberWithBool:[self currentUserIsSubscribed]], @"isSubscribed", nil]; - [users setObject:object forKey: currentUID]; + [NSNumber numberWithBool: [self currentUserIsSubscribed]], @"isSubscribed", nil]; + [users setObject: object forKey: currentUID]; } } // Adding the Any authenticated user and the public access - [users setObject:[NSDictionary dictionaryWithObjectsAndKeys: @"", @"uid", [self labelForKey: @"Any Authenticated User"], @"displayName", @"public-user", @"userClass", nil] forKey: @""]; + [users setObject: [NSDictionary dictionaryWithObjectsAndKeys: @"", @"uid", [self labelForKey: @"Any Authenticated User"], @"displayName", @"public-user", @"userClass", nil] forKey: @""]; if ([self isPublicAccessEnabled]) - [users setObject:[NSDictionary dictionaryWithObjectsAndKeys: @"anonymous", @"uid", [self labelForKey: @"Public Access"], @"displayName", @"public-user", @"userClass", nil] forKey: @"anonymous"]; + [users setObject: [NSDictionary dictionaryWithObjectsAndKeys: @"anonymous", @"uid", [self labelForKey: @"Public Access"], @"displayName", @"public-user", @"userClass", nil] forKey: @"anonymous"]; prepared = YES; } diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 7cea2e989..06f52f4f0 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -119,29 +119,62 @@ 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 isEqualToString: defaultUserID] + || [newUID isEqualToString: @"anonymous"] + || [[um getEmailForUID: newUID] length] > 0) + { + 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]]; - ASSIGN (uid, newUID); - clientObject = [self clientObject]; - [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; - - response = YES; - } + response = YES; + } } + return response; +} +- (BOOL) _initRightsForUserID:(NSString *) newUID +{ + BOOL response; + NSString *domain; + SOGoUserManager *um; + SOGoObject *clientObject; + SOGoGroup *group; + response = NO; + + if ([newUID length] > 0) + { + if (!defaultUserID) + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); + + um = [SOGoUserManager sharedUserManager]; + if ([newUID isEqualToString: defaultUserID] || [newUID isEqualToString: @"anonymous"] + || [[um getEmailForUID: newUID] length] > 0) + { + if (![newUID hasPrefix: @"@"]) + { + domain = [[context activeUser] domain]; + group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain]; + if (group) + newUID = [NSString stringWithFormat: @"@%@", newUID]; + } + ASSIGN (uid, newUID); + clientObject = [self clientObject]; + [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; + + response = YES; + } + } return response; } @@ -150,14 +183,13 @@ id response; if (![self _initRights]) - response = [NSException exceptionWithHTTPStatus: 403 - reason: @"No such user."]; - else - { - [self prepareRightsForm]; - response = self; - } - + response = [self responseWithStatus: 403 + andString: @"No such user."]; + else { + //[self prepareRightsForm]; + response = [self responseWithStatus: 200 + andString:[[self userRightsForObject] jsonRepresentation]]; + } return response; } @@ -186,32 +218,31 @@ - (id ) saveUserRightsAction { id response; + WORequest *request; SOGoDomainDefaults *dd; - NSDictionary *jsonObject, *currentObject; + NSDictionary *dirtyUsers, *currentUser, *jsonResponse;; NSEnumerator *enumerator; + NSString *uid; NSArray *o; - id key; - value = [[self context] request]; - jsonObject = [[value contentAsString] objectFromJSONString]; - enumerator = [jsonObject keyEnumerator]; + request = [[self context] request]; + dirtyUsers = [[request contentAsString] objectFromJSONString]; + enumerator = [dirtyUsers keyEnumerator]; - while((key = [enumerator nextObject])) + while((uid = [enumerator nextObject])) { - currentObject = [jsonObject objectForKey: key]; - if(![self _initRightsWithParameter: [currentObject objectForKey: @"uid"]]) + currentUser = [dirtyUsers objectForKey: uid]; + if(!([self _initRightsForUserID: [currentUser objectForKey: @"uid"]])) { + jsonResponse = [NSDictionary dictionaryWithObject: @"No such user." forKey: @"error"]; response = [self responseWithStatus: 403 - andString: @"No such user."]; + andString: [jsonResponse jsonRepresentation]]; return response; } else { - NSArray *o; - o = [NSArray arrayWithArray: userRights]; - - [self updateRights]; + [self updateRights:[currentUser objectForKey: @"aclOptions"]]; [[self clientObject] setRoles: userRights forUser: uid]; dd = [[context activeUser] domainDefaults]; @@ -220,7 +251,8 @@ response = [self jsCloseWithRefreshMethod: nil]; } - + } + response = [self responseWithStatus: 200]; return response; } diff --git a/UI/Common/product.plist b/UI/Common/product.plist index d1ad5c1fd..e58a36c62 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -45,10 +45,6 @@ actionClass = "UIxObjectActions"; actionName = "delete"; }; - acls = { - protectedBy = "ReadAcls"; - pageName = "UIxAclEditor"; - }; saveAcls = { protectedBy = "Change Permissions"; pageName = "UIxAclEditor"; @@ -63,6 +59,11 @@ pageName = "UIxUserRightsEditor"; actionName = "saveUserRights"; }; + acls = { + protectedBy = "ReadAcls"; + pageName = "UIxAclEditor"; + actionName = "acls"; + }; }; }; SOGoParentFolder = { diff --git a/UI/Contacts/UIxContactsUserRightsEditor.m b/UI/Contacts/UIxContactsUserRightsEditor.m index 74e1e1a05..ee3e45444 100644 --- a/UI/Contacts/UIxContactsUserRightsEditor.m +++ b/UI/Contacts/UIxContactsUserRightsEditor.m @@ -29,14 +29,6 @@ @implementation UIxContactsUserRightsEditor -- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects -{ - if (userCanCreateObjects) - [self appendRight: SOGoRole_ObjectCreator]; - else - [self removeRight: SOGoRole_ObjectCreator]; -} - - (BOOL) userCanCreateObjects { return [userRights containsObject: SOGoRole_ObjectCreator]; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index b7be3b3bb..bfa4b3e59 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/user-model.js, Common/acl-model.js, Common/resource.js, Contacts/card-model.js, Contacts/addressbook-model.js" className="UIxPageFrame" title="name" var:popup="isPopup"> @@ -66,11 +66,77 @@ +
+

+
+ +
+
+
    +
  • + + + {{user.displayName}} + + + +
  • +
+
+
+
+ + + +
+ +
+
+ + +
+ +
+ + +
+
+
    +
  • + +
  • + +
  • + +
  • + +
  • + +
  • + +
  • + +
  • +
+
+
+
+
+ + +
+
+ +