public void Adjust(CheckAccessContext context) { //if (context.Permission.Name.Equals("ManageMediaContent")) { // context.Adjusted = true; // context.Permission = GroupsPermissions.ViewMedia; //} if (!context.Granted && context.Content.Is <ICommonPart>()) { if (HasGroupOwnership(context.User, context.Content)) { if (context.Permission.Name.Equals("EditContent")) { context.Adjusted = true; context.Permission = GroupsPermissions.EditContentForOwnGroups; } else if (context.Permission.Name.Equals("PublishContent")) { context.Adjusted = true; context.Permission = GroupsPermissions.PublishContentForOwnGroups; } else if (context.Permission.Name.Equals("DeleteContent")) { context.Adjusted = true; context.Permission = GroupsPermissions.DeleteContentForOwnGroups; } else if (context.Permission.Name.Equals("ManageBlogs")) { context.Adjusted = true; context.Permission = GroupsPermissions.ManageBlogsForOwnGroups; } else if (context.Permission.Name.Equals("PublishBlogPost")) { context.Adjusted = true; context.Permission = GroupsPermissions.PublishBlogPostForOwnGroups; } else if (context.Permission.Name.Equals("EditBlogPost")) { context.Adjusted = true; context.Permission = GroupsPermissions.EditBlogPostForOwnGroups; } else if (context.Permission.Name.Equals("DeleteBlogPost")) { context.Adjusted = true; context.Permission = GroupsPermissions.DeleteBlogPostForOwnGroups; } else if (context.Permission.Name.StartsWith("Delete_") || context.Permission.Name.StartsWith("Edit_") || context.Permission.Name.StartsWith("Publish_")) { var permission = context.Permission; permission = GetGroupVariation(context.Permission); // output is like PublishGroup_{0} var typeDefinition = context.Content.ContentItem.TypeDefinition; if (typeDefinition.Settings.GetModel <ContentTypeSettings>().Securable) { if (permission != null) { context.Adjusted = true; context.Permission = DynamicGroupsPermissions.CreateDynamicGroupPermission(permission, typeDefinition); } } } } } }
private static Permission GetGroupVariation(Permission permission) { return(DynamicGroupsPermissions.ConvertToGroupPermission(permission)); }