Beispiel #1
0
        protected virtual bool NodeIsValid(Node node)
        {
            if (node == null || node.Name == "(apps)")
            {
                return(false);
            }
            if (TypeNames != null && !TypeNames.Contains(node.NodeType.Name))
            {
                return(false);
            }
            var contentNode = node as GenericContent;

            try
            {
                if (!ShowHiddenPages && ((contentNode != null) && contentNode.Hidden))
                {
                    return(false);
                }
            }
            catch (InvalidOperationException)
            {
                //"Invalid property access attempt"
                //The user has only See permission for this node. Changing to Admin account does not
                //help either, because the node is 'head only' and accessing any of its properties
                //will throw an invalidoperation exception anyway.
                return(false);
            }

            if (ExpandToContext)
            {
                var pathCollection = GetPathCollection(PortalContext.Current.Page.Path).ToList().
                                     Union(GetPathCollection(ContextNode.Path)).
                                     Union(GetPathCollection(PortalContext.Current.ContextNodePath)).
                                     ToArray();

                foreach (var path in pathCollection)
                {
                    if (node.Path.Equals(path) || IsSiblingPath(path, node.Path))
                    {
                        return(true);
                    }
                }

                if (GetContextChildren)
                {
                    var parentPath = RepositoryPath.GetParentPath(node.Path);
                    if (parentPath.Equals(PortalContext.Current.ContextNodePath) ||
                        parentPath.Equals(ContextNode.Path))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(true);
        }