Merge pull request #2629 from umbraco/temp-U4-11339
Fixes - User permissions does not work in listview in 7.10.4
This commit is contained in:
@@ -68,16 +68,17 @@ namespace Umbraco.Web.Trees
|
||||
var allowedUserOptions = GetAllowedUserMenuItemsForNode(e);
|
||||
if (CanUserAccessNode(e, allowedUserOptions))
|
||||
{
|
||||
|
||||
//Special check to see if it ia a container, if so then we'll hide children.
|
||||
var isContainer = e.IsContainer(); // && (queryStrings.Get("isDialog") != "true");
|
||||
|
||||
var hasChildren = ShouldRenderChildrenOfContainer(e);
|
||||
|
||||
var node = CreateTreeNode(
|
||||
entity,
|
||||
Constants.ObjectTypes.DocumentGuid,
|
||||
parentId,
|
||||
queryStrings,
|
||||
entity.HasChildren && (isContainer == false));
|
||||
hasChildren);
|
||||
|
||||
node.AdditionalData.Add("contentType", entity.ContentTypeAlias);
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Umbraco.Web.Trees
|
||||
entityId = entity.Id;
|
||||
}
|
||||
|
||||
return Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToArray();
|
||||
return Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -274,6 +274,37 @@ namespace Umbraco.Web.Trees
|
||||
return GetTreeNodesInternal(id, queryStrings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if we should return children of a container node
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This is required in case a user has custom start nodes that are children of a list view since in that case we'll need to render the tree node. In normal cases we don't render
|
||||
/// children of a list view.
|
||||
/// </remarks>
|
||||
protected bool ShouldRenderChildrenOfContainer(IUmbracoEntity e)
|
||||
{
|
||||
var isContainer = e.IsContainer();
|
||||
|
||||
var renderChildren = e.HasChildren() && (isContainer == false);
|
||||
|
||||
//Here we need to figure out if the node is a container and if so check if the user has a custom start node, then check if that start node is a child
|
||||
// of this container node. If that is true, the HasChildren must be true so that the tree node still renders even though this current node is a container/list view.
|
||||
if (isContainer && UserStartNodes.Length > 0 && UserStartNodes.Contains(Constants.System.Root) == false)
|
||||
{
|
||||
var startNodes = Services.EntityService.GetAll(UmbracoObjectType, UserStartNodes);
|
||||
//if any of these start nodes' parent is current, then we need to render children normally so we need to switch some logic and tell
|
||||
// the UI that this node does have children and that it isn't a container
|
||||
if (startNodes.Any(x => x.ParentId == e.Id))
|
||||
{
|
||||
renderChildren = true;
|
||||
}
|
||||
}
|
||||
|
||||
return renderChildren;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Before we make a call to get the tree nodes we have to check if they can actually be rendered
|
||||
/// </summary>
|
||||
@@ -290,7 +321,7 @@ namespace Umbraco.Web.Trees
|
||||
//before we get the children we need to see if this is a container node
|
||||
|
||||
//test if the parent is a listview / container
|
||||
if (current != null && current.IsContainer())
|
||||
if (current != null && ShouldRenderChildrenOfContainer(current) == false)
|
||||
{
|
||||
//no children!
|
||||
return new TreeNodeCollection();
|
||||
|
||||
Reference in New Issue
Block a user