Ejemplo n.º 1
0
        private void ExplicitPermissionToRelatedContents(EntityPermissionBase permission)
        {
            Debug.Assert(permission != null);

            var content = ContentPermissionRepository.GetContentById(permission.ParentEntityId);

            if (content == null)
            {
                throw new ApplicationException("Content has not been found. ID: " + permission.ParentEntityId);
            }

            IEnumerable <int> relatedContentId = content.Fields
                                                 .Select(f => f.RelateToContentId)
                                                 .Where(id => id.HasValue && id.Value != permission.ParentEntityId)
                                                 .Select(id => id.Value)
                                                 .Distinct()
                                                 .ToArray();

            var noPermissionRelatedContentId = ContentPermissionRepository.FilterNoPermissionContent(relatedContentId, permission.UserId, permission.GroupId);

            ContentPermissionRepository.MultipleSetPermission(noPermissionRelatedContentId, permission.UserId, permission.GroupId, PermissionLevel.Read);
        }
Ejemplo n.º 2
0
 private static bool PermissionUserOrGroupEquals(EntityPermissionBase permission, SitePermissionDAL p) =>
 (permission.GroupId.HasValue ? p.GroupId == permission.GroupId.Value : p.GroupId == null) &&
 (permission.UserId.HasValue ? p.UserId == permission.UserId.Value : p.UserId == null);
Ejemplo n.º 3
0
        private void ExplicitPermissionToRelatedContents(ICollection <int> contentIds, EntityPermissionBase permission)
        {
            var contents = ContentPermissionRepository.GetContentList(contentIds);
            IEnumerable <int> relatedContentId = contents.SelectMany(c => c.Fields.Select(f => f.RelateToContentId))
                                                 .Distinct()
                                                 .Where(id => id.HasValue && !contentIds.Contains(id.Value))
                                                 .Select(id => id.Value)
                                                 .ToArray();

            var noPermissionRelatedContentId = ContentPermissionRepository.FilterNoPermissionContent(relatedContentId, permission.UserId, permission.GroupId);

            ContentPermissionRepository.MultipleSetPermission(noPermissionRelatedContentId, permission.UserId, permission.GroupId, PermissionLevel.Read);
        }