private Content GetSharingGroupByUrlParameter()
        {
            var sharingGuid = _httpContext?.Request.Query[Constants.SharingUrlParameterName];

            return(string.IsNullOrEmpty(sharingGuid)
                ? null
                : SharingHandler.GetSharingGroupBySharingId(sharingGuid));
        }
Пример #2
0
        private static Content GetSharingGroupByUrlParameter(NameValueCollection parameters)
        {
            var sharingGuid = parameters?[Constants.SharingUrlParameterName];

            return(string.IsNullOrEmpty(sharingGuid)
                ? null
                : SharingHandler.GetSharingGroupBySharingId(sharingGuid));
        }
        internal MembershipExtension GetSharingExtension(string contextValue)
        {
            // check the url first
            var sharingGroup = GetSharingGroupByUrlParameter()?.ContentHandler as Group;

            // check the context param next
            if (sharingGroup == null && contextValue != null)
            {
                sharingGroup = SharingHandler.GetSharingGroupBySharingId(contextValue)?.ContentHandler as Group;
            }

            if (sharingGroup == null)
            {
                return(MembershipExtension.Placeholder);
            }

            var sharedNode = sharingGroup.GetReference <GenericContent>(Constants.SharedContentFieldName);

            // Check if the related shared content exists.
            if (sharedNode == null)
            {
                // Invalid sharing group: no related content. Delete the group and move on.
                SnTrace.Security.Write($"SharingMembershipExtender: Deleting orphaned sharing group {sharingGroup.Id} ({sharingGroup.Path}).");

                sharingGroup.ForceDelete();
                sharingGroup = null;
            }

            // If found and the content is not in the Trash, return a new extension collection
            // containing the sharing group.
            if ((sharingGroup?.ContentType.IsInstaceOfOrDerivedFrom(Constants.SharingGroupTypeName) ?? false) &&
                !TrashBin.IsInTrash(sharedNode))
            {
                return(new MembershipExtension(new[] { sharingGroup.Id }));
            }

            return(MembershipExtension.Placeholder);
        }