Fixed: U4-5324 Users with a content root node, cant have custom tree roots
This commit is contained in:
@@ -117,46 +117,51 @@ namespace Umbraco.Web.Trees
|
|||||||
protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||||
{
|
{
|
||||||
//check if we're rendering the root
|
//check if we're rendering the root
|
||||||
if (id == Constants.System.Root.ToInvariantString() && UserStartNode == Constants.System.Root)
|
if (id == Constants.System.Root.ToInvariantString())
|
||||||
{
|
{
|
||||||
var nodes = new TreeNodeCollection();
|
//when rendering the root, 3 things can happen:
|
||||||
var altStartId = string.Empty;
|
//1. we return -1 children without modifications
|
||||||
|
//2. the user has a non -1 content root set and we return that
|
||||||
|
//3. the tree has a non -1 content root set and we return that - if the user has access to it.
|
||||||
|
|
||||||
if (queryStrings.HasKey(TreeQueryStringParameters.StartNodeId))
|
var hasUserRoot = UserStartNode != Constants.System.Root;
|
||||||
altStartId = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
|
var hasTreeRoot = queryStrings.HasKey(TreeQueryStringParameters.StartNodeId);
|
||||||
|
|
||||||
|
//initial id
|
||||||
|
var idToLoad = id;
|
||||||
|
|
||||||
//check if a request has been made to render from a specific start node
|
//user permission override root
|
||||||
//TODO: This 'undefined' check should not be required whatseover - this parameter should not be sent up ever it if is null from the front-end.
|
if (hasUserRoot)
|
||||||
if (!string.IsNullOrEmpty(altStartId) && altStartId != "undefined" && altStartId != Constants.System.Root.ToString(CultureInfo.InvariantCulture))
|
idToLoad = UserStartNode.ToString();
|
||||||
|
|
||||||
|
//tree overrides root
|
||||||
|
if (hasTreeRoot)
|
||||||
{
|
{
|
||||||
id = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
|
//but only if the user is allowed to access this node
|
||||||
|
var _id = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
|
||||||
|
|
||||||
//we need to verify that the user has access to view this node, otherwise we'll render an empty tree collection
|
//so if we dont have a user content root or the user has access
|
||||||
// TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access
|
if (!hasUserRoot || HasPathAccess(_id, queryStrings))
|
||||||
if (HasPathAccess(id, queryStrings))
|
|
||||||
{
|
{
|
||||||
nodes = GetTreeNodesInternal(id, queryStrings);
|
idToLoad = _id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
//load whatever root nodes we concluded was the user/tree root
|
||||||
//load normally
|
var nodes = new TreeNodeCollection();
|
||||||
nodes = GetTreeNodesInternal(id, queryStrings);
|
nodes = GetTreeNodesInternal(idToLoad, queryStrings);
|
||||||
}
|
|
||||||
|
|
||||||
//only render the recycle bin if we are not in dialog and the start id id still the root
|
//only render the recycle bin if we are not in dialog and the start id id still the root
|
||||||
if (IsDialog(queryStrings) == false && id == Constants.System.Root.ToInvariantString())
|
if (IsDialog(queryStrings) == false && idToLoad == Constants.System.Root.ToInvariantString())
|
||||||
{
|
{
|
||||||
nodes.Add(CreateTreeNode(
|
nodes.Add(CreateTreeNode(
|
||||||
RecycleBinId.ToInvariantString(),
|
RecycleBinId.ToInvariantString(),
|
||||||
id,
|
idToLoad,
|
||||||
queryStrings,
|
queryStrings,
|
||||||
ui.GetText("general", "recycleBin"),
|
ui.GetText("general", "recycleBin"),
|
||||||
"icon-trash",
|
"icon-trash",
|
||||||
RecycleBinSmells,
|
RecycleBinSmells,
|
||||||
queryStrings.GetValue<string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin"));
|
queryStrings.GetValue<string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodes;
|
return nodes;
|
||||||
|
|||||||
Reference in New Issue
Block a user