Added the permissions checks in the new content tree including start node rendering
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
@@ -22,7 +23,7 @@ namespace Umbraco.Web.Trees
|
||||
|| (a.Action.CanBePermissionAssigned && userAllowedActions.Contains(a.Action)))));
|
||||
}
|
||||
|
||||
internal MenuItemCollection GetUserMenuItemsForNode(UmbracoEntity dd)
|
||||
internal MenuItemCollection GetUserMenuItemsForNode(IUmbracoEntity dd)
|
||||
{
|
||||
var actions = global::umbraco.BusinessLogic.Actions.Action.FromString(UmbracoUser.GetPermissions(dd.Path));
|
||||
|
||||
@@ -33,5 +34,16 @@ namespace Umbraco.Web.Trees
|
||||
return new MenuItemCollection(actions.Select(x => new MenuItem(x)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determins if the user has access to view the node/document
|
||||
/// </summary>
|
||||
/// <param name="doc">The Document to check permissions against</param>
|
||||
/// <param name="allowedUserOptions">A list of MenuItems that the user has permissions to execute on the current document</param>
|
||||
/// <remarks>By default the user must have Browse permissions to see the node in the Content tree</remarks>
|
||||
/// <returns></returns>
|
||||
internal bool CanUserAccessNode(IUmbracoEntity doc, IEnumerable<MenuItem> allowedUserOptions)
|
||||
{
|
||||
return allowedUserOptions.Select(x => x.Action).OfType<ActionBrowse>().Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user