Exemple #1
0
        protected bool IsPermitted(Document doc, IUser user, bool isCurrentUser)
        {
            var path = doc.Get(LucObject.FieldName.Path);

            var createdById      = IntegerIndexHandler.ConvertBack(doc.Get(LucObject.FieldName.CreatedById));
            var lastModifiedById = IntegerIndexHandler.ConvertBack(doc.Get(LucObject.FieldName.ModifiedById));
            var isLastPublic     = BooleanIndexHandler.ConvertBack(doc.Get(LucObject.FieldName.IsLastPublic));
            var isLastDraft      = BooleanIndexHandler.ConvertBack(doc.Get(LucObject.FieldName.IsLastDraft));
            var level            = isCurrentUser
                ? SecurityHandler.GetPermittedLevel(path, createdById, lastModifiedById)
                : SecurityHandler.GetPermittedLevel(path, createdById, lastModifiedById, user);

            switch (level)
            {
            case PermittedLevel.None:
                return(false);

            case PermittedLevel.HeadOnly:
                return(isLastPublic);

            case PermittedLevel.PublicOnly:
                return(isLastPublic);

            case PermittedLevel.All:
                return(isLastDraft);

            default:
                throw new NotImplementedException();
            }
        }