6

I am trying to remove access to shared presentation for a particular role. I have denied read on this item: /sitecore/content/Applications/WebEdit/Ribbons/Chunks/Layout Modes/Shared Layout. This works as the user is no longer able to toggle between shared and final.

Now, my user role can still open the presentation details dialog and edit the shared layout from there. They can also use the reset presentation dialog to reset the shared presentation. How do I deny access to these items?

2

In addition to what you have done you can do the following using a role:

In the master database deny field read and write access to /sitecore/templates/System/Templates/Sections/Layout/Layout/__Renderings. This will keep the user from being able to manually edit the shared field. This is not necessary is you already deny access to view standard fields in any way.

After doing that you will need to go to the file webroot/sitecore/shell/Applications/Content Manager/Dialogs/LayoutDetails/LayoutDetails.xml and change the CodeBeside to point to a custom class that inherits from Sitecore.Shell.Applications.ContentManager.Dialogs.LayoutDetails.LayoutDetailsForm. Here is an something you could use:

using Sitecore.Shell.Applications.ContentManager.Dialogs.LayoutDetails;
using System;

namespace CroweHorwath.Common
{
    public class CustomLayoutDetailsForm : LayoutDetailsForm
    {
        private const string DenySharedLayoutViewRole = "{YOUR_ROLE}";

        protected override void OnLoad(EventArgs e)
        {
            if (Sitecore.Context.User.IsInRole(DenySharedLayoutViewRole))
            {
                SharedLayoutTab.Active = false;
                FinalLayoutTab.Active = true;
                Tabs.Active = (int)TabType.Final;

                SharedLayoutTab.Visible = false;
            }

            base.OnLoad(e);
        }

        //Had to add this because the base TabType enum the base
        //type uses is private. You can just use a number if you
        //really wanted to where I use this if you are worried 
        //someone will see that Shared/Unknown aren't used and
        //remove them
        private enum TabType
        {
            Shared,
            Final,
            Unknown,
        }
    }
}

You would copy in your role with its domain where I put {YOUR_ROLE}. You could put the role in a config file. If you need multiple roles to do this make a base role to deny access to the shared layout and have those inherit that.

1

It doesn’t seem there is a way to do that via configuration.

To disable access to shared presentation based on a security role, you can try customizing Sitecore.Shell.Applications.Layouts.PageDesigner.Commands.Reset and Sitecore.Shell.Applications.ContentManager.Dialogs.LayoutDetails.LayoutDetailsForm logic.

To replace the Reset command, you’ll need to patch the pagedesigner:reset command via include config file.

To replace LayoutDetailsForm, you’ll need

  1. Copy \Website\sitecore\shell\Applications\Content Manager\Dialogs\LayoutDetails\LayoutDetails.xml file
  2. Put it to Website\sitecore\shell\Override folder
  3. In copied file replace the CodeBeside type with a custom type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.