When I copy a Document using its Copy(destinationFolderId, adminUser) method it copies the item to the destination, but it doesnt bring the public access security settings with it. Currently I am overcoming this by manually checking on the permissions and setting them on the copied item, but I wonder if there is a way to do this as part of the copy command
For reference here is how I am copying the permissions
var copyDoc = childDoc.Copy(doc.Id, admin); var copyDoc = childDoc.Copy(doc.Id, admin); var protectionType = umbraco.cms.businesslogic.web.Access.GetProtectionType(childDoc.Id); if (protectionType != ProtectionType.NotProtected) { int loginPageId = umbraco.cms.businesslogic.web.Access.GetLoginPage(childDoc.Path); int errorPageId = umbraco.cms.businesslogic.web.Access.GetErrorPage(childDoc.Path); umbraco.cms.businesslogic.web.Access.ProtectPage(protectionType == ProtectionType.Simple, copyDoc.Id, loginPageId, errorPageId); switch (protectionType) { case ProtectionType.Simple: var member = umbraco.cms.businesslogic.web.Access.GetAccessingMembershipUser(childDoc.Id); umbraco.cms.businesslogic.web.Access.AddMembershipUserToDocument(copyDoc.Id, member.UserName); break; case ProtectionType.Advanced: var roles = umbraco.cms.businesslogic.web.Access.GetAccessingMembershipRoles(childDoc.Id, childDoc.Path); foreach (var role in roles) { umbraco.cms.businesslogic.web.Access.AddMembershipRoleToDocument(copyDoc.Id, role); } break; } } copyDoc.Publish(admin);
Copy document with public access settings
When I copy a Document using its Copy(destinationFolderId, adminUser) method it copies the item to the destination, but it doesnt bring the public access security settings with it. Currently I am overcoming this by manually checking on the permissions and setting them on the copied item, but I wonder if there is a way to do this as part of the copy command
For reference here is how I am copying the permissions
is working on a reply...