Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • greengiant83 88 posts 109 karma points
    Feb 18, 2011 @ 19:03
    greengiant83
    0

    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

    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);

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies