Example #1
0
        protected internal bool IsPermitted(Document doc)
        {
            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 docLevel   = GetDocumentLevel(path, createdById, lastModifiedById);
            var fieldLevel = this.LucQuery.FieldLevel;

            if (this.AllVersions)
            {
                var canAccesOldVersions = SecurityHandler.HasPermission(this.User, path, createdById, lastModifiedById, PermissionType.RecallOldVersion);
                switch (docLevel)
                {
                case DocumentOpenLevel.Denied:
                    return(false);

                case DocumentOpenLevel.See:
                    return(isLastPublic && canAccesOldVersions && fieldLevel <= QueryFieldLevel.HeadOnly);

                case DocumentOpenLevel.Preview:
                    return(isLastPublic && canAccesOldVersions && fieldLevel <= QueryFieldLevel.NoBinaryOrFullText);

                case DocumentOpenLevel.Open:
                    return(isLastPublic);

                case DocumentOpenLevel.OpenMinor:
                    return(canAccesOldVersions);

                default:
                    throw new NotImplementedException("##Unknown DocumentOpenLevel");
                }
            }
            else
            {
                switch (docLevel)
                {
                case DocumentOpenLevel.Denied:
                    return(false);

                case DocumentOpenLevel.See:
                    return(isLastPublic && fieldLevel <= QueryFieldLevel.HeadOnly);

                case DocumentOpenLevel.Preview:
                    return(isLastPublic && fieldLevel <= QueryFieldLevel.NoBinaryOrFullText);

                case DocumentOpenLevel.Open:
                    return(isLastPublic);

                case DocumentOpenLevel.OpenMinor:
                    return(isLastDraft);

                default:
                    throw new NotImplementedException("##Unknown DocumentOpenLevel");
                }
            }
        }
Example #2
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();
            }
        }