/// <summary> /// Creates the root node context menu for the content tree. /// Depending on the current User's permissions, this menu will change. /// If the current User's starting node is not -1 (the normal root content tree node) /// then the menu will be built based on the permissions of the User's start node. /// </summary> /// <param name="actions"></param> protected override void CreateRootNodeActions(ref List <IAction> actions) { actions.Clear(); if (StartNodeID != -1) { //get the document for the start node id Document doc = StartNode; if (doc == null) { return; } //get the allowed actions for the user for the current node List <IAction> nodeActions = GetUserActionsForNode(doc); //get the allowed actions for the tree based on the users allowed actions List <IAction> allowedMenu = GetUserAllowedActions(AllowedActions, nodeActions); actions.AddRange(allowedMenu); } else { // we need to get the default permissions as you can't set permissions on the very root node List <IAction> nodeActions = Action.FromString(CurrentUser.GetPermissions("-1")); List <IAction> allowedRootActions = new List <IAction>(); allowedRootActions.Add(ActionNew.Instance); allowedRootActions.Add(ActionSort.Instance); List <IAction> allowedMenu = GetUserAllowedActions(allowedRootActions, nodeActions); actions.AddRange(allowedMenu); if (allowedMenu.Count > 0) { actions.Add(ContextMenuSeperator.Instance); } // default actions for all users actions.Add(ActionRePublish.Instance); actions.Add(ContextMenuSeperator.Instance); actions.Add(ActionRefresh.Instance); //actions.Add(ActionTreeEditMode.Instance); } }
private bool CurrentUserHasPermissions(IContent contentNode) { return(Action.FromString(UmbracoUser.GetPermissions(contentNode.Path)).OfType <ActionBrowse>().Any()); }