Write an event handler or pipeline processor and place inside following code:
if (Context.User.IsInRole("sitecore\\ROLE_NAME"))
{
Sitecore.Shell.UserOptions.View.ShowEntireTree = false;
}
This will basically disable the EntireTree for your current user if he belongs to role ROLE_NAME
I would suggest to add this into some event, however this is your choice when and how often you need to revalidate it.
I would avoid anything that influence normal user experience, which is for instance: httpRequestBegin
. So concentrate on pipelines/events that are used by logged users.
You can find some examples and POC below:
EVENT HANLDER
Configuration:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events>
<event name="security:loggedIn">
<handler type="Sitecore.Playground.EventHandlers.DisableEntireTree, Sitecore.Playground" method="DisableEntireTreeMethod" />
</event>
</events>
</sitecore>
</configuration>
Code:
namespace Sitecore.Playground.EventHandlers
{
public class DisableEntireTree
{
public void DisableEntireTreeMethod(object sender, EventArgs args)
{
if (Context.User.IsInRole("sitecore\\Experience Explorer"))
{
UserOptions.View.ShowEntireTree = false;
}
}
}
}
I tested it with item:saved event, everything worked fine but this not what you probably want.
PIPELINE PROCESSOR:
Configuration:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<renderContentEditor>
<processor type="Sitecore.Playground.Pipelines.RenderContentEditor.DisableEntireTree, Sitecore.Playground" />
</renderContentEditor>
</pipelines>
</sitecore>
</configuration>
Code:
namespace Sitecore.Playground.Pipelines.RenderContentEditor
{
public class DisableEntireTree
{
public void Process(RenderContentEditorArgs args)
{
if (Context.User.IsInRole("sitecore\\Experience Explorer"))
{
UserOptions.View.ShowEntireTree = false;
}
}
}
}
Works almost fine. During first load value in ribbon is changed but tree needs reload. Find your best match.