Added native events to base tree class so they will all have them.

This commit is contained in:
Shannon
2013-07-30 14:23:39 +10:00
parent 2bbc610550
commit 2d38938d86
7 changed files with 149 additions and 69 deletions

View File

@@ -13,36 +13,6 @@ using umbraco.interfaces;
namespace Umbraco.Web.Trees
{
public abstract class ContentTreeControllerBase : TreeApiController
{
/// <summary>
/// Based on the allowed actions, this will filter the ones that the current user is allowed
/// </summary>
/// <param name="allMenuItems"></param>
/// <param name="userAllowedMenuItems"></param>
/// <returns></returns>
protected MenuItemCollection GetUserAllowedMenuItems(IEnumerable<MenuItem> allMenuItems, IEnumerable<MenuItem> userAllowedMenuItems)
{
var userAllowedActions = userAllowedMenuItems.Where(x => x.Action != null).Select(x => x.Action).ToArray();
return new MenuItemCollection(allMenuItems.Where(
a => (a.Action == null
|| a.Action.CanBePermissionAssigned == false
|| (a.Action.CanBePermissionAssigned && userAllowedActions.Contains(a.Action)))));
}
internal MenuItemCollection GetUserMenuItemsForNode(UmbracoEntity dd)
{
var actions = global::umbraco.BusinessLogic.Actions.Action.FromString(UmbracoUser.GetPermissions(dd.Path));
// A user is allowed to delete their own stuff
if (dd.CreatorId == UmbracoUser.Id && actions.Contains(ActionDelete.Instance) == false)
actions.Add(ActionDelete.Instance);
return new MenuItemCollection(actions.Select(x => new MenuItem(x)));
}
}
[Tree(Constants.Applications.Content, Constants.Trees.Content, "Content")]
public class ContentTreeController : ContentTreeControllerBase
{