예제 #1
0
        protected override AccessResult GetItemAccess(Item item, Account account, AccessRight accessRight,
                                                      PropagationType propagationType)
        {
            var result = base.GetItemAccess(item, account, accessRight, propagationType);

            // We don't want to overrule other permissions not allowing access (write access etc.)
            if (result?.Permission != AccessPermission.Allow)
            {
                return(result);
            }

            // Only check if the item is the "CanDesign" policy item or if context item is not null
            // Context item can be null for some requests in the Content Editor
            if (!ShouldCheckDesignRights(item))
            {
                return(result);
            }

            var designAccessResult = DesignAccessRight.GetAccess(Context.Item, account);

            if (designAccessResult.Permission != AccessPermission.Allow)
            {
                return(designAccessResult);
            }

            return(result);
        }
        private static AccessResult GetLayoutFieldAccess(Field field, Account account)
        {
            var accessResult = DesignAccessRight.GetAccess(field.Item, account);

            if (accessResult.Permission == AccessPermission.Allow)
            {
                return(null);
            }

            return(new AccessResult(AccessPermission.Deny, accessResult.Explanation));;
        }