Exemplo n.º 1
0
        /// <summary>
        /// Returns a <see cref="TreeNode"/> for the <see cref="IUmbracoEntity"/> and
        /// attaches some meta data to the node if the user doesn't have start node access to it when in dialog mode
        /// </summary>
        /// <param name="e"></param>
        /// <param name="parentId"></param>
        /// <param name="queryStrings"></param>
        /// <returns></returns>
        internal TreeNode GetSingleTreeNodeWithAccessCheck(IEntitySlim e, string parentId, FormDataCollection queryStrings,
                                                           int[] startNodeIds, string[] startNodePaths)
        {
            var entityIsAncestorOfStartNodes = ContentPermissionsHelper.IsInBranchOfStartNode(e.Path, startNodeIds, startNodePaths, out var hasPathAccess);
            var ignoreUserStartNodes         = IgnoreUserStartNodes(queryStrings);

            if (ignoreUserStartNodes == false && entityIsAncestorOfStartNodes == false)
            {
                return(null);
            }

            var treeNode = GetSingleTreeNode(e, parentId, queryStrings);

            if (treeNode == null)
            {
                //this means that the user has NO access to this node via permissions! They at least need to have browse permissions to see
                //the node so we need to return null;
                return(null);
            }
            if (!ignoreUserStartNodes && !hasPathAccess)
            {
                treeNode.AdditionalData["noAccess"] = true;
            }
            return(treeNode);
        }
Exemplo n.º 2
0
        internal static bool IsInBranchOfStartNode(this IUser user, IUmbracoEntity entity, IEntityService entityService, int recycleBinId, out bool hasPathAccess)
        {
            switch (recycleBinId)
            {
            case Constants.System.RecycleBinMedia:
                return(ContentPermissionsHelper.IsInBranchOfStartNode(entity.Path, user.CalculateMediaStartNodeIds(entityService), user.GetMediaStartNodePaths(entityService), out hasPathAccess));

            case Constants.System.RecycleBinContent:
                return(ContentPermissionsHelper.IsInBranchOfStartNode(entity.Path, user.CalculateContentStartNodeIds(entityService), user.GetContentStartNodePaths(entityService), out hasPathAccess));

            default:
                throw new NotSupportedException("Path access is only determined on content or media");
            }
        }